Skip to navigation

Formats

Conventions for values and responses across the API.
View as Markdown

Use these formats across the API.

Timestamps

Timestamps use UTC RFC 3339 / ISO 8601, with a Z suffix and a three-digit millisecond fraction:

2025-06-06T08:53:20.000Z

Phone numbers

Phone numbers use canonical international E.164 with a leading +, for example +972500000000.

WebSocket audio

WebSocket Sessions exchange raw mono audio in binary messages without a WAV header. The required media_format sets both directions from the Session’s perspective:

  • from_session: Session to your WebSocket server.
  • to_session: Your WebSocket server to Session.

Supported profiles:

EncodingSupported sample ratesSample representation
pcm_s16leMultiples of 8000 from 8000 through 192000Signed 16-bit little-endian; two bytes per sample
mulaw8000 onlyG.711 mu-law; one byte per sample

Select each direction independently. The platform converts Session audio to the from_session profile and to_session audio to the Session media rate. Message sizes may vary. PCM16 messages must contain complete 16-bit samples; each mu-law byte is one complete sample.

PCM16 messages can contain at most 64 KiB. A to_session mu-law message can contain at most 32 KiB, keeping its PCM16 expansion within that bound.

G.711 mu-law changes representation, not sample rate: mulaw uses exactly 8 kHz. pcm_s16le can use any supported multiple of 8 kHz.

The directions may differ. For example, your server can receive pcm_s16le at 16 kHz in from_session and send mulaw at 8 kHz in to_session. See Create a WebSocket Session for the schema.

Audio is raw. mulaw does not add Twilio Media Streams JSON envelopes, base64 payloads, or control messages.