Skip to main content
WSS
bearerAuth
type:http

Telnyx API v2 Bearer token authentication.

query
type:object

Query parameters passed when opening the WebSocket connection.

Audio Frame
type:string

Client-to-server binary frame with raw audio in the format and sample_rate set on the connection, channels interleaved. No container and no WAV header. The frame must contain a whole number of samples for all channels (for example, a multiple of 4 bytes for two-channel l16) and must not exceed 65,536 bytes. 20 ms chunks are a good default.

End of Stream
type:object

Client-to-server text frame. Send it when you have no more audio. The server reads the rest of the audio, sends the summary message, then closes with code 1000. If you close the connection without it, you get no summary. Any other text frame gets an unsupported_message error frame and the session continues.

Detection
type:object

Server-to-client text frame, sent once for each channel whose watermark reads, as soon as it reads. After it, that channel is no longer read; the rest of its audio is only counted. You can end the stream as soon as you have the answer you need.

Summary
type:object

Server-to-client text frame, sent once after end_of_stream or at a session limit. data is the same object that POST /v2/audio_watermark_detections returns, with audio.format set to the stream's format.

Error Frame
type:object

Server-to-client text frame. If the error ends the session, the server closes the connection right after this frame, with the close code listed below and the error code as the close reason.

  • invalid_params (close 1008): a query parameter is missing or has an unsupported value.
  • max_session_duration (close 1008): the session reached 590 seconds or 60 minutes of audio. The summary message is sent first.
  • internal_error (close 1011): detection failed. Reconnect and try again.
  • overloaded (close 1013): the service has too many open sessions. Try again later.
  • chunk_too_large (session continues): the binary frame is larger than 65,536 bytes. The frame is dropped.
  • decode_error (session continues): the frame length is not a whole number of samples. The frame is dropped.
  • unsupported_message (session continues): the text frame is not {"type": "end_of_stream"}.