Create Stream Token
The first step of a stream call: creates the call and returns the WebSocket url, a single-use token valid 60 seconds, and the audio format. Requires the pearls:stream scope.
Then open url?token=<token> within 60 seconds: Stream WebSocket describes the connection, the audio and the events.
Errors
A 400 lists its messages in errors.validation. Several callData problems are reported together.
Message in errors.validation | Cause |
|---|---|
Pearl not found | pearlId is not a valid id, none of your Pearls has it, or the Pearl was deleted. |
Stream calls are available for voice Pearls only. | Your Pearl is a text Pearl. |
The Pearl is not active. | Your Pearl is paused. Activate it with Set Activity State. |
endUserId must not exceed 200 characters. | endUserId is longer than 200 characters. |
audioFormat 'X' is not supported. Valid: ulaw_8000, pcm_24000, opus_8000, opus_24000. | audioFormat is not one of the four formats. |
callData key cannot be null or whitespace.callData key 'K' must not exceed 40 characters.callData key 'K' contains invalid characters. Only letters, digits, underscores (_) and hyphens (-) are allowed.callData value for key 'K' must not exceed 200 characters. | A callData entry is invalid. |
Missing pre-call variables: firstName, orderId. | Required callData entries are absent or blank. |
Call cannot be completed: The client has no remaining credits. Please recharge to continue. | The account has no credits left. |
Call cannot be completed: Account Suspended! Please contact support. | The account is suspended. |
The Pearl has no flow yet.Invalid Conversation Flow | Your Pearl has no usable flow. |
The Pearl has no inbound settings.The Pearl has no outbound settings. | Your Pearl’s direction settings are missing. |
No agent is available for this Pearl right now, try again later. | All your Pearl’s agents are busy, phone calls and stream calls together, or it has none. Retry later. |
Could not start the call. | An internal failure. The agent it reserved stays taken for about 90 seconds, so a retry may get No agent is available… until then. |
Malformed JSON or a field of the wrong type (a number as audioFormat, for example) get the standard 400, with the error under the field name.
Agents and cancelling
A successful create reserves one of your Pearl’s agents until the call ends. To cancel the call, before or during it, use Hang Up Call: a token that was never used is then refused, and its agent is freed. A token that is never used and never cancelled keeps the agent for about 90 seconds, and costs nothing.
A create refused with No agent is available… or Could not start the call. still appears in the call history, as a call that never started.
Authorizations
Specify the authorization token.
For more information, check out the Authorization Guide.
Path Parameters
Your Pearl's id. It must be an active voice Pearl. Find it on your Pearl's overview page, in the Settings popover.
Body
Represents the data required to create a stream token.
Your own id for the person on the call, such as a customer id, an e-mail or a phone number, up to 200 characters. A stream call has no phone number, so this takes its place: in the call history, in your Pearl's memory, and in the flow's Phone Number variable. Send the same value for the same person every time, and never one value for different people.
200The flow's pre-call variables, by variable name: the same dictionary as a phone call's callData.
Required entries: every variable used in the opening sentence, and every input of a pre-call API, present and not blank. Other variables are optional.
Keys are letters (any script), digits, _ and -, up to 40 characters. Values are strings, up to 200 characters.
The audio format of the call, the same in both directions. We recommend opus_24000: HD for far less bandwidth.
opus_24000: Opus at 24 kHz, HD.opus_8000: Opus at 8 kHz, phone quality.ulaw_8000: 8 kHz G.711 μ-law, phone quality.pcm_24000: 24 kHz 16-bit little-endian PCM, HD.
Case-insensitive. Absent, null or empty means ulaw_8000, and any other value is refused.
Response
The call was created: connect with the token before it expires.
Represents what your server needs to connect a stream call.
The WebSocket URL. Open it with the token: url?token=<token>. Always use the returned value rather than a fixed address.
The single-use token for the connection, starting with wst_. It is valid for 60 seconds and is consumed by the first successful connection. Treat it as a secret. From a server you can send it in the Authorization: Bearer header instead of the query.
When the token stops being accepted, in ISO 8601 UTC: creation plus 60 seconds.
The format of every audio frame, in both directions.

