Skip to main content
Working code for the agent lifecycle. For prompt design, tool configuration, and template variables, see Configuring voice agents.

Placeholders

Every snippet below uses these placeholders. Replace them before running the code.

Create an agent

New agents use the shared organisation tool library. Create and publish tools separately, then add their pinned versions through tool_refs; see Tools.

Test with a web session

Web sessions let you talk to your agent from a browser. No phone number or SIP trunk required. The response includes LiveKit credentials you can use with any LiveKit client SDK.
Both fields are optional. arguments overrides template_defaults on the agent, and participant_name sets a display name in the LiveKit room. max_session_seconds is set by the server — it is not configurable per request — and is enforced for web sessions only; phone calls are not subject to it.

Update an agent

PATCH updates only the fields you send. Use PUT if you want to replace the entire configuration. Shared tool and MCP attachments need the complete agent document. Download it with GET /v1/agents/{agent_id}/config, edit tool_refs or mcp_refs, then send it with PUT. PATCH does not update attachments.

Duplicate an agent

Use duplication when you want to copy an existing agent configuration as-is, including prompts, models, tools, template defaults, and selected region. The request contract:
  • name is required. The Dashboard pre-fills <Name> Copy, but the API expects an explicit name.
  • The inbound connection is never inherited. Pass target_sip_inbound_trunk_id to attach one to the copy — this is only accepted when the source agent has inbound telephony, and the trunk must differ from the source agent’s inbound trunk.
  • The outbound connection is inherited within your organisation unless you override it with target_sip_outbound_trunk_id (only accepted when the source agent has outbound telephony).
The duplicate does not copy call history. After duplicating an agent:
  • Reconnect inbound routing if the duplicate should receive calls.
  • Verify the outbound trunk before dispatching calls.
  • Test the duplicate with a web session or a test call.

Version history and restore

Every save — create, update, restore, import — appends an immutable version to the agent’s history. Versions can’t be edited or deleted; the only mutable part is an optional label. Restoring is a two-step preview-then-accept flow, so you can review exactly which fields will change before anything is applied.

Browse the history

cURL
Each item records what changed and where it came from:

Preview a restore

cURL
The preview compares version 4 against the current configuration and returns the diff plus the hashes that authorize the accept step (preparation.config and candidate — the full config document that would be applied — are trimmed here for brevity):
While the platform is still preparing the restore candidate, the preview returns 202 with "state": "preparing" and a Retry-After header — retry the preview until state is ready. The version’s name is not restored by default; pass {"restore_historical_name": true} in the preview body to include it (and pass the same value again on accept — the acceptance hash binds the name policy).

Accept the restore

Send back the hashes from the preview:
cURL
acceptance_hash comes from the top level of the preview; candidate_hash, resource_hash, and dependency_hash come from its preparation object. If the agent changed between preview and accept, the accept fails with a conflict — run the preview again. On success the response is the restored agent, and the X-Agent-Version-Created header reports whether a new version was appended (false means the restore was a no-op because nothing differed).

Label a version

Labels are the only mutable part of a version. Set one to mark a known-good configuration, or send null to clear it:
cURL

Export and import agent configs

GET /v1/agents/{agent_id}/config downloads the agent’s canonical config document — a portable JSON file with everything needed to recreate the agent. Secrets are never included. To download a historical snapshot instead, use GET /v1/agents/{agent_id}/versions/{n}/config from the section above.
cURL
POST /v1/agents/import creates a new agent from such a document — a download followed by an import round-trips exactly. Pass the optional sip_outbound_trunk_id query parameter to attach an outbound trunk to the imported agent.
cURL

List and inspect agents

Delete an agent

Returns 204 No Content on success.