API reference

Agent

Last updated:

Sessions and thread history for the Cardog agent

These routes are not mounted on api.cardog.app yet.
POST/v2/agent/sessionsince 2026-10-27

Open 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

AgentSessionCreateRequest
surface"web" | "org" | "native" | "mcp" | "sdk"optional

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".

contextobjectoptional
hiddenstring[]optional

Tools the person chose to hide. A hide list only: it never shows a tool the grant does not hold.

orgTokenstringoptional

The 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

200AgentSession
tokenstring

The 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.

grantobject
substring

The 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.

classstringoptional

The organization's class ("oem", "gov", "dealer", "insurer", "fleet", "internal"), or "technician" for a session at the bench. Present when kind is "org".

rolestringoptional

The member's role at mint time. Present when kind is "org".

tenantIdstringoptional

The tenant key, e.g. "oem/example". Present when kind is "org".

orgIdstringoptional

The organization id. Present when kind is "org".

orgSlugstringoptional

The workspace slug in the org surface's URL. Present when kind is "org".

orgNamestringoptional

The 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.

creditobject

The 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.

refstring

The 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.

expinteger

Expiry, 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".

contextobject
hiddenstring[]

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

socketstring

The agent socket path to open with ?grant={token}, on the same host as this API

linksobject

self: this operation. threads: the session's threads, when it has a history.

Example response

7 keys
"response": {
"token": "eyJ2IjoyLCJpYXQiOjE3OTE2OTEwNDQsImV4cCI6MTc5MTY5MTE2NCwiZ3JhbnQiOnsic3ViIjoiV3E4blZ0M2tYeTJMbVI1cFpzN2NKZDRmIiwia2luZCI6ImtleSIsInNjb3BlcyI6WyJjb25zdW1lciJdLCJjcmVkaXQiOnsiY2hhbm5lbCI6ImtleSIsInJlZiI6Ikt4NG1QcTdyVHoyV3ZOOGJMZDVzSGozYyJ9LCJtb2RlbCI6ImRlZmF1bHQifSwic3VyZmFjZSI6InNkayIsImNvbnRleHQiOnsiaGlkZGVuIjpbXX19.gS-jnVeJmZ9uooVu1Ok_0Q8VNHbg-PsxgK3KjkCbPC8",
"grant": {
"sub": "Wq8nVt3kXy2LmR5pZs7cJd4f",
"kind": "key",
"scopes": [1 item],
"credit": {2 items},
"model": "default",
"exp": 1791691164
},
"surface": "sdk",
"context": {
"hidden": [0 items]
},
"expiresAt": "2026-10-11T03:59:24.000Z",
"socket": "/agents/cardog-agent/Wq8nVt3kXy2LmR5pZs7cJd4f",
"links": {
"self": "/v2/agent/session",
"threads": "/v2/agent/threads"
}
}

Errors400401403429500503every non-2xx body is the error envelope

GET/v2/agent/threadssince 2026-10-27

List 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

qstringoptional

Keep only threads whose name or newest message contains this text (case-insensitive)

Header parameters

X-Cardog-Agent-Grantstringoptional

A 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

200AgentThreadList
dataobject[]

Newest activity first

idstring

The thread id

namestring | null

The name the agent gave the thread, or null until it has one

lastMessagestring | null

A 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 | null

When the newest message landed, ISO 8601, or null

linksobject

messages: this thread's messages.

linksobject

self: this operation.

Example response

2 keys
"response": {
"data": [
0: {7 items}
],
"links": {
"self": "/v2/agent/threads"
}
}

Errors400401403429500503every non-2xx body is the error envelope

GET/v2/agent/threads/{id}/messagessince 2026-10-27

Read 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

idstringrequired

Thread id from GET /v2/agent/threads, e.g. "3f2b9c1e-7a4d-4e8b-9c0f-1a2b3c4d5e6f"

Header parameters

X-Cardog-Agent-Grantstringoptional

