Developer platform · v2

API reference

View as MarkdownAll docs

Chat API

8 operations · all resources

What this covers#

Typed chats with an agent, from your web chat or your own app. Start a conversation, then send each message and get the agent's reply in the response. The agent answers with the same job, knowledge and actions as on a call. Each reply costs ₹0.05 or $0.0005 from the wallet; messages from people are free.

Every example below runs as written once these are exported:

bash
export DVAARIK_API_KEY="dvk_..."        # project API key, server side only
export DVAARIK_TOKEN="<account access token>"   # console session, from POST /console/auth/login
export CHAT_ID="<uuid>"
export PROJECT_ID="<uuid>"

A <value> inside a JSON body is a value you supply. Responses are JSON; every error body is { "detail": … }. Each schema is expanded once per page, where it first appears.

Machine door errors#

Raised by the project-key dependency before any handler on this page runs.

StatusCause
401Missing API key or Invalid API key — the X-Api-Key header is absent, unknown, or revoked.
403API key is not scoped to a project, Project unavailable, or API key is missing the required scope '<scope>'.
429The project's api_rpm ceiling was exceeded. Honour Retry-After; X-RateLimit-* headers are on every response.

Scopes used on this page: voice:read, voice:write. Mint a key with only these.

Account door errors#

StatusCause
401No account session was presented, or it is invalid or expired. Refresh once, then re-authenticate.
403The account is suspended or its email is not verified.

Operations — project API key#

Call these from your own server with a project key. Never from a browser or a mobile bundle.

GET /v2/chats#

List conversations, the most recent message first, filtered by agent or channel.

DetailValue
DoorProject API key — X-Api-Key: $DVAARIK_API_KEY
Scopevoice:read
OperationlistChats
Success200 ChatPage
ParameterInTypeRequiredNotes
agent_idqueryuuid or nullno
channel_idqueryuuid or nullno
limitqueryintegerno
offsetqueryintegerno

ChatPage#

FieldTypeRequiredNotes
dataChatInfo[]yes
next_offsetinteger or nullno

ChatInfo#

FieldTypeRequiredNotes
agent_iduuid or nullyes
channel"api" or "telegram" or "whatsapp" or "instagram"yes
channel_iduuid or nullyes
created_atdate-timeyes
expires_atdate-timeyes
external_idstring or nullyes
external_namestring or nullyes
iduuidyes
last_message_atdate-timeyes
metadataobjectyes
retention_daysintegeryes
variablesobjectyes

FieldErrors#

A 422 from a route that names its fields: every field that failed validation, or one sentence when the request validated and was then refused.

FieldTypeRequiredNotes
detailstring or FieldError[]yesThe fields that failed validation (each named), or a sentence for the developer.
ErrorWhen
401No API key was sent in X-Api-Key, or it is invalid or revoked.
403The API key lacks the scope this route needs, or its account or project is unavailable.
422The request body or query is not valid. detail is an array of {loc, msg, type} and loc names the offending field.
429The project's requests-per-minute limit is reached; Retry-After says when to try again.

Plus the machine-door errors above. Full list on the errors page.

bash
curl -sS -X GET "https://api.developers.dvaarik.com/v2/chats?limit=20" \
  -H "X-Api-Key: $DVAARIK_API_KEY"

POST /v2/chats#

Start a conversation with an agent. Give variables for the agent's job and your own external_id for the person; nothing is charged until a reply is written.

DetailValue
DoorProject API key — X-Api-Key: $DVAARIK_API_KEY
Scopevoice:write
OperationstartChat
Success201 ChatInfo

Request body: ChatCreate.

ChatCreate#

Start a conversation with an agent (the chat API: your web chat, your own app).

FieldTypeRequiredNotes
agent_iduuidyes
external_idstring or nullno
metadataobjectno
variablesobjectno
ErrorWhen
401No API key was sent in X-Api-Key, or it is invalid or revoked.
403The API key lacks the scope this route needs, or its account or project is unavailable.
404The addressed resource does not exist in this key's project. One in another project is deliberately indistinguishable from one that never existed.
422The request body or query is not valid. detail is an array of {loc, msg, type} and loc names the offending field.
429The project's requests-per-minute limit is reached; Retry-After says when to try again.

Plus the machine-door errors above. Full list on the errors page.

bash
curl -sS -X POST "https://api.developers.dvaarik.com/v2/chats" \
  -H "X-Api-Key: $DVAARIK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "agent_id": "<agent uuid>",
    "external_id": "customer-4821",
    "variables": {
      "company": "Northline Dental"
    }
  }'

GET /v2/chats/{chat_id}#

Read a conversation with its newest messages, oldest first: each reply's status, cost, tokens and actions. Send before (from next_before) to read further back.

