A callout is a call made to a phone number or app using the API.
Voice API | Sinch (1.0.1)
This document provides a detailed user guide and reference documentation on the Sinch Voice REST API. For information on how to authenticate API requests, please check the Authentication page.
Contact Sinch support here: Support@sinch.com
When using Sinch for voice calling, the Sinch dashboard works as a big telephony switch. The dashboard handles incoming phone calls (also known as incoming call “legs”), sets up outgoing phone calls (or outgoing call “legs”), and bridges the two. The incoming call leg may come in over a data connection (from a smartphone or web application using the Sinch SDKs) or through a local phone number (from the PSTN network). Similarly, the outgoing call leg can be over data (to another smartphone or web application using the Sinch SDKs) or the PSTN network.
For most calls, you can use the Sinch In-app Voice & Video SDKs on a smartphone or web client to establish calls without the need of additional integration. For more control or flexibility of the calls, you can use the Sinch REST APIs to manage the calls.
Controlling a call from your application is done by responding to callbacks from the Sinch platform and/or by calling REST APIs in the Sinch platform from your application. For more details on the callbacks triggered from the Sinch platform see the Callback API.
const fetch = require("node-fetch");
const resp = await fetch(`https://calling-use1.api.sinch.com/v1/callouts/`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization:
"Basic " + Buffer.from("<username>:<password>").toString("base64"),
},
body: JSON.stringify({
method: "ttsCallout",
ttsCallout: {
cli: "14155552223333",
destination: {
type: "number",
number: "+14045555000",
},
domain: "pstn",
custom: "customData",
locale: "en-US",
prompts: "This is a phone call from Sinch",
},
}),
});
const data = await resp.json();
console.log(data);
These are the typical call scenarios that you can control with the Sinch Callback and Calling APIs:
The Calling API uses a variety of endpoints depending on where in the world you are located.
When using API methods concerning individual calls, you can define what regional endpoint you want to use for the call. The following regional endpoints are available:
Endpoint | Description |
---|---|
https://calling.api.sinch.com/calling/v1 | Global - redirected by Sinch to the closest region |
https://calling-euc1.api.sinch.com/calling/v1 | Europe |
https://calling-use1.api.sinch.com/calling/v1 | North America |
https://calling-sae1.api.sinch.com/calling/v1 | South America |
https://calling-apse1.api.sinch.com/calling/v1 | South East Asia 1 |
https://calling-apse2.api.sinch.com/calling/v1 | South East Asia 2 |
For cases where the call is the result of an incoming PSTN, SIP or data call, the endpoint to use for managing that call is supplied in the ICE event. ICE callbacks will also provide region-specific URLs in the callResourceUrl
property.
When using API methods for configuring or managing applications, where region doesn't matter, use the following global endpoint:
Endpoint | Description |
---|---|
https://callingapi.sinch.com/calling/v1 | Global endpoint |
The API is developed using the following REST style operations:
[GET] - Fetch / Query
[POST] - Create / New / Start
[PUT] - 'Full' Update / Alter / Modify
[PATCH] - 'Partially' Update / Alter / Modify
[DELETE] - Remove / Stop / Cancel
The API uses the HTTP status code to indicate failure and the body contains more information.
[Error]
int - errorCode
string - message
Example
HTTP Status Code: 401 (Unauthorized)
{
"errorCode":40102,
"message":"Invalid Signature"
}
An error code contains five digits. The first three digits are the same as the HTTP Status Code.
[BadRequest - 400]
40001 - Parameter Validation
[Unauthorized - 401]
40100 - Authorization Header
40101 - Timestamp Header
40102 - Invalid Signature
[InternalServerError - 500]
50000 - Internal Server Error
[ServiceUnavailable - 503]
50300 - Temporary Down
To use callback events you need to assign a callback URL in the Sinch portal under your app settings.
Event | HTTP Verb | Functionality |
---|---|---|
ICE | POST | Incoming Call Event callback |
ACE | POST | Answered Call Event callback |
DiCE | POST | Disconnect Call Event callback |
PIE | POST | Prompt Input Event callback |
Notify | POST | Notify Event callback |
Voice numbers can call phone numbers on the fixed or mobile phone network. You can rent and configure voice numbers from the Sinch dashboard by following these steps:
- Rent a Voice number from the Sinch Dashboard, under the Numbers tab.
- Assign the number to your application. Under the Apps tab, select your app and assign the number under the app Voice settings.
- Configure a callback URL under your app's Voice settings, where Sinch will send call-related events.
When a user calls your configured voice number, the Sinch platform will trigger an Incoming Call Event callback towards your callback URL. The destination number - where the call will be connected to - has to be specified in your response to the Incoming Call Event callback. Similarly to app to phone calls, the Sinch platform will trigger additional events for call control.
For more information please check the Callback API. The callback events that are used in phone to phone calls are the Incoming Call Event callback, the Answer Call Event callback and the Disconnect Call Event callback.
With the text-to-speech REST API, you can trigger a call to be placed to a fixed or mobile phone number and play a synthesized text message.
For more information please check the Callouts operation.
Apps using the iOS, Android or Javascript SDK can call phone numbers on the fixed or mobile phone network. For additional call control, you can configure a callback URL under your app's voice settings in the Sinch dashboard, where Sinch will send call-related events. By capturing and responding to these events from your app, you can allow or deny calls to go through. Events will also be triggered when the calls are answered or disconnected.
For more information please check the Callback API. The callback events that are used in app to phone calls are the Incoming Call Event callback, the Answer Call Event callback, and the Disconnect Call Event callback.
Apps can call other apps using the iOS, Android or Javascript SDK. Both call legs are established over the data connection of the smartphone or computer (VoIP). For additional call control, you can specify a callback URL where Sinch will send call-related events. By capturing and responding to these events from your app you can allow, deny, and control the calls. You can configure the callback URL under your app's voice settings in the Sinch dashboard.
For more information please check the Callback API. The callback event that's used in app to app calls is the Incoming Call Event callback.
The Sinch dashboard supports a variety of different ways of initiating a conference call and connecting participants.
By using the Sinch Voice SDKs, you can allow your users to call in a conference from a mobile or web app. For more information please check the Voice SDKs documentation.
If you haven't specified a callback URL under your app settings for voice, the participants will be directly added to the conference that's uniquely identified by the conference ID specified in the SDK client method.
If you have specified a callback URL under your app settings for voice, an Incoming Call Event callback will be triggered towards your URL, containing information on the conference ID that the caller wants to connect to. By responding to this event you can allow or deny the connection to the conference, or even specify a different conference ID.
You can also allow users to dial in a conference by calling a fixed phone number. To do this, first follow the steps mentioned in Phone to phone calls to configure a number in your app and set a callback URL. Every time a user calls your configured number, an Incoming Call Event callback will be triggered towards your URL. By responding to this event with the ConnectConf
action, you can connect the call to a conference.
For more information check the Incoming Call Event callback and the ConnectConf action.
By using the conference callout endpoint, you can trigger calls to fixed or mobile phones and connect them all to the same conference room.
The Voice API allows you to control an ongoing conference. There are several conference-control options available, such as muting/unmuting participants or kicking out a participant or all participants from the conference when the conference ends.
The Voice API also allows recording of conference calls. For more information on how to record a conference, please check the ConnectConf
action in the SVAML Actions page.
Conference rooms have regional scope. If you want to connect multiple participants from different regions (Continents) on the same conference, you must “force” all members to be on the same region.
This can be done by selecting the same Sinch Voice API regional endpoints for Callout requests and/or the Sinch In-App regional endpoint/hostname to be used on your Mobile or Web Apps.
https://calling.api.sinch.com/
https://calling-use1.api.sinch.com/
https://calling-euc1.api.sinch.com/
https://calling-sae1.api.sinch.com/
https://calling-apse1.api.sinch.com/
https://calling-apse2.api.sinch.com/
Callbacks
Controlling a call from your application backend is done by responding to callbacks from the Sinch platform and/or by calling REST APIs in the Sinch platform from your application's backend.
Read more about how callbacks work here.
Request
When a call reaches the Sinch platform, the system makes a POST request to the specified calling callback URL.
This event, called the ICE event, can be triggered by either an incoming data call or an incoming PSTN call. Look here for allowed instructions and actions.
If there is no response to the callback within the timeout period, an error message is played, and the call is disconnected.
Must have the value ice
.
Enum Value | Description |
---|---|
ice | An Incoming Call Event is a type of event sent to your server when a phone number assigned to your Voice application receives an incoming call. |
ace | An Answered Call Event is a type of event sent to your server when an outgoing call made by your Voice application is answered. |
dice | A Disconnected Call Event is a type of event sent to your server when a call is disconnected. |
pie | A Prompt Input Event is a type of event sent to your server when a prompt input is submitted. |
notify | A Notification Event is a type of event sent to your server when a particular action occurs, such as a recording starting or finishing. |
Used in some types of events, it presents the unique Conference ID assigned to this call.
The unique application key. You can find it in the Sinch dashboard.
The number that will be displayed to the recipient of the call. To set your own CLI, you may use your verified number or your Dashboard virtual number and add it to the connectPSTN
SVAML response to the Incoming Call Event request. It must be in E.164 format.
Can be either pstn
for PSTN endpoint or mxp
for data (app or web) clients.
Enum Value | Description |
---|---|
pstn | A call on the Public Switched Telephone Network. |
mxp | A data call. |
PSTN | A call on the Public Switched Telephone Network. |
MXP | A data call. |
Can be either pstn
for PSTN endpoint or mxp
for data (app or web) clients.
Enum Value | Description |
---|---|
pstn | A call on the Public Switched Telephone Network. |
mxp | A data call. |
PSTN | A call on the Public Switched Telephone Network. |
MXP | A data call. |
If the call is initiated by a Sinch SDK client, call headers are the headers specified by the caller client. Read more about call headers here.
- redirected by Sinch to an appropriate region
https://calling.api.sinch.com/ice
- United States
https://calling-use1.api.sinch.com/ice
- Europe
https://calling-euc1.api.sinch.com/ice
- South America
https://calling-sae1.api.sinch.com/ice
- Southeast Asia 1
https://calling-apse1.api.sinch.com/ice
- Southeast Asia 2
https://calling-apse2.api.sinch.com/ice
An example of an Incoming Call Event.
{ "event": "ice", "callId": "3b0a7ccd-05e1-4728-bafd-023b77c47784", "callResourceUrl": "https://calling-euc1.api.sinch.com/calling/v1/calls/id/3b0a7ccd-05e1-4728-bafd-023b77c47784", "timestamp": "2022-03-21T13:13:59Z", "version": 1, "userRate": { "currencyId": "USD", "amount": 0.03 }, "cli": "31639136121", "to": { "type": "did", "endpoint": "+3197121281500" }, "domain": "pstn", "applicationKey": "3b216e8d-e385-4ff9-ae80-5d11897006b0", "originationType": "PSTN" }
A SVAML response to an Incoming Call Event that plays a message to the caller and then hangs up the call.
{ "instructions": [ { … } ], "action": { "name": "hangup" } }
Request
This callback is made when the call is picked up by the callee (person receiving the call). It's a POST request to the specified calling callback URL. Look here for allowed instructions and actions.
If there is no response to the callback within the timeout period, the call is connected.
If you have Answering Machine Detection (AMD) enabled, the amd
object will also be present on ACE callbacks.
Note: ACE Callbacks are not issued for InApp Calls (destination:
username
), only PSTN and SIP calls.
Must have the value ice
.
Enum Value | Description |
---|---|
ice | An Incoming Call Event is a type of event sent to your server when a phone number assigned to your Voice application receives an incoming call. |
ace | An Answered Call Event is a type of event sent to your server when an outgoing call made by your Voice application is answered. |
dice | A Disconnected Call Event is a type of event sent to your server when a call is disconnected. |
pie | A Prompt Input Event is a type of event sent to your server when a prompt input is submitted. |
notify | A Notification Event is a type of event sent to your server when a particular action occurs, such as a recording starting or finishing. |
Used in some types of events, it presents the unique Conference ID assigned to this call.
The unique application key. You can find it in the Sinch dashboard.
The number that will be displayed to the recipient of the call. To set your own CLI, you may use your verified number or your Dashboard virtual number and add it to the connectPSTN
SVAML response to the Incoming Call Event request. It must be in E.164 format.
Can be either pstn
for PSTN endpoint or mxp
for data (app or web) clients.
Enum Value | Description |
---|---|
pstn | A call on the Public Switched Telephone Network. |
mxp | A data call. |
PSTN | A call on the Public Switched Telephone Network. |
MXP | A data call. |
Can be either pstn
for PSTN endpoint or mxp
for data (app or web) clients.
Enum Value | Description |
---|---|
pstn | A call on the Public Switched Telephone Network. |
mxp | A data call. |
PSTN | A call on the Public Switched Telephone Network. |
MXP | A data call. |
If the call is initiated by a Sinch SDK client, call headers are the headers specified by the caller client. Read more about call headers here.
- redirected by Sinch to an appropriate region
https://calling.api.sinch.com/ace
- United States
https://calling-use1.api.sinch.com/ace
- Europe
https://calling-euc1.api.sinch.com/ace
- South America
https://calling-sae1.api.sinch.com/ace
- Southeast Asia 1
https://calling-apse1.api.sinch.com/ace
- Southeast Asia 2
https://calling-apse2.api.sinch.com/ace
{ "event": "iceRequest", "callid": "string", "conferenceId": "string", "version": 0, "timestamp": "2023-04-21T14:45:51Z", "custom": "string", "applicationKey": "string", "callResourceUrl": "string", "userRate": { "currencyId": "string", "amount": 0.1 }, "cli": "string", "to": { "type": "did", "endpoint": "+3197121281500" }, "domain": "pstn", "originationType": "pstn", "duration": 0, "rdnis": "string", "callHeaders": [ { … } ] }
A SVAML response to an Answered Call Event that plays a message to the callee and then hangs up the call.
{ "instructions": [ { … } ], "action": { "name": "hangup" } }
Request
This callback is made when the call is disconnected. It's a POST request to the specified calling callback URL. This event doesn't support instructions and only supports the hangup action.
Must have the value ice
.
Enum Value | Description |
---|---|
ice | An Incoming Call Event is a type of event sent to your server when a phone number assigned to your Voice application receives an incoming call. |
ace | An Answered Call Event is a type of event sent to your server when an outgoing call made by your Voice application is answered. |
dice | A Disconnected Call Event is a type of event sent to your server when a call is disconnected. |
pie | A Prompt Input Event is a type of event sent to your server when a prompt input is submitted. |
notify | A Notification Event is a type of event sent to your server when a particular action occurs, such as a recording starting or finishing. |
Used in some types of events, it presents the unique Conference ID assigned to this call.
The unique application key. You can find it in the Sinch dashboard.
The number that will be displayed to the recipient of the call. To set your own CLI, you may use your verified number or your Dashboard virtual number and add it to the connectPSTN
SVAML response to the Incoming Call Event request. It must be in E.164 format.
Can be either pstn
for PSTN endpoint or mxp
for data (app or web) clients.
Enum Value | Description |
---|---|
pstn | A call on the Public Switched Telephone Network. |
mxp | A data call. |
PSTN | A call on the Public Switched Telephone Network. |
MXP | A data call. |
Can be either pstn
for PSTN endpoint or mxp
for data (app or web) clients.
Enum Value | Description |
---|---|
pstn | A call on the Public Switched Telephone Network. |
mxp | A data call. |
PSTN | A call on the Public Switched Telephone Network. |
MXP | A data call. |
If the call is initiated by a Sinch SDK client, call headers are the headers specified by the caller client. Read more about call headers here.
- redirected by Sinch to an appropriate region
https://calling.api.sinch.com/dice
- United States
https://calling-use1.api.sinch.com/dice
- Europe
https://calling-euc1.api.sinch.com/dice
- South America
https://calling-sae1.api.sinch.com/dice
- Southeast Asia 1
https://calling-apse1.api.sinch.com/dice
- Southeast Asia 2
https://calling-apse2.api.sinch.com/dice
An example of a Disconnected Call Event.
{ "event": "dice", "callId": "3b0a7ccd-05e1-4728-bafd-023b77c47784", "timestamp": "2022-03-21T13:14:19Z", "reason": "GENERALERROR", "result": "FAILED", "version": 1, "debit": { "currencyId": "USD", "amount": 0 }, "userRate": { "currencyId": "USD", "amount": 0.368 }, "to": { "type": "did", "endpoint": "3197121281500" }, "applicationKey": "3b216e8d-e274-4ff9-ae80-5d11897006b0", "from": "31639136121" }
Request
This callback is triggered as a result of a runMenu action. It can be triggered from either a user pressing a number of DTMF digits, or by the return
command.
It's a POST request to the specified calling callback URL. Your application can respond with SVAML logic.
Note: PIE callbacks are not issued for DATA Calls, only PSTN and SIP calls.
Must have the value ice
.
Enum Value | Description |
---|---|
ice | An Incoming Call Event is a type of event sent to your server when a phone number assigned to your Voice application receives an incoming call. |
ace | An Answered Call Event is a type of event sent to your server when an outgoing call made by your Voice application is answered. |
dice | A Disconnected Call Event is a type of event sent to your server when a call is disconnected. |
pie | A Prompt Input Event is a type of event sent to your server when a prompt input is submitted. |
notify | A Notification Event is a type of event sent to your server when a particular action occurs, such as a recording starting or finishing. |
Used in some types of events, it presents the unique Conference ID assigned to this call.
The unique application key. You can find it in the Sinch dashboard.
The number that will be displayed to the recipient of the call. To set your own CLI, you may use your verified number or your Dashboard virtual number and add it to the connectPSTN
SVAML response to the Incoming Call Event request. It must be in E.164 format.
Can be either pstn
for PSTN endpoint or mxp
for data (app or web) clients.
Enum Value | Description |
---|---|
pstn | A call on the Public Switched Telephone Network. |
mxp | A data call. |
PSTN | A call on the Public Switched Telephone Network. |
MXP | A data call. |
Can be either pstn
for PSTN endpoint or mxp
for data (app or web) clients.
Enum Value | Description |
---|---|
pstn | A call on the Public Switched Telephone Network. |
mxp | A data call. |
PSTN | A call on the Public Switched Telephone Network. |
MXP | A data call. |
If the call is initiated by a Sinch SDK client, call headers are the headers specified by the caller client. Read more about call headers here.
- redirected by Sinch to an appropriate region
https://calling.api.sinch.com/pie
- United States
https://calling-use1.api.sinch.com/pie
- Europe
https://calling-euc1.api.sinch.com/pie
- South America
https://calling-sae1.api.sinch.com/pie
- Southeast Asia 1
https://calling-apse1.api.sinch.com/pie
- Southeast Asia 2
https://calling-apse2.api.sinch.com/pie
An example of a Prompt Input Event.
{ "event": "pie", "callId": "3b0a7ccd-05e1-4728-bafd-023b77c47784", "timestamp": "2022-03-21T13:14:19Z", "menuResult": { "menuId": "sub", "type": "sequence", "value": "3576", "inputMethod": "dtmf" }, "version": 1, "applicationKey": "3b216e8d-e274-4ff9-ae80-5d11897006b0" }
A SVAML response to an Prompt Input Event that plays a message to the callee and then hangs up the call.
{ "instructions": [ { … } ], "action": { "name": "hangup" } }
Must have the value ice
.
Enum Value | Description |
---|---|
ice | An Incoming Call Event is a type of event sent to your server when a phone number assigned to your Voice application receives an incoming call. |
ace | An Answered Call Event is a type of event sent to your server when an outgoing call made by your Voice application is answered. |
dice | A Disconnected Call Event is a type of event sent to your server when a call is disconnected. |
pie | A Prompt Input Event is a type of event sent to your server when a prompt input is submitted. |
notify | A Notification Event is a type of event sent to your server when a particular action occurs, such as a recording starting or finishing. |
Used in some types of events, it presents the unique Conference ID assigned to this call.
The unique application key. You can find it in the Sinch dashboard.
The number that will be displayed to the recipient of the call. To set your own CLI, you may use your verified number or your Dashboard virtual number and add it to the connectPSTN
SVAML response to the Incoming Call Event request. It must be in E.164 format.
Can be either pstn
for PSTN endpoint or mxp
for data (app or web) clients.
Enum Value | Description |
---|---|
pstn | A call on the Public Switched Telephone Network. |
mxp | A data call. |
PSTN | A call on the Public Switched Telephone Network. |
MXP | A data call. |
Can be either pstn
for PSTN endpoint or mxp
for data (app or web) clients.
Enum Value | Description |
---|---|
pstn | A call on the Public Switched Telephone Network. |
mxp | A data call. |
PSTN | A call on the Public Switched Telephone Network. |
MXP | A data call. |
If the call is initiated by a Sinch SDK client, call headers are the headers specified by the caller client. Read more about call headers here.
- redirected by Sinch to an appropriate region
https://calling.api.sinch.com/notify
- United States
https://calling-use1.api.sinch.com/notify
- Europe
https://calling-euc1.api.sinch.com/notify
- South America
https://calling-sae1.api.sinch.com/notify
- Southeast Asia 1
https://calling-apse1.api.sinch.com/notify
- Southeast Asia 2
https://calling-apse2.api.sinch.com/notify
An example of a Notify Event that a recording is finished.
{ "event": "notify", "callId": "da2d576b-d35a-476a-93cc-09e083fe8729", "version": 1, "type": "recording_finished" }