Skip to main content
Docs menu

API reference

Chat agents

Read and change a chat agent's hours, handoff, quick replies, resolution and booking settings, and test its next reply without sending anything.

Beta. These endpoints are switched on per organization. While they are off for yours, each one answers 404 not_found. Ask Finn support to turn them on.

Overview

A chat agent answers your customers on the website widget, WhatsApp and other chat channels. These endpoints read and change its settings (Setup > Agents in Finn) and let you try it before customers see a change.

The agent's instructions and first message belong to its Finn agent: change them with PATCH /finns/{finn_id}/draft (finn:write). For conversations, messages and chat contacts, see the Chat operations.

Base URL: https://api.hirefinn.ai/api/v1. See authentication and scopes.

Credential

Org API keys and member tokens (a personal MCP key or an AI app's OAuth access token) both work. The Chat API must be on for your organization (403 chat_api_not_enabled otherwise).

Endpoints

MethodPathScopeWhat it does
GET/chat/agents/{agent_id}chat:readGet a chat agent's settings.
PATCH/chat/agents/{agent_id}chat:writeChange a chat agent's settings.
POST/chat/agents/{agent_id}/test_turnchat:writeTest a chat agent.

GET /chat/agents/{agent_id} answers three things: overrides (the agent's own settings), effective (what the agent uses: the workspace's Setup with the overrides on top, with timezone resolved) and the settings version.

Changing settings

PATCH /chat/agents/{agent_id} takes any of hours, handoff, quick_replies, resolution and booking. A setting you send replaces the agent's own. null drops it, so the agent follows the workspace's setting (for booking, no booking). The change is live: the agent uses it on its next reply.

  • Org key: the change runs at once, unless your organization holds org keys for chat.agent_update.
  • Member token: the person must be an org Owner or Admin (403 forbidden otherwise). The change is held until that person approves it in Finn: the answer is 202 with "status": "pending_approval" and nothing has changed yet. See requests held for approval.

Send an Idempotency-Key, so a retry returns the same approval instead of asking again. If the settings changed at the same moment, the answer is 409 setup_stale: read the agent again and retry.

Testing a reply

POST /chat/agents/{agent_id}/test_turn asks the agent for its next reply, as it would answer a customer. Nothing is sent to anyone, a booking is only simulated, the agent's own HTTP tools aren't called, and nothing is billed. It isn't held for approval.

FieldTypeRequiredNotes
lateststringYesThe customer's next message. Up to 4,000 characters.
historyarrayNoThe conversation so far: up to 50 { "role": "user" or "assistant", "content": "..." } messages.
channelstringNoDefault widget.
sessionstringNoKeeps several test turns together.

Example: try a question

curl -X POST https://api.hirefinn.ai/api/v1/chat/agents/2e3f4a5b-6c7d-4e8f-9a0b-1c2d3e4f5a6b/test_turn \
  -H "Authorization: Bearer $FINN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "history": [
      { "role": "assistant", "content": "Hi, I am Finn from Acme Clinic. How can I help?" }
    ],
    "latest": "Are you open on Sunday?"
  }'
{
  "text": "We're closed on Sundays. We're open Monday to Saturday, 9am to 7pm. Would you like me to book a time for you?",
  "options": ["Book a time", "Talk to a person"],
  "handoff": false,
  "end": false,
  "booking": null,
  "tools": [],
  "turn_id": "tt_5f0c2a9e",
  "latency_ms": 1840,
  "simulated": true
}

Rate limits

300 requests per minute per credential across the Chat API, and 60 writes per minute shared by every Chat write. At most 30 test turns per organization a minute. Over a limit: 429 rate_limited. See rate limits.

Errors

StatusCodeWhen
400invalid_requestThe body isn't valid. fields lists which.
401api_key_required, invalid_api_keyThe credential is missing, unknown or revoked.
403chat_api_not_enabledThe Chat API isn't switched on for your organization.
403insufficient_scopeThe credential lacks chat:read or chat:write.
403forbiddenA member token whose person isn't an org Owner or Admin.
403approval_unavailableA held change while approval holds are off for your organization.
404agent_not_foundNo such chat agent in your organization.
404not_foundChat agent settings aren't switched on for your organization.
409setup_staleThe settings changed at the same time. Read the agent again and retry.
422content_filtered, validation_failedThe agent refused the test turn.
423ai_apps_pausedAn admin paused all AI apps. Writes are refused; reads still work.
429rate_limitedOver a limit. Wait Retry-After seconds.
503unavailableChat is briefly unavailable. Safe to retry.