Formats
Use these conventions whenever a request or response field uses one of these types.
Timestamps
Timestamps use RFC 3339 /
ISO 8601 in UTC, with a Z suffix and a
three-digit millisecond fraction:
Phone numbers
Phone numbers use canonical international E.164
format 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 object configures each
direction from the Session’s perspective:
from_sessiondescribes audio that the platform sends from the Session to your WebSocket server.to_sessiondescribes audio that your WebSocket server sends to the Session.
Each direction selects one supported encoding and sample-rate combination:
You select the profile for each direction independently. The platform converts
Session audio to the selected from_session format and converts audio received
in the selected to_session format to the Session media rate as needed. Binary
message sizes may vary. Each PCM16 message 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 so its PCM16 expansion remains within that bound.
G.711 mu-law companding changes the representation of an 8 kHz sample; it does not change the sample rate. A mu-law direction therefore uses exactly 8 kHz. A PCM16 direction can use any supported multiple of 8 kHz.
The two directions may use different profiles. 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 complete request schema.
The platform exchanges raw audio only. Selecting mulaw does not add Twilio
Media Streams JSON envelopes, base64 payloads, or control messages.