Skip to navigation

Start audio playback

View as Markdown

Rate limit: Per command · Burst: 8 · Refill: 4 req/s

Play WAV or MP3 files, live AAC/HLS streams, raw live audio, or indefinite silence.

Playback modes:

  • Use type: files for one or more WAV or MP3 files.
  • Use type: silence for indefinite silence.
  • Use type: stream with one HTTP/HTTPS AAC or HLS live stream url; optionally set format to aac or hls, or omit it for auto-detection. Explicit ports must be 80 or 443. Playback starts at the current live position and does not support pause, resume, or seek.
  • Use type: push with a raw mono media_format. The 202 response includes an ingest object with the short-lived URL, HTTP method, required headers, and expiry. Send one streaming POST exactly as described, add the normal Bearer authorization header in addition to ingest.headers, write unframed raw audio in the request body, and close the body at end of input. A successful ingest response means the complete body was accepted, not that the caller has heard all audio.

File playlists play in URL order. Session playback does not loop. To start partway through one file, set offset_ms; an offset is not valid for a playlist.

A new play request automatically replaces active playback. Call playback/stop to stop audio without starting another source. For a DTMF menu, receive the usual Session DTMF event and call playback/stop before preparing the selected source when you need the current audio to stop first.

A 202 response confirms durable asynchronous admission. It does not confirm that previous playback has stopped or that new playback has started.

After admission:

  • For files, the platform prepares source 0 first and can begin caller playback without waiting for the complete playlist. It then keeps up to five following sources ready ahead of the source being consumed, preparing another source as playback advances.
  • For live streams, source fetching and decoding begin after the 202; fetch, format, or decode failures emit playback.failed with reason media_unavailable.
  • The platform emits playback.started when it estimates that playback began.
  • Any platform, source, or preparation failure after admission emits one operation-level playback.failed. Because later sources are prepared asynchronously, this event can occur before or after playback.started.
  • An explicit stop or replacement before playback starts emits playback.stopped, which may precede any playback.started.

Triggered webhooks: playback.started, playback.stopped, and playback.failed.

See Playback lifecycle events for complete payload schemas and examples.

Match the operation_uuid in every playback webhook to the value returned by the 202 response.

Play one WAV or MP3 file, or a playlist:

{
"type": "files",
"urls": [
"https://media.example.com/greeting.mp3",
"https://media.example.com/menu.wav"
]
}

The platform plays the URLs in order. Use offset_ms only with one file. For private files, use presigned HTTPS URLs that remain valid through playback. Seek within playback is available only for files.

Play a live audio stream, such as a radio station:

{
"type": "stream",
"url": "https://media.example.com/live"
}

The platform starts playback at the stream’s current position. Live streams do not support seek.

To push generated audio such as TTS, use:

Start a pushed raw-audio stream:

{
"type": "push",
"media_format": {
"encoding": "pcm_s16le",
"sample_rate": 24000
}
}

The 202 Accepted response includes a short-lived ingest object. Send the application’s normal Bearer authorization together with every header in ingest.headers, then stream the TTS bytes to ingest.url in one request and close the body when the TTS stream ends:

POST {ingest.url}
Authorization: Bearer <app_uuid>:<api_key>
Content-Type: application/octet-stream
<raw audio bytes>

The audio must be unframed signed 16-bit little-endian PCM. For example, an OpenAI TTS response with response_format: pcm can be streamed directly as the request body.

The audio must match media_format: signed little-endian PCM16 at 8, 16, 24, or 48 kHz; or G.711 mu-law at 8 kHz.

Keep Session Playback active without an audio source:

{
"type": "silence"
}

Silence continues until another playback replaces it, the session ends, or you stop playback.

An accepted request returns 202 Accepted with operation_uuid and status: in_progress. New playback replaces active playback automatically. See Playback lifecycle events for completion and failure webhooks.

Authentication

AuthorizationBearer

Send Authorization: Bearer <app_uuid>:<api_key> using an active API key. See Authentication for details.

Path parameters

uuidstringRequired

Session identifier.

Headers

Idempotency-KeystringOptionalformat: "^[a-zA-Z0-9._-]*$"<=128 characters

Optional key for safely retrying mutating requests. An explicitly empty header is treated like omission and does not enable replay protection. See Idempotency for details.

Operation-IdstringOptionalformat: "uuid"

optional client-supplied lowercase RFC-4122 v4 UUID returned as operation_uuid; platform generates one when omitted; correlation metadata distinct from Idempotency-Key.

Request

This endpoint expects an object.
SessionPlaybackFilesRequestobjectRequired
Play one or more WAV or MP3 files in order.
OR
SessionPlaybackPushRequestobjectRequired
Play raw mono audio uploaded live through the returned HTTPS target.
OR
SessionPlaybackStreamRequestobjectRequired

Play one HTTP/HTTPS AAC or HLS live audio source from its current live position. Omit format to auto-detect; explicit ports must be 80 or 443.

OR
SessionPlaybackSilenceRequestobjectRequired
Play indefinite silence until playback is replaced or stopped.

Response headers

traceparentstringOptionalformat: "^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$"=55 characters

Server-owned W3C Trace Context for correlating this response with support and observability data. It is present on successful and error responses. A valid incoming traceparent is linked to, but never becomes, the server-owned trace identifier.

Response

Playback accepted.
operation_uuidstring
statusenum
Allowed values:
ingestobjectOptional

Present only for type: push. Send one streaming HTTP request exactly as described by this object, plus the normal application Bearer authorization header.

Errors

400
Bad Request Error
401
Unauthorized Error
404
Not Found Error
406
Not Acceptable Error
409
Conflict Error
413
Content Too Large Error
415
Unsupported Media Type Error
422
Unprocessable Entity Error
429
Too Many Requests Error
500
Internal Server Error
502
Bad Gateway Error
503
Service Unavailable Error