DetailValue
DoorProject API key — X-Api-Key: $DVAARIK_API_KEY
Scopevoice:read
OperationgetChat
Success200 ChatDetail
ParameterInTypeRequiredNotes
chat_idpathuuidyes
limitqueryintegerno
beforequerydate-time or nullno

ChatDetail#

FieldTypeRequiredNotes
agent_iduuid or nullyes
channel"api" or "telegram" or "whatsapp" or "instagram"yes
channel_iduuid or nullyes
created_atdate-timeyes
expires_atdate-timeyes
external_idstring or nullyes
external_namestring or nullyes
iduuidyes
last_message_atdate-timeyes
messagesChatMessageInfo[]yes
metadataobjectyes
next_beforedate-time or nullno
retention_daysintegeryes
variablesobjectyes

ChatMessageInfo#

FieldTypeRequiredNotes
agent_versioninteger or nullno
attachmentsstring[]no
conversation_iduuidyes
cost_minorstringnodefault "0"
created_atdate-timeyes
currencystring or nullno
delivery_status"sent" or "delivered" or "read" or "failed" or nullno
errorstring or nullno
error_codestring or nullno
iduuidyes
input_tokensintegernodefault 0
modelstring or nullno
money_scaleinteger or nullno
output_tokensintegernodefault 0
partsinteger or nullno
price_minorstring or nullno
price_versionstring or nullno
providerstring or nullno
role"user" or "agent"yes
sent_atdate-time or nullno
status"received" or "pending" or "ready" or "sending" or "sent" or "failed" or "ambiguous"yes
textstringyesmax length 8000
tool_callsChatToolCall[]no
ErrorWhen
401No API key was sent in X-Api-Key, or it is invalid or revoked.
403The API key lacks the scope this route needs, or its account or project is unavailable.
404The addressed resource does not exist in this key's project. One in another project is deliberately indistinguishable from one that never existed.
422The request body or query is not valid. detail is an array of {loc, msg, type} and loc names the offending field.
429The project's requests-per-minute limit is reached; Retry-After says when to try again.

Plus the machine-door errors above. Full list on the errors page.

bash
curl -sS -X GET "https://api.developers.dvaarik.com/v2/chats/$CHAT_ID?limit=20" \
  -H "X-Api-Key: $DVAARIK_API_KEY"

POST /v2/chats/{chat_id}/messages#

Send the person's message and get the agent's reply in the response. Send an Idempotency-Key; the same key again returns the first reply with duplicate: true and is never charged twice.

DetailValue
DoorProject API key — X-Api-Key: $DVAARIK_API_KEY
Scopevoice:write
OperationsendChatMessage
Success201 ChatExchange
ParameterInTypeRequiredNotes
chat_idpathuuidyes
Idempotency-Keyheaderstring or nullno

Request body: ChatMessageCreate.

ChatMessageCreate#

One message from the person, as text.

FieldTypeRequiredNotes
textstringyesmin length 1; max length 4096

ChatExchange#

The person's message and the agent's reply to it. A reply that could not be written is failed, says why in error, and is charged nothing.

FieldTypeRequiredNotes
duplicatebooleannodefault false
messageChatMessageInfoyes
replyChatMessageInfoyes
ErrorWhen
401No API key was sent in X-Api-Key, or it is invalid or revoked.
402The wallet cannot pay for one AI reply; top it up.
403The API key lacks the scope this route needs, or its account or project is unavailable.
404The addressed resource does not exist in this key's project. One in another project is deliberately indistinguishable from one that never existed.
409A limit or the resource's state refuses this change; the sentence says which.
422The request body or query is not valid. detail is an array of {loc, msg, type} and loc names the offending field.
429The project's request limit or one of the chat reply limits is reached (per conversation an hour, per minute, per day); Retry-After says when to try again.
503A bounded worker this request needs is busy; Retry-After says when to try again.

Plus the machine-door errors above. Full list on the errors page.

bash
curl -sS -X POST "https://api.developers.dvaarik.com/v2/chats/$CHAT_ID/messages" \
  -H "X-Api-Key: $DVAARIK_API_KEY" \
  -H "Idempotency-Key: <unique per call attempt>" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Do you open on Sunday?"
  }'

Operations — account session#

The same resource through the console door. These are what the web console calls; both doors return the same shapes.

GET /console/v2/projects/{project_id}/chats#

List conversations, the most recent message first, filtered by agent or channel.

