Agents

Start an agent session

POST /v1/agents/{id}/sessions
Permission
write:sessions
Tokens
API key, CLI user token, Session token

The body takes the fields of Start a session, all optional, and is merged into the settings of the agent. An object merges key by key, any other value replaces the value the agent has, a field you leave out keeps it, and null removes it so its default applies. An environment object is merged into the environment of the agent. Send input when the agent declares an input schema.

Path parameters

idstringrequired
{
"force_rebuild": bool,
"idempotency_key": str,
}

Request

budgetRunBudget

Spend limit for this session. `session` is the most it may spend, in US dollars. Omitted, an agent session keeps the agent's limit and a raw session takes the organization's default. `null` takes the organization's default. Above the organization's per-session ceiling is a 400. `day`, `week`, and `month` are agent-wide limits and are rejected with a 422.

claude_codeClaudeCodeOverrides

Claude Code options merged into the agent's for this session. Naming Claude Code on an agent that runs another harness replaces its harness and requires a model. Set at most one of claude_code, codex, or gemini.

codexCodexOverrides

Codex options merged into the agent's for this session. Naming Codex on an agent that runs another harness replaces its harness and requires a model. Set at most one of claude_code, codex, or gemini.

conversationSessionConversationConfigPatch

Conversation settings merged into the agent's for this session. Omitted, the session keeps the agent's setting. `null` makes it interactive.

environmentstring | EnvironmentConfig

Where the session runs. A STRING is a saved environment's name or `env_...` id and replaces the agent's environment. An OBJECT is merged into the agent's environment, a saved one included: an object inside it merges key by key, any other value replaces the agent's, and `null` removes a value so its default applies. Omitted, the session keeps the agent's environment. `null` runs it in the built-in basic environment.

force_rebuildboolean

Skip the image cache for this session's initial provision: a fresh full build whose snapshot then refreshes the cache for later sessions.

geminiGeminiOverrides

Set at most one of claude_code, codex, or gemini.

idempotency_keystring

Optional retry safety key, unique per account across POST /v1/sessions and POST /v1/agents/{id}/sessions. A retry with the same key returns the session the first request started instead of starting another. Only a request that started a session holds its key. A key is kept for 90 days. The SDKs make a key for each call that sets none, so their own retries never start a second session.

imagesarray<ImageAttachment>

Images attached to the first message, base64 inline. Requires the model's `images` capability, listed by `/v1/account/models`. Each becomes an `[Image #N]` placeholder in the prompt and an image block the model sees with it. Up to 10, 5 MiB each; PNG, JPEG, GIF, or WebP.

inputobject

The typed payload for an agent that declares input.json_schema. Required when the agent declares a schema; rejected when it does not. Validated against the schema. Each {{field}} in the session's prompt, the agent's or one this request sends, is replaced with that field's value. A prompt that names no field gets the payload as formatted JSON after it.

mcparray<any>

MCP servers for this session, added to the servers its environment lists. A server with the same name as one of the environment's replaces it.

metadataConfigMetadataPatch

Metadata merged into the agent's for this session. Labels you send replace the agent's. Each annotation key you send sets that key, a `null` value removes the agent's key, and keys you leave out keep the agent's values. `null` removes all of the agent's metadata.

outputOutputConfigPatch

The structured-output exit contract merged into the agent's for this session. `null` removes the agent's.

permissionsPermissionsConfig

What the session may touch, per minted credential.

skillsarray<SkillRef>

Skills installed for this session.

Response

sessionSessionrequired

The session.

On this page

No Headings
Schedule a demo
For HumansFor Agents