The script-tag widget is the supported way to embed Circuit chat. If you want to build a custom chat interface on these endpoints directly, contact the Circuit team.
Basics
- Base URL:
https://api.circuit.ai - Authentication:
Authorization: Bearer YOUR_AGENT_KEYon every request - Session continuity:
X-Session-Tokenheader (see sessions) - All endpoints enforce the key’s domain allowlist and share one rate limit of 60 requests per minute per key
GET /chat-bot/config
Returns the full configuration for the agent bound to the key. The launcher calls this on every page load to render the bubble with the correct branding. Response headers:Cache-Control: public, max-age=60, Vary: Authorization, Origin. The response is cacheable per (apiKey, origin) pair for 60 seconds.
Response body:
welcomeMessageisnullwhen no welcome message is configured.logoisnullwhen no logo is configured; the widget falls back to the Circuit mark.positionaccepts:top-left,top-center,top-right,middle-left,middle-center,middle-right,bottom-left,bottom-center,bottom-right. Unrecognized values fall back tobottom-right.style:windowedorfloating.features.actionsreflects whether the agent has any actions visible to widget visitors (admin-only and hide-in-chat actions are stripped).features.askUserQuestionis derived from whether the agent’s tool list includes AskUserQuestion.
console.warn and render nothing (fail-closed).
POST /chat-bot/
Sends a visitor message and streams the agent’s response. On the first call, the server creates a session and returns the session token inX-Session-Token. Include this token on all subsequent requests as X-Session-Token: <token> to continue the same chat.
Request headers: Content-Type: application/json, Accept: text/event-stream, and for subsequent turns, X-Session-Token: <token>.
Request body:
Content-Type: text/event-stream). Each event has an event name and a JSON data payload:
The set of event types can grow over time. Consumers should ignore event types they do not recognize.
Error status codes:
400 malformed body, 401 missing or revoked key, 403 origin not in the allowed domains list, 429 rate limit exceeded.
GET /chat-bot/history
Returns all messages in the current session, in order. RequiresX-Session-Token: <token> to identify the session.
Returns 404 when there is no session, which is the expected state before the visitor’s first message. This endpoint never creates a session.
GET /chat-bot/agent
Returns a narrow view of the agent bound to the key:JS API on the host page
The launcher attaches a small global towindow so your page can drive the chat from its own UI:
Calls made before the SPA finishes loading are queued and flushed once it signals ready, so
window.CircuitChat.open() on page load reliably opens the chat when the SPA mounts. window.CircuitChat is removed if the launcher is torn down.