To get details of a call (including Status, Price, etc.), you will need to make a HTTP GET request to
https://<your_api_key>:<your_api_token><subdomain>/v1/Accounts/<your_sid>/Calls/<CallSid>
Where <CallSid>
is an alpha-numeric unique identifier generated for all the calls made via Exotel.
If you’d prefer response in JSON format, just append .json at the end of the HTTP GET request.
<your_api_key>
and <your_api_token>
with the API key and token created by you.<your_sid>
with your “Account sid”<subdomain>
with the region of your account<your_api_key>
, <your_api_token>
and <your_sid>
are available in the API settings page of your Exotel Dashboard
In the case of an outbound call originated via the API, the Sid parameter is as returned in the XML/JSON response to your request. In the case of inbound calls, you can get the Sid by using the Passthru applet.
curl https://<your_api_key>:<your_api_token><subdomain>/v1/Accounts/<your_sid>/Calls/b6cfaf5f5cef3ca0fc937749ef960e25
var request = require('request'); var options = { url: 'https://<your_api_key>:<your_api_token><subdomain>/v1/Accounts/<your_sid>/Calls/b6cfaf5f5cef3ca0fc937749ef960e25' }; function callback(error, response, body) { if (!error && response.statusCode == 200) { console.log(body); } } request(options, callback);
<?php include('vendor/rmccue/requests/library/Requests.php'); Requests::register_autoloader(); $headers = array(); $response = Requests::get('https://<your_api_key>:<your_api_token><subdomain>/v1/Accounts/<your_sid>/Calls/b6cfaf5f5cef3ca0fc937749ef960e25', $headers);
import requests requests.get('https://<your_api_key>:<your_api_token><subdomain>/v1/Accounts/<your_sid>/Calls/b6cfaf5f5cef3ca0fc937749ef960e25')
require 'net/http' require 'uri' uri = URI.parse("https://<your_api_key>:<your_api_token><subdomain>/v1/Accounts/<your_sid>/Calls/b6cfaf5f5cef3ca0fc937749ef960e25") response = Net::HTTP.get_response(uri) # response.code # response.body
HTTP Response:
{ "Call": { "Sid": "b6cfaf5f5cef3ca0fc937749ef960e25", "ParentCallSid": "", "DateCreated": "2016-11-29 15:58:45", "DateUpdated": "2016-11-29 16:00:09", "AccountSid": "Exotel", "To": "0XXXXX20000", "From": "0XXXXX30240", "PhoneNumberSid": "0XXXXXX4890", "Status": "completed", "StartTime": "2016-11-29 15:59:10", "EndTime": "2016-11-29 15:59:27", "Duration": "17", "Price": "1.500", "Direction": "outbound-api", "AnsweredBy": "human", "ForwardedFrom": "", "CallerName": "", "Uri": "/v1/Accounts/<your_sid>/Calls/b6cfaf5f5cef3ca0fc937749ef960e25", "RecordingUrl": "https://s3-ap-southeast-1.amazonaws.com/exotelrecordings/<your_sid>/b6cfaf5f5cef3ca0fc937749ef960e25.mp3" } }
<?xml version="1.0" encoding="UTF-8"?> <TwilioResponse> <Call> <Sid>b6cfaf5f5cef3ca0fc937749ef960e25</Sid> <ParentCallSid></ParentCallSid> <DateCreated>2017-02-17 14:16:03</DateCreated> <DateUpdated>2017-02-17 14:17:32</DateUpdated> <AccountSid>Exotel</AccountSid> <To>0XXXXX20000</To> <From>0XXXXX30240</From> <PhoneNumberSid>0XXXXXX4890</PhoneNumberSid> <Status>completed</Status> <StartTime>2017-02-17 14:16:03</StartTime> <EndTime>2017-02-17 14:16:20</EndTime> <Duration>17</Duration> <Price>0.750</Price> <Direction>inbound</Direction> <AnsweredBy>human</AnsweredBy> <ForwardedFrom></ForwardedFrom> <CallerName></CallerName> <Uri>/v1/Accounts/<your_sid>/Calls/b6cfaf5f5cef3ca0fc937749ef960e25</Uri> <RecordingUrl>https://s3-ap-southeast-1.amazonaws.com/exotelrecordings/<your_sid>/b6cfaf5f5cef3ca0fc937749ef960e25.mp3</RecordingUrl> </Call> </TwilioResponse>
Some of the parameters of a call (like Duration, Price, EndTime, etc.) are updated asynchronously after the call ends. So it might take some time after the call ends (~ 2 mins on an average) for these parameters to be populated correctly.
Description of parameters mentioned in the above response:
Parameter Name | Type & Value |
Sid | string; an alpha-numeric unique identifier of the call |
DateCreated | Date and time at which the user initiated the API |
DateUpdated | Date and time at which the status of the call was last updated in our system |
AccountSid | Your account SID |
To | Your customer's phone number |
From | The phone number that will be called first |
PhoneNumberSid | This is your ExoPhone/Exotel Virtual Number |
Status |
Overall call status, which could be one of:
|
StartTime | Time in format YYYY-MM-DD HH:mm:ss; Date and time when the call request was initiated to the operator |
EndTime | Time in format YYYY-MM-DD HH:mm:ss; Date and time when the call was completed |
Duration | Call duration in seconds |
Price | Double; If present, this will be the amount (in INR or USD) you have been charged for the call |
Direction |
|
AnsweredBy | human |
Uri | Uri is the path of the CallSid |
RecordingUrl | Link to the call recording |
If status of both the call legs are required incase of an outbound call, you will need to make an HTTP GET request to
https://<your_api_key>:<your_api_token><subdomain>/v1/Accounts/<your_sid>/Calls/<CallSid>?details=true
HTTP Response:
{ "Call": { "Sid": "b6cfaf5f5cef3ca0fc937749ef96d245", "ParentCallSid": "", "DateCreated": "2016-11-29 15:58:45", "DateUpdated": "2016-11-29 16:00:09", "AccountSid": "Exotel", "To": "0XXXXX30240", "From": "0XXXXX85175", "PhoneNumberSid": "0XXXXXX4890", "Status": "completed", "StartTime": "2016-11-29 15:59:10", "EndTime": "2016-11-29 15:59:27", "Duration": "17", "Price": "1.500", "Direction": "outbound-api", "AnsweredBy": "human", "ForwardedFrom": "", "CallerName": "", "Uri": "/v1/Accounts/Exotel/Calls/b6cfaf5f5cef3ca0fc937749ef96d245", "RecordingUrl": "https://s3-ap-southeast-1.amazonaws.com/exotelrecordings/Exotel/b6cfaf5f5cef3ca0fc937749ef96d245.mp3", "Details": { "ConversationDuration": 8, "Leg1Status": "completed", "Leg2Status": "completed" "Legs": [ { "Leg": { "Id": "1", "OnCallDuration": 21 } }, { "Leg": { "Id": "2", "OnCallDuration": 8 } } ] } } }
<?xml version="1.0" encoding="UTF-8"?> <TwilioResponse> <Call> <Sid>b6cfaf5f5cef3ca0fc937749ef96d245</Sid> <ParentCallSid></ParentCallSid> <DateCreated>2016-11-29 15:58:45</DateCreated> <DateUpdated>2016-11-29 16:00:09</DateUpdated> <AccountSid>Exotel</AccountSid> <To>0XXXXX30240</To> <From>0XXXXX85175</From> <PhoneNumberSid>0XXXXXX4890</PhoneNumberSid> <Status>completed</Status> <StartTime>2016-11-29 15:59:10</StartTime> <EndTime>2016-11-29 15:59:27</EndTime> <Duration>17</Duration> <Price>1.500</Price> <Direction>outbound-api</Direction> <AnsweredBy>human</AnsweredBy> <ForwardedFrom></ForwardedFrom> <CallerName></CallerName> <Uri>/v1/Accounts/Exotel/Calls/b6cfaf5f5cef3ca0fc937749ef96d245</Uri> <RecordingUrl>https://s3-ap-southeast-1.amazonaws.com/exotelrecordings/Exotel/b6cfaf5f5cef3ca0fc937749ef96d245.mp3</RecordingUrl> <Details> <ConversationDuration>8</ConversationDuration> <Leg1Status>completed</Leg1Status> <Leg2Status>completed</Leg2Status> <Legs> <Leg> <Id>1</Id> <OnCallDuration>21</OnCallDuration> </Leg> <Leg> <Id>2</Id> <OnCallDuration>8</OnCallDuration> </Leg> </Legs> </Details> </Call> </TwilioResponse>
Description of parameters mentioned in the above response:
Parameter Name | Value |
ConversationDuration | The duration for the From and To phone numbers on call in seconds |
Leg1Status |
Status of the first leg of the call. Can be one of
|
Leg2Status |
Status of the second leg of the call. Can be one of
|
Legs |
Status of individual legs of the call. Contains the following information (per leg):
|
The following diagram illustrates how the call duration is calculated for a call and its constituent legs.