Skip to main content
Data messages are used to communicate non-audio information during Ultravox calls. These messages enable real-time control and interaction with ongoing conversations.

Communication Methods

  • Client Data Channels → Used by our SDKs and WebSocket connections for bi-directional, real-time message exchange during calls. This is the primary method for client apps to interact with calls.
  • Data Connection → Add a data connection to your call to receive messages via a separate WebSocket connection. This is particularly useful for:
    • Telephony integrations where the client doesn’t support WebRTC
    • Server-side applications that need to monitor call events or route data to external systems
  • REST API → Inject messages into active calls via HTTP POST requests. See Sending Messages to Live Calls via REST API below for detailed implementation guidelines.

Messages at a Glance

Details on each message type appear below in Data Message Details.

Client-to-Server Messages

Server-to-Client Messages

Messages excluded by default are sent only to connections that ask for them:
  • Clients list the message types they want in additionalMessages when joining the call (experimentalMessages in older SDKs). The dataMessages on the call’s medium is applied afterward, so you can limit what clients you don’t fully trust receive: true always sends a message, false never does (even if the client asks for it), and leaving it unset lets the client choose, falling back to the default.
  • Data connections set dataMessages on the data connection.
Triggers can listen for any of these messages either way.

Data Message Details

All messages are JSON objects with camelCase keys containing:
  • A required type field identifying the message type
  • Additional fields specific to each message type

Ping

A message sent by the client to measure round-trip data message latency. Message Structure
Fields
float
required
Unix timestamp with millisecond precision. Client timestamp for latency measurement.

Pong

A message sent by the server in response to a PingMessage. The timestamp is copied from the PingMessage. Message Structure
Fields
float
required
Echoed timestamp from the original ping message.

State

A message sent by the server to indicate its current state. Message Structure
Fields
string
required
Current session state. One of: idle, listening, thinking, or speaking.

Transcript

A message containing text transcripts of user and agent utterances. Message Structure
Fields
string
required
Who emitted the utterance. Must be either “user” or “agent”.
string
default:"voice"
The medium through which the utterance was emitted. Either “text” or “voice”.
string
The full text of the transcript so far. Either this or delta will be set, but not both.
string
The additional transcript text added since the last transcript message. Either this or text will be set, but not both.
boolean
required
Whether to expect additional transcript messages for this conversation round.
integer
required
The ordinal of the message within the current call, used for ordering transcripts.

UserStartedSpeaking

Sent by the server when voice activity detection hears the user start speaking. Excluded by default. Message Structure

UserStoppedSpeaking

Sent by the server when voice activity detection decides the user has finished speaking. Excluded by default. Message Structure

UserTextMessage

A user message sent via text. The message appears to the agent as if it came from the user.
On a call whose mediumRestriction doesn’t allow text, user text messages from the client are ignored, except those sent to a side thread. Messages sent through a data connection or the REST API are still delivered.
Message Structure
Fields
string
required
The content of the user message.
string
default:"soon"
Determines whether this message can interrupt the agent and whether it should trigger a generation. Options:
  • immediate → Interrupts the agent if speaking and starts a new generation immediately.
  • soon → Doesn’t interrupt but starts a generation at the next opportunity.
  • later → Message is considered during the next natural generation without forcing a new generation.
string
default:"UI"
Optional thread ID to send this message to. Defaults to “UI” (the main conversation).

SetOutputMedium

Message sent by the client to set the server’s output medium. Message Structure
Fields
string
required
Output medium to use. Must be either “voice” or “text”.
On a call whose mediumRestriction doesn’t allow the requested medium, this message is ignored.

ClientToolInvocation and DataConnectionToolInvocation

Sent by the server to ask the client or data connection to invoke a tool with the given parameters. The client or data connection is expected to send back a ClientToolResultMessage or DataConnectionToolResultMessage with a matching invocationId. Message Structure
Fields
string
required
Name of the tool to invoke.
string
required
Unique identifier for this invocation. Must be included in the corresponding result.
object
required
Tool-specific parameters as a JSON object.

ClientToolResult and DataConnectionToolResult

Contains the result of a tool invocation. Message Structure
Fields
string
required
Must match the invocationId from the corresponding invocation.
string
Typically the tool execution result as viewed by the agent, which is often a JSON string. May be omitted for errors. For responseTypes other than tool-response, this may be a JSON string for an object that further specifies how the response should be handled. See special response types.
string
default:"tool-response"
Type of response being provided. See special response types.
string
default:"speaks"
How the agent should react. Options: “speaks” (default), “listens”, or “speaks-once”. See Agent Responses to Tools for more.
string
Error classification if the tool failed. Should be omitted when result is set.Options:
  • undefined → Tool with the given name does not exist
  • implementation-error → Tool exists but execution failed
