API reference
Agent
Last updated:
Sessions and thread history for the Cardog agent
- POST
/v2/agent/sessionOpen an agent session - GET
/v2/agent/threadsList agent threads - GET
/v2/agent/threads/{id}/messagesRead an agent thread
/v2/agent/sessionsince 2026-10-27Open an agent session
Mint a short-lived session for the Cardog agent: a signed grant naming who the session acts as, which tools it may see and the ledger a turn debits. Costs 0 credits. Present `token` as the `grant` query parameter when you open the agent socket, and mint a new one on every connect; it lives 120 seconds. The grant is minted from the credential you send: a signed-in session opens a personal session, an API key opens one billed to that key, an anonymous session opens an anonymous one, and an org token from an organization workspace opens an org session. An organization key, or a server with no person behind it, is 403. Tool reads inside a turn run as the grant's subject and are never billed; the turn is the only charge.
Request body
AgentSessionCreateRequestsurface"web" | "org" | "native" | "mcp" | "sdk"optionalThe surface opening the session: "web" (the consumer site), "org" (an organization workspace), "native" (the mobile app), "mcp" (an MCP server), "sdk" (a program using an API key). Defaults to "sdk".
contextobjectoptionalhiddenstring[]optionalTools the person chose to hide. A hide list only: it never shows a tool the grant does not hold.
orgTokenstringoptionalThe org token from the organization workspace (a short-lived credential the API minted from your membership). Present it to open an org session; omit it for a personal one.
curl -X POST "https://api.cardog.app/v2/agent/session" \
-H "x-api-key: $CARDOG_API_KEY" \
-H "Cardog-Version: 2026-10-26" \
-H "content-type: application/json" \
-d '{"surface":"sdk"}'Response
200AgentSessiontokenstringThe signed session. Present it as the grant query parameter on the agent socket, or in the X-Cardog-Agent-Grant header on a thread read. It expires with the grant; mint a new one on every connect.
grantobjectsubstringThe account the session acts as. Every tool read inside a turn runs as this subject.
kind"anonymous" | "user" | "org" | "key""anonymous": an anonymous session (no account yet). "user": a signed-in person. "org": a member inside an organization workspace, minted only from an org token. "key": the owner of a personal API key.
classstringoptionalThe organization's class ("oem", "gov", "dealer", "insurer", "fleet", "internal"), or "technician" for a session at the bench. Present when kind is "org".
rolestringoptionalThe member's role at mint time. Present when kind is "org".
tenantIdstringoptionalThe tenant key, e.g. "oem/example". Present when kind is "org".
orgIdstringoptionalThe organization id. Present when kind is "org".
orgSlugstringoptionalThe workspace slug in the org surface's URL. Present when kind is "org".
orgNamestringoptionalThe organization's display name. Present when kind is "org".
scopesstring[]The tool scopes the session holds, e.g. ["consumer"] or ["org:*", "org:oem"]. A tool outside them is absent, not refused.
creditobjectThe ledger a turn debits
channel"session" | "key" | "org""session": the person's own account (an anonymous session has no credit account and is bounded by a turn limit). "key": the API key the session was opened with. "org": the organization.
refstringThe account on that channel: the user id for a session, the key id for a key, the organization id for an org
model"default" | "fixture"The model chain the session runs on. "default": the conversation chain. "fixture": the scripted sample model, which answers every tool from a recorded example and reaches no live model or data store.
expintegerExpiry, seconds since the epoch
surface"web" | "org" | "native" | "mcp" | "sdk"The surface opening the session: "web" (the consumer site), "org" (an organization workspace), "native" (the mobile app), "mcp" (an MCP server), "sdk" (a program using an API key). Defaults to "sdk".
contextobjecthiddenstring[]Tools the person chose to hide. A hide list only: it never shows a tool the grant does not hold.
expiresAtstring (date-time)The grant's expiry as ISO 8601
socketstringThe agent socket path to open with ?grant={token}, on the same host as this API
linksobjectself: this operation. threads: the session's threads, when it has a history.
Example response
7 keysErrors400401403429500503every non-2xx body is the error envelope
/v2/agent/threadssince 2026-10-27List agent threads
The threads (conversations) on the agent instance a grant names, newest activity first. Costs 0 credits. Without a grant this is your own personal history. To read an organization workspace's history, send the session token from POST /v2/agent/session in the X-Cardog-Agent-Grant header; the grant must be your own, or the read is 401. An anonymous session has no thread history (403), and neither does an organization key or a server token.
Query parameters
qstringoptionalKeep only threads whose name or newest message contains this text (case-insensitive)
Header parameters
X-Cardog-Agent-GrantstringoptionalA session token from POST /v2/agent/session, minted for you. Omit it to read your personal threads.
curl "https://api.cardog.app/v2/agent/threads" \
-H "x-api-key: $CARDOG_API_KEY" \
-H "Cardog-Version: 2026-10-26"Response
200AgentThreadListdataobject[]Newest activity first
idstringThe thread id
namestring | nullThe name the agent gave the thread, or null until it has one
lastMessagestring | nullA preview of the newest message, or null
createdAtstring (date-time)When the thread was opened, ISO 8601
updatedAtstring (date-time)When the thread last changed, ISO 8601
lastMessageAtstring | nullWhen the newest message landed, ISO 8601, or null
linksobjectmessages: this thread's messages.
linksobjectself: this operation.
Example response
2 keysErrors400401403429500503every non-2xx body is the error envelope
/v2/agent/threads/{id}/messagessince 2026-10-27Read an agent thread
One thread and its stored messages, oldest first, as AI SDK UIMessages. Costs 0 credits. The grant rules are those of GET /v2/agent/threads: your personal history without a grant, the grant's instance with one. A thread id that is not on that instance is a 404.
Path parameters
idstringrequiredThread id from GET /v2/agent/threads, e.g. "3f2b9c1e-7a4d-4e8b-9c0f-1a2b3c4d5e6f"
Header parameters
X-Cardog-Agent-GrantstringoptionalA session token from POST /v2/agent/session, minted for you. Omit it to read your personal threads.
curl "https://api.cardog.app/v2/agent/threads/3f2b9c1e-7a4d-4e8b-9c0f-1a2b3c4d5e6f/messages" \
-H "x-api-key: $CARDOG_API_KEY" \
-H "Cardog-Version: 2026-10-26"Response
200AgentThreadMessagesthreadobjectidstringThe thread id
namestring | nullThe name the agent gave the thread, or null until it has one
lastMessagestring | nullA preview of the newest message, or null
createdAtstring (date-time)When the thread was opened, ISO 8601
updatedAtstring (date-time)When the thread last changed, ISO 8601
lastMessageAtstring | nullWhen the newest message landed, ISO 8601, or null
linksobjectmessages: this thread's messages.
dataobject[]Oldest first
idstringrole"system" | "user" | "assistant"partsobject[]The message parts, in order
metadataobjectoptionallinksobjectself: this operation. threads: the thread list.
Example response
3 keysErrors400401403404429500503every non-2xx body is the error envelope
Generated from the contract. Machine-readable spec: GET https://api.cardog.app/v2/openapi.json · markdown twin: /docs/reference/agent.md
Was this helpful?