WebSocket messages

API → Application

These messages are sent from the API to your application, the WebSocket server.

Message Description Example
hello The WebSocket session has started.
{
  "t": "hello",
  "callid": "cA2c...",
  "from": "+46701234567",
  "to": "+46766861234"
}
audio Base64 encoded audio data, see Audio Formats.
{
  "t": "audio",
  "data": "<base64>"
}
sync Sent in response to a sync request from the application. All audio sent before the request has been played.
{
  "t": "sync"
}
bye The call has ended. reason can be either done, hangup, or error.
{
  "t": "bye",
  "reason": "done",
  "message": "Call finished"
}

Application → API

These messages are sent to the API from your application.

Message Description Example
sending Let the API know that we will be sending data in the given format.
{
  "t": "sending",
  "format": "pcm_24000"
}
listening Let the API know that we want to receive audio in the given format.
{
  "t": "listening",
  "format": "pcm_24000"
}
audio Base64 encoded audio data, see Audio Formats.
{
  "t": "audio",
  "data": "<base64>"
}
interrupt Immediately clear the audio buffer and ignore all subsequent audio messages until a new sending is sent.
{
  "t": "interrupt"
}
sync Request a checkpoint from the API. The API will reply once all previously sent audio has been played.
{
  "t": "sync"
}
bye End the call.
{
  "t": "bye"
}