DetailValue
DoorAccount session — Authorization: Bearer $DVAARIK_TOKEN
OperationconsoleListChats
Success200 ChatPage
ParameterInTypeRequiredNotes
project_idpathuuidyes
agent_idqueryuuid or nullno
channel_idqueryuuid or nullno
limitqueryintegerno
offsetqueryintegerno
ErrorWhen
401No account session was presented, or it is invalid or expired.
403The account is suspended or its email is not verified.
404The project or the addressed resource does not exist for this owner. A resource owned by another developer is deliberately indistinguishable from one that never existed.
422The request body or query is not valid. detail is an array of {loc, msg, type} and loc names the offending field.

Plus the account-door errors above. Full list on the errors page.

bash
curl -sS -X GET "https://api.developers.dvaarik.com/console/v2/projects/$PROJECT_ID/chats?limit=20" \
  -H "Authorization: Bearer $DVAARIK_TOKEN"

POST /console/v2/projects/{project_id}/chats#

Start a conversation with an agent. Give variables for the agent's job and your own external_id for the person; nothing is charged until a reply is written.

DetailValue
DoorAccount session — Authorization: Bearer $DVAARIK_TOKEN
OperationconsoleStartChat
Success201 ChatInfo
ParameterInTypeRequiredNotes
project_idpathuuidyes

Request body: ChatCreate.

ErrorWhen
401No account session was presented, or it is invalid or expired.
403The account is suspended or its email is not verified.
404The project or the addressed resource does not exist for this owner. A resource owned by another developer is deliberately indistinguishable from one that never existed.
409The project or resource is in a state that refuses this change.
422The request body or query is not valid. detail is an array of {loc, msg, type} and loc names the offending field.

Plus the account-door errors above. Full list on the errors page.

bash
curl -sS -X POST "https://api.developers.dvaarik.com/console/v2/projects/$PROJECT_ID/chats" \
  -H "Authorization: Bearer $DVAARIK_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "agent_id": "<agent uuid>",
    "external_id": "customer-4821",
    "variables": {
      "company": "Northline Dental"
    }
  }'

GET /console/v2/projects/{project_id}/chats/{chat_id}#

Read a conversation with its newest messages, oldest first: each reply's status, cost, tokens and actions. Send before (from next_before) to read further back.

DetailValue
DoorAccount session — Authorization: Bearer $DVAARIK_TOKEN
OperationconsoleGetChat
Success200 ChatDetail
ParameterInTypeRequiredNotes
chat_idpathuuidyes
project_idpathuuidyes
limitqueryintegerno
beforequerydate-time or nullno
ErrorWhen
401No account session was presented, or it is invalid or expired.
403The account is suspended or its email is not verified.
404The project or the addressed resource does not exist for this owner. A resource owned by another developer is deliberately indistinguishable from one that never existed.
422The request body or query is not valid. detail is an array of {loc, msg, type} and loc names the offending field.

Plus the account-door errors above. Full list on the errors page.

bash
curl -sS -X GET "https://api.developers.dvaarik.com/console/v2/projects/$PROJECT_ID/chats/$CHAT_ID?limit=20" \
  -H "Authorization: Bearer $DVAARIK_TOKEN"

POST /console/v2/projects/{project_id}/chats/{chat_id}/messages#

Send the person's message and get the agent's reply in the response. Send an Idempotency-Key; the same key again returns the first reply with duplicate: true and is never charged twice.

DetailValue
DoorAccount session — Authorization: Bearer $DVAARIK_TOKEN
OperationconsoleSendChatMessage
Success201 ChatExchange
ParameterInTypeRequiredNotes
chat_idpathuuidyes
project_idpathuuidyes
Idempotency-Keyheaderstring or nullno

Request body: ChatMessageCreate.

ErrorWhen
401No account session was presented, or it is invalid or expired.
402The wallet cannot pay for one AI reply; top it up.
403The account is suspended or its email is not verified.
404The project or the addressed resource does not exist for this owner. A resource owned by another developer is deliberately indistinguishable from one that never existed.
409The project or resource is in a state that refuses this change.
422The request body or query is not valid. detail is an array of {loc, msg, type} and loc names the offending field.
429The project's request limit or one of the chat reply limits is reached (per conversation an hour, per minute, per day); Retry-After says when to try again.
503This server is already writing its share of chat replies; Retry-After (2 s) says when to try again.

Plus the account-door errors above. Full list on the errors page.

bash
curl -sS -X POST "https://api.developers.dvaarik.com/console/v2/projects/$PROJECT_ID/chats/$CHAT_ID/messages" \
  -H "Authorization: Bearer $DVAARIK_TOKEN" \
  -H "Idempotency-Key: <unique per call attempt>" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Do you open on Sunday?"
  }'

Try it without a key in the browser

The playground opens a real voice session with your account session, so a project key never reaches a browser. Machine calls belong on your own server.