Skip to main content

Response envelope

JSON endpoints return a consistent envelope with a boolean error flag. On success, error is false and the payload is in data:
On failure, error is true, data is omitted, message carries the detail, code is machine-readable, and request_id identifies the request:

Request IDs

Every response carries an X-Request-Id header, and every JSON error body repeats it as request_id. Log it with each failure and include it when you contact support: it is how we find your request. To correlate with your own logs, send your id in X-Request-Id (or X-Client-Request-Id). Any value of 1-128 characters from A-Z a-z 0-9 - _ . : is echoed back as X-Request-Id; otherwise the service generates one (req_ followed by 24 hex characters). WebSocket handshake responses carry X-Request-Id too.

Error codes

Errors add a machine-readable code next to message. Branch on code, never on the message text:
Errors from the synthesis service are never passed through: they are mapped to the codes above, and their messages are ours.
The audio endpoints don’t use this envelope on success: /speak returns raw audio bytes and /stream returns a Server-Sent Events body. Errors on those endpoints still return the JSON envelope above.

Plan-limit & entitlement denials

Most billing-related denials do not use the standard envelope - they return a flat JSON body. The one exception is the credit check that runs inside synthesis, covered below. Per-resource plan limits (for example creating more voices than your plan allows) return 403:
When metered-usage enforcement is active, an exhausted allowance returns 402, and a feature your plan doesn’t include returns 403. Both carry the unit and the current usage:
The error string is the denial reason: quota_exhausted or insufficient_credits (402), or feature_disabled (403). A 402 can also come from the credit check inside synthesis (/speak and /stream), after the plan check has passed. That one uses the standard envelope, with message set to insufficient_credits:
Handle both shapes when you check for a 402.

Status codes

Enroll and clone are asynchronous: once the 202 is returned, engine-side failures (such as a reference clip that’s too short) don’t come back as 422 or 502. The job is marked failed instead - read its error field with Get job.

Common messages

The voice you referenced isn’t ready to use - only voices with status ready can synthesize. See Working with voices.
The text field exceeds the 10,000-character limit. Split long input into multiple requests.
rate_limited and concurrency_limited come from your plan’s limits, not from a fault. Wait the Retry-After seconds before retrying, and use the RateLimit header to slow down before you hit the limit. See Rate limits.
upstream_error (502) means the synthesis service failed or is warming up; retry with backoff. upstream_busy (503) means it is at capacity; wait Retry-After seconds first. A 422 invalid_input is about your input and is not worth retrying unchanged.
Once the socket is open, errors arrive as error frames ({type, context_id?, code, message, fatal}) rather than HTTP statuses. invalid_message means a frame you sent was not a JSON text frame of a known type and was dropped; voice_not_allowed means your access token is restricted to other voices (only that task_start is rejected); upstream_unavailable means the synthesis engine could not be reached and the socket closes with 1013 - reconnect with backoff. A refused handshake (for example 429 concurrency_limited) returns the JSON error body above before the upgrade. See Realtime (WebSocket).