A 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

200AgentThreadMessages
threadobject
idstring

The thread id

namestring | null

The name the agent gave the thread, or null until it has one

lastMessagestring | null

A 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 | null

When the newest message landed, ISO 8601, or null

linksobject

messages: this thread's messages.

dataobject[]

Oldest first

idstring
role"system" | "user" | "assistant"
partsobject[]

The message parts, in order

metadataobjectoptional
linksobject

self: this operation. threads: the thread list.

Example response

3 keys
"response": {
"thread": {
"id": "3f2b9c1e-7a4d-4e8b-9c0f-1a2b3c4d5e6f",
"name": "Recalls on a 2021 RAV4",
"lastMessage": "There is one open recall for that model year.",
"createdAt": "2026-10-09T14:02:11.000Z",
"updatedAt": "2026-10-09T14:03:40.000Z",
"lastMessageAt": "2026-10-09T14:03:40.000Z",
"links": {1 item}
},
"data": [
0: {4 items},
1: {4 items}
],
"links": {
"self": "/v2/agent/threads/3f2b9c1e-7a4d-4e8b-9c0f-1a2b3c4d5e6f/messages",
"threads": "/v2/agent/threads"
}
}

Errors400401403404429500503every non-2xx body is the error envelope

GET/v2/agent/org/directorysince 2026-11-19

Who an organization may name on a thread

The organizations the grant's organization may name as participants when it opens a coordination thread, and the seat the grant acts as (re-read now: a read-only seat has canWrite false). Costs 0 credits. Requires an org grant in the X-Cardog-Agent-Grant header, sent by the grant's own person or by the agent runtime.

Header parameters

X-Cardog-Agent-Grantstringrequired

An org session token from POST /v2/agent/session (opened from an organization workspace), minted for you. Required.

curl "https://api.cardog.app/v2/agent/org/directory" \
  -H "x-api-key: $CARDOG_API_KEY" \
  -H "Cardog-Version: 2026-10-26"

Response

200AgentOrgDirectory
seatobject

Who the grant acts as, re-read on this call

organizationobject
slugstring
namestring
classstring
rolestring

The member's role in the organization, read now, not from the grant

canWriteboolean

False for a read-only seat (the viewer role): it may read threads and write none

mayOpenboolean

False when this organization's class cannot open threads

organizationsobject[]
namestring
slugstring
classstring

Example response

3 keys
"response": {
"seat": {
"organization": {3 items},
"role": "member",
"canWrite": true
},
"mayOpen": true,
"organizations": [
0: {3 items}
]
}

Errors401404429500503every non-2xx body is the error envelope

GET/v2/agent/org/keyssince 2026-11-20

An organization's API keys, metadata only

The grant's organization's API keys: name, first characters, state, created and last used, never the key. Readable by every member of an organization whose developer surface is live; the 30-day usage per key and by day is included only for an owner or admin (seat.canManage), otherwise null. Making and revoking keys happens in the browser, never here. Costs 0 credits. Requires an org grant in the X-Cardog-Agent-Grant header, sent by the grant's own person or by the agent runtime.

Header parameters

X-Cardog-Agent-Grantstringrequired

An org session token from POST /v2/agent/session (opened from an organization workspace), minted for you. Required.

curl "https://api.cardog.app/v2/agent/org/keys" \
  -H "x-api-key: $CARDOG_API_KEY" \
  -H "Cardog-Version: 2026-10-26"

Response

200AgentOrgKeys
seatobject
organizationobject
slugstring
namestring
classstring
rolestring
canManageboolean

True for an owner or admin: may make and revoke keys and read usage

keysobject[]
idstring
namestring | null
startstring | null

The key's first characters, as shown on the developer page

enabledboolean
createdAtstring

ISO 8601

lastUsedAtstring | null

ISO 8601, or null when never used

expiresAtstring | null
credits30dinteger | null

