Skip to main content

Connect Two Numbers

Make an outbound call that connects two phone numbers. The platform calls the From number first, and once they answer, the To number is dialed and connected.

HTTP Request​

POST /v1/Accounts/<your_sid>/Calls/connect

Regional Endpoints​

RegionURL
Singaporehttps://<api_key>:<api_token>@api.exotel.com/v1/Accounts/<your_sid>/Calls/connect
Mumbaihttps://<api_key>:<api_token>@api.in.exotel.com/v1/Accounts/<your_sid>/Calls/connect

Request Parameters​

ParameterRequiredTypeDescription
FromYesStringPhone number called first. Preferably in E.164 format.
ToYesStringCustomer phone number. Preferably in E.164 format.
CallerIdYesStringYour ExoPhone/virtual number.
CallTypeNoStringtrans for transactional calls.
TimeLimitNoIntegerMax call duration in seconds. Max: 14400 (4 hours).
TimeOutNoIntegerRing timeout in seconds.
WaitUrlNoStringAudio URL (WAV) played while waiting. Recommended: under 2MB.
RecordNoBooleantrue to record the conversation.
RecordingChannelsNoStringsingle (default) or dual.
RecordingFormatNoStringmp3 (default) or mp3-hq.
StreamUrlNoStringWebSocket URL for real-time audio streaming.
StreamBeginNoStringat Leg1Connect or at Leg2Connect.
CustomFieldNoStringMetadata (max 128 chars). Passed to StatusCallback and applets.
StartPlaybackToNewNoStringCallee (default) or Both.
StartPlaybackValueNewNoStringAudio URL for pre-call playback.
StatusCallbackNoStringWebhook URL for call status updates.
StatusCallbackEventsNoArrayterminal, answered, or both.
StatusCallbackContentTypeNoStringmultipart/form-data or application/json.

Code Examples​

curl -X POST 'https://<your_api_key>:<your_api_token>@api.exotel.com/v1/Accounts/<your_sid>/Calls/connect' \
-d 'From=+91XXXXXXXXXX' \
-d 'To=+91XXXXXXXXXX' \
-d 'CallerId=XXXXXXXXXX' \
-d 'Record=true' \
-d 'StatusCallback=https://yoururl.com/callback'

Response​

{
"Call": {
"Sid": "c5797dcbaaeed7678c4062a4a3ed2f8a",
"ParentCallSid": null,
"DateCreated": "2017-03-03 10:48:33",
"DateUpdated": "2017-03-03 10:48:33",
"AccountSid": "Exotel",
"To": "0XXXXX38847",
"From": "0XXXXX30240",
"PhoneNumberSid": "0XXXXXX4890",
"Status": "in-progress",
"StartTime": "2017-03-03 10:48:33",
"EndTime": null,
"Duration": null,
"Price": null,
"Direction": "outbound-api",
"AnsweredBy": null,
"ForwardedFrom": null,
"CallerName": null,
"Uri": "/v1/Accounts/Exotel/Calls.json/c5797dcbaaeed7678c4062a4a3ed2f8a",
"RecordingUrl": null
}
}

Response Fields​

FieldTypeDescription
SidStringUnique alpha-numeric call identifier
DateCreatedDateTimeWhen the API request was initiated
DateUpdatedDateTimeLast status update timestamp
AccountSidStringYour Exotel Account SID
ToStringThe destination phone number
FromStringThe number called first
PhoneNumberSidStringThe ExoPhone used
StatusStringqueued, in-progress, completed, failed, busy, no-answer
StartTimeDateTimeWhen call was sent to operator
EndTimeDateTimeWhen call ended
DurationIntegerTotal duration in seconds
PriceDoubleAmount charged (INR/USD)
DirectionStringinbound, outbound-dial, outbound-api
RecordingUrlStringRecording URL (if enabled)

Call Status Values​

StatusDescription
queuedWaiting to be sent to operator
in-progressCall is active
completedEnded normally
failedCould not be completed
busyBusy signal received
no-answerNot answered within timeout
note

Duration, Price, and EndTime update asynchronously (~2 minutes after call ends). Use StatusCallback or Call Details API for final values.

info

Audio file URLs for WaitUrl are cached. Use unique URLs (e.g., add a query parameter) when updating audio files.

Error Responses​

When a request fails, the API returns an error JSON:

400 — Missing required parameter:

{
"RestException": {
"Status": 400,
"Message": "The 'From' parameter is required."
}
}

401 — Authentication failed:

{
"RestException": {
"Status": 401,
"Message": "Authentication failed. Verify your API key and token."
}
}

429 — Rate limit exceeded:

{
"RestException": {
"Status": 429,
"Message": "Rate limit exceeded. Max 200 requests per minute."
}
}

For a complete list of error codes, see the Error Code Dictionary.

Try It​