Errors
Every status code the public API returns, the exact shapes of the detail field, and which failures are worth retrying.
A request that cannot be completed gets a non-2xx status and a JSON body with a single field, detail. Read the status first, then detail. detail comes in three shapes, depending on the kind of failure.
The three shapes of `detail`
| Shape | Used for | Example |
|---|---|---|
| A string | Most failures: missing key, missing scope, not found, conflicts and rejected input. | {"detail": "Contact not found"} |
An object with code | 402 (plan limits), 429 (rate limits) and server-side failures. Branch on code, not on the text. | {"detail": {"code": "rate_limit_key", "message": "Too many requests"}} |
| A list | 422 when the body, path or query does not match what the route expects. One entry per problem. | {"detail": [{"type": "missing", "loc": ["body", "from"], "msg": "Field required"}]} |
Each list entry names the problem with type, the place in the request with loc, and a readable msg. Entries can also carry the rejected value, so do not write raw error bodies to shared logs. Every response, success or failure, has an X-Request-Id header: quote it to support.
Example
curl -sS -X GET "https://api.stage.dhvanee.com/v1/contacts/00000000-0000-0000-0000-000000000000" \
-H "Authorization: Bearer dhvanee_live_YOUR_KEY"{"detail": "Contact not found"}Status codes
| Status | Meaning | What to do |
|---|---|---|
400 | The request is well formed but cannot be done as it stands, for example starting a campaign that has no recipients, publishing a flow agent whose canvas is invalid, a file the knowledge base rejects, or a malformed Idempotency-Key when starting an automation run. | Change the request. Do not retry it unchanged. |
401 | No key, an unusable key, or an unknown or revoked key. See Authentication. | Check the key. Do not retry in a loop: repeated attempts with a wrong key are throttled. |
402 | The plan has no allowance left for this action. detail.code says which. See Credits. | Raise the allowance or wait for the next cycle; retrying does not help. |
403 | The key is valid but not allowed: it lacks the scope, or a publishable key tried a write. | Use a key with the scope the message names. |
404 | Nothing with that id in this workspace. An id that belongs to another workspace also answers 404, so you cannot probe other workspaces. | Check the id. |
409 | A conflict with the current state, such as a phone number another contact already owns, or an Idempotency-Key reused with a different body. | Fix the cause. Do not retry unchanged. |
422 | Input that was understood but rejected: a missing or malformed field, a value out of range, or a rule such as an agent that is not published yet. | Change the request. |
428 | The Idempotency-Key header is missing on POST /v1/automations/{id}/runs. | Add the header and send again. |
429 | Too many requests. The Retry-After header says how many seconds to wait. See Rate limits. | Wait, then retry. |
5xx | Something failed on Dhvanee's side, including 503 when the rate-limit store is briefly unavailable. | Retry with a short, growing delay. For a call or run use the same Idempotency-Key. |
Messages you will see
These are the exact detail strings. Branch on the status code and, for objects, on code; treat the text as something to show or log.
| Status | `detail` | When |
|---|---|---|
401 | Valid API key is required | No key, wrong header form, or a value that is not a Dhvanee key. |
401 | API key is invalid or revoked | Unknown or revoked key, or a suspended workspace. |
403 | API key needs contacts:write scope | The key lacks that scope (the message names it). |
403 | Publishable API keys cannot use this scope | A publishable key on a write or copilot:use route. |
404 | Contact not found, Agent not found, Call not found, Campaign not found, Automation not found, Run not found, Document not found, Phone number not found | No such record in this workspace. |
404 | Not Found | The path does not exist. |
409 | A contact already owns that phone number | Creating or updating a contact to a phone number another contact has. |
409 | Idempotency-Key was already used with a different request | The same Idempotency-Key with a different body on a call, campaign start or automation create. |
409 | Idempotency-Key was already used with a different payload | The same key with a different payload when running an automation. |
409 | Only an active automation with a Manual trigger can be run on demand | Running an automation that is not active or has no Manual trigger. |
409 | Phone number already mapped to a workspace | Importing a number that is already in use. |
422 | Give a valid phone or email | Creating or updating a contact without a usable phone or email. |
422 | limit must be 1-200 and offset non-negative | A paging value out of range on contacts or calls. |
422 | Idempotency-Key is required | No Idempotency-Key on a call, campaign start or automation create. |
422 | Idempotency-Key must be 1-128 printable ASCII characters | A key that is empty, too long or has spaces or non-ASCII characters. |
422 | Publish the agent before placing a call | Calling with an agent that has never been published. |
422 | Use a phone number this workspace already owns | A from number that is not yours. |
422 | Give a valid phone number | A to number that cannot be read as a phone number. |
428 | Idempotency-Key is required | No Idempotency-Key when running an automation. |
429 | {"code": "rate_limit_key", "message": "Too many requests"} | Over a limit. code is rate_limit_key, rate_limit_workspace, rate_limit_client or rate_limit_auth_fail. |
Plan limits (402)
A 402 body is an object with only a code:
{"detail": {"code": "minutes_limit_reached"}}The codes are minutes_limit_reached, wallet_empty, concurrent_limit_reached, outbound_disabled, workspace_inactive, kb_storage_limit_reached, automation_executions_limit_reached and copilot_credits_exhausted. Each is explained on Credits.
Server-side failures
When something goes wrong on our side the real cause is never put in the response. You get the same calm object, with a code of busy (or timeout for a 504) and an action of retry:
{"detail": {"code": "busy", "message": "We're seeing a lot of activity right now. Please try again in a moment.", "action": {"type": "retry"}}}Retrying safely
- Retry only
429,503,504and other5xxanswers, and network timeouts. Wait forRetry-Afterwhen it is present, otherwise back off 1, 2, 4, 8 seconds with a little randomness. - Never retry unchanged a
400,401,402,403,404,409,422or428. The answer will be the same. - Use an `Idempotency-Key` wherever the API accepts one, so a retry after a timeout does not place a second call or start a second run. The same key and body within 24 hours returns the first response. For calls, campaign starts and automation creation, a request that failed is not remembered, so you can send it again with the same key.
- Creating a contact has no `Idempotency-Key`. Retrying a create that had a phone number answers
409instead of making a duplicate.