Credits this key spent in the last 30 days; null for a seat that cannot read usage

usageobject | null

The organization's keyed usage over 30 days; null for a seat that cannot read usage

days30
creditsinteger
unitsinteger
byDayobject[]
daystring
creditsinteger
unitsinteger

Example response

3 keys
"response": {
"seat": {
"organization": {3 items},
"role": "admin",
"canManage": true
},
"keys": [
0: {8 items},
1: {8 items}
],
"usage": {
"days": 30,
"credits": 43,
"units": 43,
"byDay": [2 items]
}
}

Errors401404429500503every non-2xx body is the error envelope

POST/v2/agent/org/issuessince 2026-11-19

Open a coordination thread

Open a thread in the grant's organization, as the grant's person, through the same checks as the workspace: the class must open threads, a read-only seat is 403, and every participant must be in GET /v2/agent/org/directory. The body is plain text; blank lines separate paragraphs. Costs 0 credits. The agent runtime calls this only after the person approved the draft.

Header parameters

X-Cardog-Agent-Grantstringrequired

An org session token from POST /v2/agent/session (opened from an organization workspace), minted for you. Required.

Request body

AgentOrgIssueCreateRequest
titlestringrequired
bodystringrequired

Plain text. Blank lines separate paragraphs.

participantsstring[]optional

Organization slugs from GET /v2/agent/org/directory

kind"vin" | "listing" | "seller" | "document" | "delivery" | "campaign" | "data" | "general"optional
subjectRefstring | nulloptional
curl -X POST "https://api.cardog.app/v2/agent/org/issues" \
  -H "x-api-key: $CARDOG_API_KEY" \
  -H "Cardog-Version: 2026-10-26"

Response

201AgentOrgIssueCreated
issueobject
idstring
numberinteger
keystring
linksobject
issuestring

The thread's header read, GET /v2/agent/org/issues/{issueId}

Example response

2 keys
"response": {
"issue": {
"id": "3f2b9c1e-7a4d-4e8b-9c0f-1a2b3c4d5e6f",
"number": 12,
"key": "EXAMPLE-DEALER-12"
},
"links": {
"issue": "/v2/agent/org/issues/3f2b9c1e-7a4d-4e8b-9c0f-1a2b3c4d5e6f"
}
}

Errors400401403404429500503every non-2xx body is the error envelope

GET/v2/agent/org/issues/{issueId}since 2026-11-19

A coordination thread's header

One thread the grant's organization takes part in: title, key, state, subject, owning organization and participants, whether this organization may close or reopen it, and whether its words are withheld from the assistant. Never its description or comments. A thread the organization does not take part in is a 404, the same as one that does not exist. Costs 0 credits.

Path parameters

issueIdstring (uuid)required

Thread id from the organization's coordination list, e.g. "3f2b9c1e-7a4d-4e8b-9c0f-1a2b3c4d5e6f"

Header parameters

X-Cardog-Agent-Grantstringrequired

An org session token from POST /v2/agent/session (opened from an organization workspace), minted for you. Required.

curl "https://api.cardog.app/v2/agent/org/issues/{issueId}" \
  -H "x-api-key: $CARDOG_API_KEY" \
  -H "Cardog-Version: 2026-10-26"

Response

200AgentOrgIssue
seatobject

Who the grant acts as, re-read on this call

organizationobject
slugstring
namestring
classstring
rolestring

The member's role in the organization, read now, not from the grant

canWriteboolean

False for a read-only seat (the viewer role): it may read threads and write none

issueobject
idstring
keystring
numberinteger
titlestring
state"open" | "closed"
kind"vin" | "listing" | "seller" | "document" | "delivery" | "campaign" | "data" | "general"
subjectRefstring | null
owningOrganizationobject
namestring
slugstring
classstringoptional
participantsobject[]
namestring
slugstring
classstringoptional
stewardboolean

True when this organization may close or reopen the thread: its own thread, or Cardog staff

