Copilot API
Send a first message to the workspace copilot and get its reply: a question, a proposed automation or agent flow, or an answer.
The copilot is the assistant of the dashboard that helps you design automations and voice-agent call flows in plain words. This API sends the first message of a new chat and returns the chat with the copilot's reply. See Copilot for what it can do in the dashboard.
Scope
copilot:useforPOST /v1/copilot
The scope is not part of the read scopes, so a publishable key (dhvanee_pub_) cannot use it. Use a secret key. See Authentication.
Send the first message
Send a JSON body with text. Unknown keys are rejected.
| Field | Type | Notes |
|---|---|---|
text | string | Required. What you want to build or change. Spaces at both ends are trimmed. At least 2 characters. At most 2000 characters, or 20,000 when the chat is about an agent (agent_id or domain: agent), so a whole agent prompt can be pasted. |
agent_id | string (UUID) | Optional. An existing voice agent of this workspace: the chat is about that agent's call flow. |
domain | string | Optional. agent starts a chat that designs an agent flow without naming an agent yet. Leave it out to let the copilot decide. platform is accepted but platform questions are not answered through the API, so do not use it. |
area | string | Optional hint about what you are working on: automations, agents or other. It only helps the copilot choose. |
curl -sS -X POST "https://api.stage.dhvanee.com/v1/copilot" \
-H "Authorization: Bearer dhvanee_live_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"text":"When a form is submitted, add a row to my sheet and email me"}'To design a voice-agent flow, name the agent or ask for a new one:
curl -sS -X POST "https://api.stage.dhvanee.com/v1/copilot" \
-H "Authorization: Bearer dhvanee_live_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"text":"A friendly front desk agent that books appointments","domain":"agent"}'subject, snapshot, selection, attachment_ids, call_ids) are checked but are not used by this API, so the copilot does not see an existing automation through it. Describe the change in text instead.The response
Returns 201 with the new chat after the first turn.
| Field | Type | Notes |
|---|---|---|
id | string (UUID) | The chat. |
title | string | The start of your message, up to 80 characters. |
status | string | active, opened or archived. |
domain | string or null | What the chat is about once the copilot knows: automation or agent. null while it does not know yet. |
subject | object or null | null through this API. |
applied_revision_seq | integer or null | Set after a draft is applied in the dashboard. |
workflow_id | string or null | The automation opened from this chat in the dashboard. null here. |
created_at, updated_at | string or null | ISO 8601. |
messages | array | Your message first, then the copilot's reply (usually one message). See below. |
| Message field | Notes |
|---|---|
seq | Position in the chat, from 1. |
role | user or assistant. |
kind | What the message is. Yours is request. See the table below for the copilot's. |
content | An object that depends on kind. Yours is {"text": "..."}. |
created_at | ISO 8601. |
usage | null on your message. On the reply: calls, input_tokens, cached_input_tokens, output_tokens and credits (the copilot credits this turn used). |
{
"id": "5c0b7e3a-9d41-4b6e-8f10-3a7d2c9e1b44",
"title": "When a form is submitted, add a row to my sheet and email me",
"status": "active",
"domain": "automation",
"subject": null,
"applied_revision_seq": null,
"workflow_id": null,
"created_at": "2026-11-28T10:00:00+00:00",
"updated_at": "2026-11-28T10:00:04+00:00",
"messages": [
{"seq": 1, "role": "user", "kind": "request", "content": {"text": "When a form is submitted, add a row to my sheet and email me"}, "created_at": "2026-11-28T10:00:00+00:00", "usage": null},
{"seq": 2, "role": "assistant", "kind": "questions", "content": {"questions": [ ... ]}, "created_at": "2026-11-28T10:00:04+00:00", "usage": {"calls": 2, "input_tokens": 5120, "cached_input_tokens": 0, "output_tokens": 410, "credits": 1.2}}
]
}The shape above is an example: the reply, its kind and its usage depend on your message.
What the reply can be
| `kind` of the reply | What it means |
|---|---|
questions | The copilot needs a few answers first. content.questions lists them with their options. Answer them in the dashboard. |
draft | A proposed automation or agent flow, ready to review in the dashboard. Nothing is applied or published by the API. |
brief | A short summary of what it understood, before building. |
general, needs_detail | A plain answer or a request for more detail, in content.message. |
out_of_scope | The copilot only helps with building automations and agents, and a request outside that, or one it declines, gets this reply with content.message. It is still a 201. |
error | The copilot could not finish the turn. content has a code and a message. Try again with a clearer request. |
Credits
Every turn uses copilot credits, counted by what the model used. A plan includes a number of credits for each usage cycle, and some plans sell more from the wallet once those are used. Read copilot_credits from the Account API to see what is left. When the credits are used up the call returns 402 before anything is run, with {"detail": {"code": "copilot_credits_exhausted"}}, or the code wallet_empty when the plan sells extra credits and the wallet is empty. See Credits.
Errors
| Status | When | `detail` |
|---|---|---|
401 | No key, or an unknown or revoked key | Valid API key is required, API key is invalid or revoked |
402 | Copilot credits used up, or an empty wallet | An object with the code copilot_credits_exhausted or wallet_empty |
403 | The key lacks the scope, or is a publishable key | API key needs copilot:use scope, Publishable API keys cannot use this scope |
404 | agent_id is not an agent of this workspace | Agent not found |
409 | agent_id or domain: agent while building agents is switched off | Building agents is not available right now. |
422 | A body that is not valid | A list of field errors. The messages are Say what you would like to build or change. (text missing or shorter than 2 characters), Keep it to 2000 characters., Extra inputs are not permitted (an unknown key, for example message), A chat about an agent is not also about an automation workflow., A chat about an open workflow needs both the workflow and its current snapshot., Selected steps need the workflow or the agent they are on. |
429 | Too many requests | An object with the code rate_limit_key, rate_limit_workspace, rate_limit_client or rate_limit_auth_fail, and a Retry-After header |
503 | The AI model could not be reached or is not set up | The AI model could not be reached. Try again shortly. with code: assistant_unavailable next to detail, or an object with the code assistant_unavailable when the model is not set up |
curl -sS -X POST "https://api.stage.dhvanee.com/v1/copilot" \
-H "Authorization: Bearer dhvanee_live_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"message":"Summarise my open campaigns"}'{"detail": [{"type": "extra_forbidden", "loc": ["body", "message"], "msg": "Extra inputs are not permitted", "input": "Summarise my open campaigns"}]}The example above sends message instead of text, which is the most common mistake. For limits and keys see Authentication and Rate limits. To start from an automation you can run yourself, see the Automations API.