string
Human-readable error description if the tool failed. This is not seen by the model but may be used for debugging.
object
Optional state updates to apply to the call. See Tool State for more.

InvokingTool

Sent by the server when a tool invocation starts. Excluded by default. Message Structure
Fields
string
required
Unique identifier for this invocation.
string
required
The name the agent used for the tool.
string
The callToolId of the tool, as returned by List Call Tools.
object
required
The parameters the agent passed to the tool.
boolean
required
Whether this is a speculative invocation of a precomputable tool, whose result may go unused.
string
required
The ID of the thread that invoked the tool.

ToolUsed

Sent by the server when a tool invocation finishes, with its result. Excluded by default. Message Structure
Fields
string
required
The name the agent used for the tool.
string
The callToolId of the tool, as returned by List Call Tools.
string
required
Matches the invocationId of the InvokingTool message.
object
required
The parameters the agent passed to the tool.
string
required
The tool’s result, as the agent sees it.
string
Details of the error, if the tool failed. The agent doesn’t see these.
string
required
How long the tool took, in seconds with an s suffix.
integer
required
The tool call’s position in the thread’s messages. For threads other than UI, it counts the thread’s own messages, which aren’t saved with the call’s.
string
required
The ID of the thread that invoked the tool.
object
The call’s new state, if the tool changed it.

Debug

A message sent by the server to communicate debug information. Disabled by default. Message Structure
Fields
string
required
Debug information or diagnostic details.
Debug messages are disabled by default and must be explicitly enabled for debugging purposes.

CallEvent

Sent by the server each time a call event is recorded. Excluded by default. Message Structure
Fields
object
required
The event, in the same form as List Call Events returns it.

CallStarted

Basic call metadata shared by the server when a call begins. Message Structure
Fields
string
required
The UUID of the call that has started.
string[]
required
The mediums the call allows for user input and agent output: “voice”, “text”, or both. See Text-Only and Voice-Only Calls.

PlaybackClearBuffer

Message sent by the server to clear buffered output audio. Integrators should drop as much unplayed output audio as possible for interruptions to function properly. Message Structure
This message is only used with WebSocket connections. Handling this message allows for larger client buffers while maintaining responsive interrupts. Larger client buffers make choppy audio less likely in the presence of network disruption or resource contention.

ForcedAgentMessage

Forces the agent to say a specific message or invoke tools. Message Structure
Fields
string
default:""
Text content the agent should speak.
array
Array of tool invocations to execute.
array
Array of known tool results. If specified, any toolCalls with matching invocationIds will use these results instead of executing the tool. See ClientToolResult for the structure of each result object.
boolean
If true, prevents interruption while the agent speaks this message. (Note that tools are always uninterruptible.)
string
default:"soon"
Controls when the message is processed. Must be either “immediate” (may interrupt the user or agent) or “soon” (process at next opportunity).
string
default:"UI"
Optional thread ID to send this message to. Defaults to “UI” (the main conversation).

HangUp

Instructs the agent to end the call with an optional farewell message. Message Structure
Fields
string
default:""
Final message to speak before ending the call.

Thread Messages

The following messages are used to manage Threads — parallel conversations that run alongside the main call. For conceptual background and usage examples, see the Threads guide.

SpawnThread

Spawns a new parallel thread that forks from the parent’s conversation history. See Threads for a full explanation. Message Structure
Fields
string
Unique identifier for the new thread. If omitted, an id will be auto-generated. Leading and trailing whitespace is trimmed, and the result may be at most 64 characters. UI and _PARENT are reserved.
string
default:"UI"
The thread to fork from. Defaults to “UI” (the main conversation). If the referenced thread has failed or doesn’t exist, this spawn attempt will be rejected.
string
default:"reject"
Controls behavior when newThreadId matches an existing thread. Options:
  • reject (default) → The spawn request is rejected and a ThreadRejected message is sent.
  • replace → The existing thread is terminated and a new thread is spawned with the same ID. Useful for re-syncing a thread with the current conversation state. The existing thread is terminated even if the new spawn is then rejected, and its ThreadTerminated is sent before the new thread’s ThreadSpawned.
array
Messages to append to the forked history before the thread starts generating. Each element must be either a UserTextMessage or ForcedAgentMessage. Every ForcedAgentMessage except the last must have known results for each tool call. The last may have unmatched calls, in which case the thread will begin by executing those.
object
Changes to the parent thread’s tools for the new thread. Same format as the toolOverrides in an update-tools tool response:
  • remove (string[]) → Names of the parent’s tools to remove. May not be set together with removeAll.
  • removeAll (boolean) → Removes all of the parent’s tools.
  • add (object[]) → Tools to add, in the same format as selectedTools when creating a call. Removals are applied first.
