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.
Request
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 Code input and native options. Set exactly one of claude_code, codex, or gemini.
Codex input and native options. Set exactly one of claude_code, codex, or gemini.
Conversation settings. Omitted, the session is interactive. Warmth and prompting are server-owned response fields.
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.
Skip the image cache for this session's initial provision: a fresh full build whose snapshot then refreshes the cache for later sessions.
Set exactly one of claude_code, codex, or gemini.
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.
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.
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.
Labels and annotations stored on the session, to filter sessions by.
The structured-output exit contract for this session.
What the session may touch, per minted credential.
Skills installed for this session.
Response
The session.