Skip to content
DhvaneeDocs
Dashboard
On this page

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.

The machine-readable contract is openapi.public.yaml. Download it for clients and codegen. This site has no live Try-it console.
Each call is one turn of a new chat. There is no endpoint to send a follow-up message, answer the copilot's questions, read a chat again, or apply a proposed draft. Continue and apply the chat in the dashboard. A turn uses an AI model, so it uses your plan's copilot credits, and the call waits for the answer. Use a generous timeout.

Scope

  • copilot:use for POST /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.

FieldTypeNotes
textstringRequired. 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_idstring (UUID)Optional. An existing voice agent of this workspace: the chat is about that agent's call flow.
domainstringOptional. 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.
areastringOptional 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"}'
The dashboard also lets a chat start from an open automation, selected steps, attached files or attached calls. Those fields (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.

FieldTypeNotes
idstring (UUID)The chat.
titlestringThe start of your message, up to 80 characters.
statusstringactive, opened or archived.
domainstring or nullWhat the chat is about once the copilot knows: automation or agent. null while it does not know yet.
subjectobject or nullnull through this API.
applied_revision_seqinteger or nullSet after a draft is applied in the dashboard.
workflow_idstring or nullThe automation opened from this chat in the dashboard. null here.
created_at, updated_atstring or nullISO 8601.
messagesarrayYour message first, then the copilot's reply (usually one message). See below.
Message fieldNotes
seqPosition in the chat, from 1.
roleuser or assistant.
kindWhat the message is. Yours is request. See the table below for the copilot's.
contentAn object that depends on kind. Yours is {"text": "..."}.
created_atISO 8601.
usagenull 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 replyWhat it means
questionsThe copilot needs a few answers first. content.questions lists them with their options. Answer them in the dashboard.
draftA proposed automation or agent flow, ready to review in the dashboard. Nothing is applied or published by the API.
briefA short summary of what it understood, before building.
general, needs_detailA plain answer or a request for more detail, in content.message.
out_of_scopeThe 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.
errorThe copilot could not finish the turn. content has a code and a message. Try again with a clearer request.
A chat that designs an agent can create a new, blank agent in your workspace to hold the design (the reply names it). The agent is not published and takes no calls. A chat about an automation creates nothing in your workspace: the proposal stays in the chat.

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

StatusWhen`detail`
401No key, or an unknown or revoked keyValid API key is required, API key is invalid or revoked
402Copilot credits used up, or an empty walletAn object with the code copilot_credits_exhausted or wallet_empty
403The key lacks the scope, or is a publishable keyAPI key needs copilot:use scope, Publishable API keys cannot use this scope
404agent_id is not an agent of this workspaceAgent not found
409agent_id or domain: agent while building agents is switched offBuilding agents is not available right now.
422A body that is not validA 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.
429Too many requestsAn object with the code rate_limit_key, rate_limit_workspace, rate_limit_client or rate_limit_auth_fail, and a Retry-After header
503The AI model could not be reached or is not set upThe 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.