Skip to main content
Most teams build agents in Clarity’s editor. The API is for the parts you want to script: creating agents from a template, changing a greeting or prompt in many agents at once, publishing after your own review, or rolling back.

Drafts and published versions

An agent has numbered versions. Each version has a status:
1

Edit

PATCH an agent and your changes go to its draft. If there is no draft, Clarity creates one from the published version first. Live calls keep using the published version.
2

Publish

POST …/publish checks the draft against the full configuration rules. If it passes, the draft becomes the published version and the previous one becomes outdated.
3

Roll back if needed

POST …/versions/{versionId}/republish makes an outdated version live again.
Creating, editing, publishing, republishing and cloning agents need the publish permission, because they change what callers hear. Your organization API key has it.

Endpoints

All paths are under /v1/projects/{projectId}/agents. GET / leaves out Voice Assist agents. Add ?type=assist for only those, or ?type=all for every agent. Each listed agent shows its published configuration and carries published_version_id, published_version_number and has_draft.

Create an agent

The prompt, task_prompt_json, is a rich-text document: paragraphs of text nodes. A mention node inserts a variable, such as a campaign item’s custom_vars value.
The response is 201 with the new agent, including its id. The agent is published right away as version 1, so it can take calls once a number routes to it.
  • name is required and must be unique in the project. A taken name answers 400.
  • Fields you leave out get Clarity’s defaults. That includes the speech-recognition, language-model and voice settings in agent_model_config, which you can set later.
  • To see the full set of fields an agent’s configuration can carry, read GET /v1/agents/config-schema. It returns the JSON Schema every version is checked against when it is published.
The simplest way to get a complete, valid configuration is to build an agent in Clarity’s editor, then GET it and use the response as your template.

Edit and publish

1

Change the draft

Send only the fields you want to change:
The change is in the draft only. One exception: a new name applies to the agent at once.
2

Publish

Both versions are trimmed here. The response may also carry warnings, for example about a language model that could not be verified. A publish with warnings still succeeds.
To throw the draft away instead, POST /{id}/discard-draft. Reading the agent then returns the published version again.

Validation

Agents are checked twice:
  • When you save (POST, PATCH), the body is checked field by field. A bad body answers 422 with every problem in issues:
    Unknown fields are dropped without an error, so check the field names you send.
  • When you publish, the complete configuration is checked against the runtime schema. A version that does not pass answers 422 and stays a draft:
    message lists each problem with its path. details holds the same problems as objects.
Other publish and version errors:

Versions and rollback

Versions are newest first. Times are milliseconds since the Unix epoch. The list is a summary; GET /{id}/versions/{versionId} returns a version’s full configuration. To roll back, republish an outdated version:
The version is checked against today’s rules first, so a version that was valid when it was published can be refused with 422 if the rules have changed since. Every conversation records the version that handled it (agent_version_id), so you can compare calls before and after a change. See Conversations and recordings.

Clone

POST /{id}/clone copies the agent’s published version into a new agent named <name> (clone) (or (clone 2) and so on if that name is taken). The copy is published. An agent that was never published cannot be cloned (409).