API

Chat API.

Send a visitor message to a team and get back the agent that answered, the reply, and its citations. This is the same engine the widget runs on.

POSThttps://desk.whizztech.ai/v1/chat

Authenticate with a wz_live_ key — see Authentication. If you specify no team, the request uses your organization's published team.

Request parameters#

FieldTypeDescription
visitorIdstringrequiredStable identifier for the end user. Keys cross-conversation memory, so reuse it for a returning visitor.
messagestringrequiredThe visitor's message to answer.
teamIdstringoptionalTarget a specific team. Omit to use the organization's published team.
widgetKeystringoptionalPublic wd_pub_ key identifying a published team. Alternative to teamId.
conversationIdstringoptionalContinue an existing conversation. Omit to start a new one; the response returns the new id.

Request#

curl
curl https://desk.whizztech.ai/v1/chat \
  -H "Authorization: Bearer wz_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "visitorId": "v_9f2a",
    "message": "Do you offer refunds after 30 days?",
    "conversationId": "conv_7c41"
  }'

Response#

FieldTypeDescription
conversation_idstringId for this conversation. Pass it back as conversationId to continue the thread.
agentstringName of the agent the Router picked to answer.
replystringThe answer to return to the visitor.
citationsarraySources the reply is grounded in — title and reference per item. Empty when no knowledge was used.
200 OK
{
  "conversation_id": "conv_7c41",
  "agent": "Support",
  "reply": "Refunds are available within 30 days of purchase. After that, store credit applies — I can start either for you.",
  "citations": [
    {
      "title": "Returns & Refunds Policy",
      "source": "https://acme.com/policies/refunds"
    }
  ]
}

Credits and rate limits#

Each answered message costs 1 credit. Requests are rate limited per API key. When your organization is out of credits, the API returns 402 and does not answer.

Errors#

Errors use one envelope across the API: { "error": { "code", "message" } }.

StatusCodeWhen
400invalid_requestA required parameter is missing or malformed.
401invalid_api_keyMissing or invalid API key.
402insufficient_creditsrequiredThe organization is out of credits. Top up or upgrade to resume answering.
404team_not_foundThe teamId or widgetKey does not resolve to a published team.
429rate_limitedToo many requests for this key. Retry after backing off.
402 Payment Required
{
  "error": {
    "code": "insufficient_credits",
    "message": "Out of credits. Top up or upgrade to keep answering."
  }
}