textWithheldboolean

True when a manufacturer owns or takes part in the thread: its words are not readable by the assistant

Example response

2 keys
"response": {
"seat": {
"organization": {3 items},
"role": "member",
"canWrite": true
},
"issue": {
"id": "3f2b9c1e-7a4d-4e8b-9c0f-1a2b3c4d5e6f",
"key": "EXAMPLE-DEALER-12",
"number": 12,
"title": "Title brand on a 2021 RAV4 trade-in",
"state": "open",
"kind": "vin",
"subjectRef": "vin:2T3RWRFV5MW123456",
"owningOrganization": {2 items},
"participants": [1 item],
"steward": true,
"textWithheld": false
}
}

Errors400401404429500503every non-2xx body is the error envelope

POST/v2/agent/org/issues/{issueId}/commentssince 2026-11-19

Reply on a coordination thread

Post a reply as the grant's person, through the workspace's own comment checks: a read-only seat is 403, a thread the organization does not take part in is 404. Costs 0 credits. The agent runtime calls this only after the person approved the draft.

Path parameters

issueIdstring (uuid)required

Thread id from the organization's coordination list, e.g. "3f2b9c1e-7a4d-4e8b-9c0f-1a2b3c4d5e6f"

Header parameters

X-Cardog-Agent-Grantstringrequired

An org session token from POST /v2/agent/session (opened from an organization workspace), minted for you. Required.

Request body

AgentOrgCommentCreateRequest
bodystringrequired
parentIdstring | nulloptional
curl -X POST "https://api.cardog.app/v2/agent/org/issues/{issueId}/comments" \
  -H "x-api-key: $CARDOG_API_KEY" \
  -H "Cardog-Version: 2026-10-26"

Response

201AgentOrgCommentCreated
commentobject
idstring
parentIdstring | null
linksobject
issuestring

The thread's header read, GET /v2/agent/org/issues/{issueId}

Example response

2 keys
"response": {
"comment": {
"id": "7c1d2e3f-4a5b-4c6d-8e7f-9a0b1c2d3e4f",
"parentId": null
},
"links": {
"issue": "/v2/agent/org/issues/3f2b9c1e-7a4d-4e8b-9c0f-1a2b3c4d5e6f"
}
}

Errors400401403404429500503every non-2xx body is the error envelope

PATCH/v2/agent/org/issues/{issueId}/statesince 2026-11-19

Close or reopen a coordination thread

Compare-and-set the thread's state as the grant's person. Only the thread's own organization (or Cardog staff) may close or reopen it; anyone else gets 404. A state that changed since the draft is 409. Costs 0 credits. The agent runtime calls this only after the person approved the change.

Path parameters

issueIdstring (uuid)required

Thread id from the organization's coordination list, e.g. "3f2b9c1e-7a4d-4e8b-9c0f-1a2b3c4d5e6f"

Header parameters

X-Cardog-Agent-Grantstringrequired

An org session token from POST /v2/agent/session (opened from an organization workspace), minted for you. Required.

Request body

AgentOrgIssueStateRequest
state"open" | "closed"required
expectedState"open" | "closed"optional
curl -X PATCH "https://api.cardog.app/v2/agent/org/issues/{issueId}/state" \
  -H "x-api-key: $CARDOG_API_KEY" \
  -H "Cardog-Version: 2026-10-26"

Response

200AgentOrgIssueState
issueobject
idstring
state"open" | "closed"
linksobject
issuestring

The thread's header read, GET /v2/agent/org/issues/{issueId}

Example response

2 keys
"response": {
"issue": {
"id": "3f2b9c1e-7a4d-4e8b-9c0f-1a2b3c4d5e6f",
"state": "closed"
},
"links": {
"issue": "/v2/agent/org/issues/3f2b9c1e-7a4d-4e8b-9c0f-1a2b3c4d5e6f"
}
}

Errors400401403404409429500503every 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