Test Chat

Agents

Test Chat

Talks to your real agent through its website chat — the same prompt, model, knowledge, actions, limits and billing as the console's Playground — and answers with its reply and every tool it used. It runs as a sandbox: anything that would phone, message, email or send a code to a person, or change a calendar booking, is switched off and the agent says what it would have done instead; your own actions still run for real, and every request they make carries an X-Test-Chat: true header (and {{test.chat}} fills as true) so your endpoint can answer without writing anything. The conversation appears in your inbox; send session back to continue it. It always runs the agent as saved: there is no separate draft, so a change you save is live at once. To try a change first, create a second agent with it (Create Agent) and test that one. A reply costs what a chat reply costs: on an agent using its own language-model key, the flat own-key reply price. A build key may do this.

POST/agents/{id}/test-chat

Path parameters

idstringrequired
The agent's id (ag_…), as List Agents returns it. Another workspace's agent is the same 404 as one that never existed.

Headers

Katexs-Workspacestring
Developers only: the customer workspace this request acts in — its org_… id from POST /customers. Leave it out to act in your own workspace. Refused with 404 (Workspace not found.) when the id is unknown, is not one of your customers, or is not an org_… id; 410 when that customer was deleted (restore it with POST /customers/{id}/restore until it is erased); 403 when the key belongs to one customer workspace (it cannot act as another); 400 when your workspace is not a developer workspace. /customers/* and GET /customers/usage are your own workspace's and refuse the header with 400: call them without it.

Request body

messagestringrequired
What the customer says. Trimmed; up to 4,000 characters.
sessionstring
The session a previous test chat answered with, to continue that conversation. Leave it out to start a new one.
modestring
chat talks to the agent as a website visitor. call runs the turn with the agent's call prompt: its call rules (or the built-in ones), the speaking rules, the model its calls use (the Voice page's, or your own key's) and, on your own Gemini key, the thinking level a call uses, with no cards or buttons. It shows the words a caller will be given, not the audio, and not the call's own tools (transferring, hanging up). Needs calling set up on the agent (409 otherwise). One of: chat, call. Default: chat.

Example request

bash
curl -X POST "https://app.katexs.com/api/v1/agents/{id}/test-chat" \
  -H "Authorization: Bearer $KATEXS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "message": "Is a 2 BHK at Sky Towers under 90 lakh?",
  "session": "vr_4f1c09e2b7a84d55a1e0c3b2d9f86a71"
}'

Responses

StatusDescription
200The agent's reply and the tools it used.
400message is missing or too long, or session is not one a test chat handed out.
401The key is missing, wrong or revoked. The answer is always the same, whichever it is.
403The key's access level (read-only or build) does not allow this request, the plan does not include it, or a customer's key named another workspace in Katexs-Workspace. code says which: key_scope_read, key_scope_build, workspace_header_forbidden, or forbidden.
404No such agent in your workspace.
409The agent has no website chat, or its website chat is switched off, or mode is call and the agent has no calling set up.
410The customer named in Katexs-Workspace was deleted. POST /customers/{id}/restore brings it back until its erase date.
429Messages sent faster than a person types, or over the per-minute API limit. Wait and retry.
503Test chats cannot run on this deployment.

Response fields

sessionstringrequired
Send this back as session to continue the conversation.
modestringrequired
The mode the turn ran in. One of: chat, call.
replystringrequired
What the agent said.
toolsobject[]required
Every tool it used, in order.
errorstring
Present when the reply failed part-way; reply holds what came before.
200 response
{
  "session": "vr_4f1c09e2b7a84d55a1e0c3b2d9f86a71",
  "mode": "chat",
  "reply": "Yes — a 2 BHK at Sky Towers starts at 82 lakh. Would you like to visit the site this weekend?",
  "tools": [
    {
      "name": "search_knowledge",
      "input": {
        "query": "2 BHK price Sky Towers"
      },
      "output": "A 2BHK starts at 82 lakh. A 3BHK starts at 1.1 crore."
    }
  ]
}

Last updated November 2026 · Found a problem? Email support@katexs.com