Skip to main content
POST
Create a session

Headers

idempotency-key
string

Optional Idempotency-Key header for safe retries

Required string length: 1 - 128
Pattern: ^\S[\s\S]*\S$|^\S$|^$

Body

application/json
agent
required

Agent to run in the session. Pass an ID to pin the latest version, or pass an object with type "agent", id, and version to pin a specific version.

Required string length: 1 - 256
environment_id
string
required

Environment ID for the session

Required string length: 1 - 256
initial_events
object[]

User messages to send in order when the session is created. Each message keeps its text blocks in order. The agent reads them joined with newlines. Each combined message can contain up to 16384 UTF-16 code units. The JSON array of text block arrays can contain up to 1048576 UTF-8 bytes. The whole request body can contain up to 2097152 UTF-8 bytes.

Maximum array length: 50
title
string | null

Optional session title

Maximum string length: 1024
vault_ids
string[]

Vaults whose credentials the session may use. A server with exactly one matching credential across them is bound to it.

Maximum array length: 20
Minimum string length: 1
mcp_server_credentials
object[]

Explicit credentials for named servers. An explicit binding wins over vault matching.

Maximum array length: 40
machine_credentials
object[]

Credentials with a prefix scope from the session's vaults, for the session's machine. A request from the machine's command line tools that matches a credential's scope is sent with that credential, added outside the machine; the token never enters the machine. With env, the machine gets that variable set to a placeholder for tools that expect a token variable. A mounted repository's requests keep the repository's own token.

Maximum array length: 16
resources
object[]

Repositories, memory stores, artifacts, skills and files to mount in the session's workspace

Maximum array length: 72

Response

Success

id
string
required
Required string length: 1 - 256
type
enum<string>
required
Available options:
session
status
enum<string>
required
Available options:
idle,
running,
terminated
environment_id
string
required
title
string | null
required
turn
integer
required
Required range: 0 <= x <= 9007199254740991
usage
object
required
mcp_server_credentials
object[]
required
Maximum array length: 40
machine_credentials
object[]
required

Credentials the session's machine uses: requests from its command line tools to a credential's targets are sent with that credential, added outside the machine

Maximum array length: 16
created_at
string
required
updated_at
string
required
archived_at
string | null
required
agent
object
required

The pinned agent configuration used by the session.

resources
object[]
required
runtime
object