Invalid removals reject the spawn. If an added tool can’t be resolved, the thread terminates with the invalid_input cause. May not be set together with toolFilter. See Changing a Thread’s Tools.
object
deprecated
Deprecated: use toolOverrides instead. Restricts which tools the thread can use. Specify either allowedTools (allowlist) or disallowedTools (blocklist), or both. If both are provided, the allowlist is applied first and then the blocklist is applied to the remaining tools. If neither is specified (or this field is omitted), the thread will be allowed to use all tools. The thread’s model still sees the parent’s tool definitions, and calling a filtered tool gets the same error as calling a tool that doesn’t exist.
object
Resource constraints for the thread. Available fields:
  • threadOutputTokenLimit (integer) → Max total output tokens for the thread. At most 20,000.
  • threadFuzzyInputTokenLimit (integer) → Approximate total (uncached) input token limit. At most 100,000.
  • generationLimit (integer) → Max LLM generation rounds.
  • generationOutputTokenLimit (integer) → Max output tokens per generation. At most 4,000, and 2,048 if unset.
  • generationFuzzyInputTokenLimit (integer) → Approximate (uncached) input token limit per generation.
A limit above its maximum is lowered to the maximum, and a thread.limit_clamped call event is recorded.Limits are a useful way to constrain model usage (and thus costs) for a thread, but leaving threads unconstrained is also totally reasonable, especially when the context provided to them keeps them focused on a specific task.
object
String values of your choosing, echoed back as metadata on the thread and side generation messages about this thread, such as ThreadState. Useful for telling threads apart, for example in a trigger’s conditions.
string
The model the thread runs on, which must be one of the call’s additionalModels. If unset, the thread uses its parent’s model. See Choosing a Thread’s Model.
string
Replaces the parent’s system prompt. The thread then starts without its parent’s messages, so additionalMessages are its first. Text models only.
number
The thread’s sampling temperature, between 0 and 2. Text models only.
string
How much the model reasons before responding: low, medium, or high. Text models only.

ThreadSpawned

Sent by the server to confirm a thread was successfully created. Message Structure
Fields
string
required
The ID of the newly created thread.
object
The metadata the thread was spawned with.

ThreadRejected

Sent by the server when a thread spawn request cannot be fulfilled. Message Structure
Fields
string
required
The thread ID from the spawn request.
string
required
Why the thread could not be created.
object
The metadata from the spawn request.

ThreadTerminated

Sent by the server when a thread stops running. Message Structure
Fields
string
required
The ID of the terminated thread.
string
required
The ID of the thread it was spawned from.
string
required
Why the thread terminated:
  • limit → The thread would have exceeded one of its limits.
  • inference → The thread’s generation failed.
  • canceled → The thread was canceled, for example because the call’s stage changed or the thread was replaced by one with the same ID.
  • invalid_input → Input the thread was spawned with, such as an added tool in toolOverrides, turned out to be invalid once the thread resolved it.
  • internal → Something unexpected went wrong.
string
required
A human-readable description of why the thread was terminated.
object
The metadata the thread was spawned with.

ThreadState

Sent by the server when a spawned thread starts and each time its state changes. Excluded by default, but triggers can listen for it either way. Message Structure
Fields
string
required
The thread’s ID.
string
required
The ID of the thread it was spawned from.
string
required
The thread’s state:
  • initializing → The thread is setting up.
  • generating → The thread is running LLM inference.
  • calling_tool → The thread is executing tool calls.
  • idle → The thread has no work to do.
integer
required
How many times the thread has finished its work and gone idle, including this time. A thread that starts idle hasn’t finished any work yet.
string
When idle, the thread’s final agent message, if its history ends with one.
object
The metadata the thread was spawned with.

SideGenerationDelta

Streaming text delta from a (non-UI) thread’s LLM generation, similar to a transcript delta. Excluded by default. Message Structure
Fields
string
required
The ID of the thread producing this generation.
string
required
The incremental text produced since the last delta message.
object
The metadata the thread was spawned with.

SideGenerationCompleted

Sent when a (non-UI) thread’s generation round finishes successfully. Message Structure
Fields
string
required
The ID of the thread that completed generation.
string
required
The complete generated text for this generation round.
array
Any tool calls the LLM requested during this generation. The thread will execute these automatically.
object
The metadata the thread was spawned with.

Sending Messages to Live Calls via REST API

The Send Data Message to Call endpoint allows you to inject messages into active calls (calls that are joined and not yet ended).

Supported Message Types

Responses

Successful messages sent via the REST API will receive a 204 No Content response with an empty body. Potential error responses include:
  • 401 Unauthorized: Missing or invalid API key
  • 403 Forbidden: Insufficient authorization
  • 422 Unprocessable Entity: Call is not active (either not joined yet or already ended)