Sinch Voice API: Choosing between v1 and v2
For all new projects, please use Voice API v2. This is especially important for projects involving:
- AI capabilities like Streams and Voice Relay
- Voice campaigns like Batch calling
You should only use the older Voice API v1 if one of the following is a strict requirement:
- The project must be in General Availability (GA).
- The project requires In-App voice or Conferencing (until these features are available in v2).
This feature is in closed beta - Please, contact Sinch sales for more details.
Determines how to route a call to a Stream/websocket server.
Available to use in a response to an Incoming Call Event callback.
- Connect inbound calls via one of the standard voice channels (PSTN, SIP or IN-App) to the new Stream channel
- Reply ICE with connectStream() action.
- Connect outbound calls via one of the standard voice channels into a conference room, and add a stream channel into the same conference, to combine 2 or more outbound calls with a stream outbound call.
- Initiate a conferenceCallout to connect a standard voice channel (PSTN, SIP or In-App) into a conference room
- Initiate a customCallout to connect a stream outbound call leg.
ConnectStream Action example code
{
"action": {
"name": "connectStream",
"destination": {
"type": "Websocket",
"endpoint": "wss://yourcompany.com/websocket-server"
},
"streamingOptions": {
"version": 1,
"sampleRate": 44100
},
"maxDuration": 3000,
"callHeaders": [
{
"key": "foo",
"value": "bar"
},
{
"key": "baz",
"value": "qux"
}
]
}
}Schema
The name property. Must have the value connectStream.
| Value | Description |
|---|---|
| connectStream | The |
Specifies where to route the Stream call.
Optional parameters for the WebSocket stream.
The max duration of the call in seconds (max 14400 seconds). If the call is still connected at that time, it will be automatically disconnected.
These custom parameters (headers/messages) are sent to your WebSocket server in the initial message when the ConnectStream is established.
After the server response is received Sinch will start to send binary messages and expects to receive binary messages back, encoded with the same CODEC received.
The websocket connection request does not contain any headers. The client is expected to either accept the connection (200 OK) or decline (non-successful HTTP response). If declined, the call is hung up.
If the connection is accepted, the server immediately sends a connect command message, containing all the information.
The client is expected to send a command message back to indicate whether the call should be answered or hung up. If answered, the audio streams start.
This flow introduces an extra message with a payload that might be considered to be cleaner. Compared to the previous flow, the customer header names are preserved (not prepended with X-).
The websocket close message, sent from either side, indicates a hangup. This message can contain code and reason.
{
"command": "connect",
"CallId": "...",
"ApplicationId": "...",
"Headers": {
"Header1": "Value1",
"ApplicationId": "dsfkjhgdfkjghsdfkjg"
}
}{
"command": "answer"
}
-or-
{
"command": "busy"
}
-or-
{
"command": "reject"
}Info about Close message and how audio is streamed if the Close message is sent.



