agent

Open an agent session

Changed on

Creates a short-lived session for the Cardog agent. Its token is a signed grant that says who the agent acts as, which tools it may use and which account pays for each turn. Pass token as the grant query parameter when you open the agent's socket. It expires after 120 seconds, so create a new one for every connection.

The kind of session follows 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 organization token from an organization workspace opens an organization session. An organization API key, or a server with no person behind it, is a 403.

Costs 0 credits. Each agent turn is billed; the data the agent reads during a turn is not.

post/v2/agent/session

Request

  • Base URL
    https://api.cardog.app
  • Auth
    • API key in header x-api-key
    • or HTTP bearer

Request body

AgentSessionCreateRequest required
surface, 'web' | 'org' | 'native' | 'mcp' | 'sdk'

Where the session is opened from: "web" (the Cardog website), "org" (an organization workspace), "native" (the mobile app), "mcp" (an MCP server) or "sdk" (your own program, using an API key). Default "sdk".

context, object

Session settings. hidden lists tools to hide, up to 64.

orgToken, string

The org token from the organization workspace, a short-lived credential tied to your membership. Send it to open an organization session; leave it out for a personal one.

Response

The session and its token

AgentSession required
token, string required

The signed session. Send it as the grant query parameter when you open the agent socket, or in the X-Cardog-Agent-Grant header when you read threads. It expires after 120 seconds: create a new session on every connect.

grant, object required

What the session may do and who pays, as signed into token

surface, 'web' | 'org' | 'native' | 'mcp' | 'sdk' required

Where the session is opened from: "web" (the Cardog website), "org" (an organization workspace), "native" (the mobile app), "mcp" (an MCP server) or "sdk" (your own program, using an API key). Default "sdk".

context, object required

The session settings

expiresAt, string date-time required

When the session expires, ISO 8601

socket, string required

The path of the agent socket. Open it with ?grant={token} on the same host as this API.

links, object required

self: this endpoint. threads: the session's past chats, when it has any.

Changes