Sessions

Start a session

POST /v1/sessions
Permission
write:sessions
Tokens
API key, CLI user token, Session token

Start a cloud session. Select a harness explicitly. Provide an inline environment, reference a saved environment, or omit it to use the default environment. Set conversation.interactive to false to run once. The response carries the session. Its status says where it is.

{
"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_codeClaudeCodeConfig

Claude Code input and native options. Set exactly one of claude_code, codex, or gemini.

codexCodexConfig

Codex input and native options. Set exactly one of claude_code, codex, or gemini.

conversationSessionConversationConfig

Conversation settings. Omitted, the session is interactive. Warmth and prompting are server-owned response fields.

environmentstring | EnvironmentConfig

Where the session runs. A STRING is a saved environment's name or `env_...` id, substituted wholesale. An OBJECT is the whole environment for this session, and `{}` is the bare environment. Nothing is merged: what you send is the whole environment. Omitted, a raw session runs in the built-in basic environment and an agent session keeps the agent's own environment. `null` runs an agent session 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.

geminiGeminiConfig

Set exactly 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.

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.

metadataConfigMetadata

Labels and annotations stored on the session, to filter sessions by.

outputOutputConfig

The structured-output exit contract for this session.

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