The AI API also includes an embedded, org-wide Knowledge Base — not shown
in the auto-generated endpoint list below. Ingest documents by upload, URL,
markdown, or bulk help-center import (
POST /api/v1/ai/kb/documents,
POST /api/v1/ai/kb/import/help-center), keep them fresh with a staleness
scorecard and per-document verification (GET /api/v1/ai/kb/staleness,
POST /api/v1/ai/kb/documents/{id}/verify), and query them with raw semantic
search (POST /api/v1/ai/kb/search) or a grounded answer with citations
(POST /api/v1/ai/kb/answers). See the full
AI Knowledge Base reference. For a
separately provisioned, per-knowledge-base store, use the
Knowledge Bases API.Worked session/memory + budget envelopes
The auto-generated response examples below show the OpenAPI schema shape. The worked envelopes in this section show the exact fields your integration sees, with real values, across the three AI chains the reference below only half-covers: the per-contact session-memory read/write pair, the per-agent token-budget precheck, and the chat response the whole flow ends in. Together with the worked agent samples they give you a body you can branch on for every call an agent build makes first. Both the memory round trip and the budget precheck are tenant-owned controls: memory facts are scoped to one contact (and deleted with the contact’s GDPR erasure), and the token budget is a per-agent cap your workspace sets. The session-memory pair has its four statuses —201 write, 200 read, 409 opt-out or per-contact fact cap, 422 validation.
1. Session memory round trip
Teach the agent a fact about a contact, then read the same contact’s facts back. The write returns201 with the stored item; the read returns the newest facts with PII in the fact bodies masked unless your role is in the unmask allowlist and you pass ?reveal=true. When the contact has opted out of memory the write returns 409 MEMORY_DISABLED_FOR_CONTACT and the read returns an empty list with memory_enabled: false.
POST /api/v1/agents/{agentId}/memorycontact_id and fact are required; source is manual (default) or conversation, and importance (0–1) overrides the default 0.9 for manual teaches. The fact body is sanitised, capped to your tenant’s content limit, and stored with an embedding so the agent can retrieve it in later turns.
Request
GET /api/v1/agents/{agentId}/memory?contact_id=ctt_4f2a9c1efact-type entries are returned and phone/email tokens in the bodies are PII-masked; owner, admin, and developer roles can pass reveal=true to unmask (each reveal is audit-logged). A contact that has opted out returns an empty items list with memory_enabled: false.
409 the write returns when the contact has opted out — branch on this before you surface “teach the agent” in your UI:
409
2. Token-budget precheck
Evaluate an action against your agent’s governance policies before the send, so a long turn never starts when it would be denied. Pass the intendedmodel, the tool id (if the action invokes a tool), and the tokens the agent has already consumed this UTC month. The response merges every enabled policy that applies to the agent and returns a single allow/deny verdict with the effective caps it resolved — the monthly token budget is the strictest (minimum) across applying policies, and the model allowlist is the intersection. Gate on allowed: true/false; when the gate denies, reason is one of model_not_allowed, budget_exceeded, or sod_approval_required. Both fields you need to gate the send are on the envelope below.
GET /api/v1/agents/governance-internal/resolve?agent_id=agt_7e3b9c1f&model=claude-sonnet-4-6&monthly_tokens_used=84129monthly_tokens_used=250000 (already at the budget) the verdict flips — gate on it before you send:
200
POST /api/v1/agents/{agentId}/chat200
3. Errors-as-decision-table
Every/ai and /agents failure returns the same { error, meta } envelope. The error.code and status tell you which of the three decisions to take; don’t treat 4xx as one class.
429
429, 502, 503) are the only safe replay: they mean nothing was committed, so the same request can be resent after the wait. Reframe statuses (402, 409, 422) will fail identically every time until you change the request — and 409 MEMORY_DISABLED_FOR_CONTACT specifically means stop, because the contact revoked consent.