Recording
A Recording resource represents the recording associated with a voice call, conference, or SIP Trunk. Using the Recordings REST API you can fetch, start, stop, pause, resume, and delete voice recordings.
You can initiate a recording for your call, conference, or trunk via one of the following methods.
- TwiML中の<Record>
- TwiML中の<Dial record>
- TwiML中の<Conference record>
- Record=true in an outbound call via the REST API
- Enable recording on an elastic SIP Trunk in the Twilio Console
- Post to Recording resource of an in-progress Call SID
Once a recording is initiated, you can optionally pause, resume, or stop the recording
Recording properties
Resource Properties in REST API format | |
---|---|
account_sid
|
The SID of the Account that created the Recording resource. |
api_version
|
The API version used during the recording. |
call_sid
|
The SID of the Call the Recording resource is associated with. This will always refer to the parent leg of a two-leg call. |
conference_sid
|
The Conference SID that identifies the conference associated with the recording, if a conference recording. |
date_created
|
The date and time in GMT that the resource was created specified in RFC 2822 format. |
date_updated
|
The date and time in GMT that the resource was last updated specified in RFC 2822 format. |
start_time
|
The start time of the recording in GMT and in RFC 2822 format. |
duration
|
The length of the recording in seconds. |
sid
|
The unique string that that we created to identify the Recording resource. |
price
|
The one-time cost of creating the recording in the |
price_unit
|
The currency used in the |
status
|
The status of the recording. Can be: |
channels
|
The number of channels in the final recording file. Can be: |
source
|
How the recording was created. Can be: |
error_code
|
The error code that describes why the recording is |
uri
|
The URI of the resource, relative to |
encryption_details
|
How to decrypt the recording if it was encrypted using Call Recording Encryption feature. |
subresource_uris
|
A list of related resources identified by their relative URIs. |
Create a Recording resource
POST https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Calls/{CallsSid}/Recordings.json
To start a recording on a live call, make an HTTP Post request to the Recordings list resource of an in-progress Call.
Legal implications of call recording
If you choose to record voice or video calls, you need to comply with certain laws and regulations, including those regarding obtaining consent to record (such as California’s Invasion of Privacy Act and similar laws in other jurisdictions). Additional information on the legal implications of call recording can be found here.
Notice: Twilio recommends that you consult with your legal counsel to make sure that you are complying with all applicable laws in connection with communications you record or store using Twilio.
オプションパラメーター
進行中の通話での録音の開始時は、POST時に下記のオプションパラメーターが利用可能です。
Parameters in REST API format | |
---|---|
account_sid
Path
|
The SID of the Account that will create the resource. |
call_sid
Path
|
The SID of the Call to associate the resource with. |
recording_status_callback_event
オプション
|
The recording status events on which we should call the |
recording_status_callback
オプション
|
The URL we should call using the |
recording_status_callback_method
オプション
|
The HTTP method we should use to call |
trim
オプション
|
Whether to trim any leading and trailing silence in the recording. Can be: |
recording_channels
オプション
|
The number of channels used in the recording. Can be: |
recording_track
オプション
|
The audio track to record for the call. Can be: |
RecordingStatusCallback
Twilio will pass the following parameters with its request to your RecordingStatusCallback
URL:
パラメーター | 概要 |
---|---|
AccountSid | この録音の属するアカウントの一意な識別子です。 |
CallSid | 録音に関連づけられた通話の一意な識別子です。 |
RecordingSid | この録音のユニークな識別子です。 |
RecordingUrl | 録音された音声の URL。 |
RecordingStatus | 録音ステータスです。 取りうる値はin-progress 、completed 、およびabsent です。 |
RecordingDuration | The length of the recording, in seconds. (only provided when RecordingStatus is completed ) |
RecordingChannels | 最終的な録音ファイルのチャンネル数を示す整数です。 取りうる値は 1 および 2 です。 |
RecordingStartTime | The timestamp of when the recording started. |
RecordingSource | The initiation method used to create this recording. For recordings initiated with this API, the value will be StartCallRecordingAPI . |
RecordingTrack | The audio track recorded. Possible values are inbound , outbound or both . |
Fetch a Recording resource
GET https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Recordings/{Sid}.json
Because the URLs that host individual recordings are useful for many external applications, they are public and do not require HTTP Basic Auth to access. This allows you to embed the recording URL in a web application without revealing your Twilio API credentials.
Twilio's recording URLs are quite long and difficult to guess, so the contents of the recordings should be reasonably private unless you distribute the URL. For added security, you can enforce HTTP basic auth to access media using your AccountSid and Authentication token via the voice settings page in the console.
Parameters in REST API format | |
---|---|
account_sid
Path
|
The SID of the Account that created the Recording resource to fetch. |
sid
Path
|
The Twilio-provided string that uniquely identifies the Recording resource to fetch. |
Fetch recording metadata
Recordings Resource Metadata can be returned in either json or xml by appending the either the '.json' or 'xml' suffix to the URI.
Fetch a recording media file
WAV
拡張子なし、または「.wav」の場合は、MIME-Type が「audio/x-wav」のバイナリ WAV 音声ファイルを返します。 たとえば、次のようになります。
GET https://api.twilio.com/2010-04-01/Accounts/ACXXXXX.../Recordings/RE557ce644e5ab84fa21cc21112e22c485
WAV files have a bitrate of 128kbps
MP3
URI に「.mp3」をつけると、MIME-Type が「audio/mpeg」 のバイナリ MP3 音声ファイルを返します。 たとえば、次のようになります。
GET https://api.twilio.com/2010-04-01/Accounts/ACXXXXX.../Recordings/RE557ce644e5ab84fa21cc21112e22c485.mp3
MP3 files have a bitrate of 32kbps
Fetch a Recording's Transcriptions
Each Recording instance resource has a Transcriptions subresource which represents the set of transcriptions generated from the recording (if any):
GET https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Recordings/{RecordingSid}/Transcriptions
This will return the set of transcriptions available for the recording identified by {RecordingSid}
. See the Transcriptions resource documentation for properties and response formats.
Read multiple Recording Resources
GET https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Recordings.json
This API call returns a list of Recordings, each representing a recording generated during a call or conference for the given account. The list returned includes paging information.
The list of Recordings is protected by your account credentials like most parts of this API. You must use HTTP basic auth to access the Recordings list resource.
You can also get a list of Recordings from a specific call or conference by including the call or conference SID in your request like so:
GET https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Calls/{CallSid}/Recordings.json
GET https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Conferences/{ConferenceSid}/Recordings.json
パラメーター
Parameters in REST API format | |
---|---|
account_sid
Path
|
The SID of the Account that created the Recording resources to read. |
date_created
オプション
|
Only include recordings that were created on this date. Specify a date as |
call_sid
オプション
|
The Call SID of the resources to read. |
conference_sid
オプション
|
The Conference SID that identifies the conference associated with the recording to read. |
サンプル
Update a Recording resource
POST https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Calls/{CallSid}/Recordings/{Sid}.json
POST https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Conferences/{ConferenceSid}/Recordings/{Sid}.json
An active call or conference recording can be paused and resumed. Additionally, an active call recording can be stopped which will end the recording immediately. (stopped not supported for conference recordings)
パラメーター
Parameters in REST API format | |
---|---|
account_sid
Path
|
The SID of the Account that created the Recording resource to update. |
call_sid
Path
|
The Call SID of the resource to update. |
sid
Path
|
The Twilio-provided string that uniquely identifies the Recording resource to update. |
status
必須
|
The new status of the recording. Can be: |
pause_behavior
オプション
|
Whether to record during a pause. Can be: |
例:
Note in examples below that the API responses for updates to the recording resource will provide a more detailed inflight 'status' including paused, in-progress, or stopped but a fetch on the recording resource will only show processing or completed.
In the following two examples, note the use of Twilio.CURRENT
to reference the currently active recording without requiring an explicit Recording SID.
Twilio.CURRENT
can be used for pause, resume, or stop actions on calls with only one active recording.
Note that if your use case has multiple or concurrent recordings for a call or conference, you will need to use the Recording SID to reference the correct one. Using Twilio.CURRENT
to reference a recording on a resource that has multiple recordings will result in an error that the request failed because there is more than one recording for the given Call.
Delete a Recording resource
DELETE https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Recordings/{Sid}.json
Deletes a recording from your account. Once the recording is deleted:
- You will no longer be billed for storage of those minutes
- The recording is set to a status of
deleted
- The metadata is preserved for a period of 40 days, during which time the metadata is still visible in the Console.
If successful, DELETE
returns HTTP 204 (No Content) with no body.
Please note that only completed
recordings can be deleted. Recordings with any other status are not available for deletion.
Parameters in REST API format | |
---|---|
account_sid
Path
|
The SID of the Account that created the Recording resources to delete. |
sid
Path
|
The Twilio-provided string that uniquely identifies the Recording resource to delete. |
To to delete a large set of Voice Recordings, you can use the bulk deletion capabilities available in the Twilio Console.
例:
ヘルプが必要ですか?
誰しもが一度は考える「コーディングって難しい」。そんな時は、お問い合わせフォームから質問してください。 または、Stack Overflow でTwilioタグのついた情報から欲しいものを探してみましょう。