Create Session
Open a session: one of your people, working toward one task, inside your environment.
The TASK is required and is exactly one of two shapes: {"instructions": "..."} describes the intent inline, or {"id": "..."} binds a task you registered. A bound task’s instructions are frozen onto the session, so later edits to the registry never change a run that already happened. An id that does not resolve is a 404; one that resolves but is retired is a 409.
The ENVIRONMENT is also exactly one of two shapes: environment_id names one you registered, or environment describes an ad-hoc one inline. A registered environment’s name, kind and configuration are snapshot onto the session for the same reason.
Send an Idempotency-Key header to make retries safe: the same key with the same body replays the original session as a 200, and the same key with a different body is a 409.
Authorizations
Workspace API key as a bearer token: Authorization: Bearer ish_sk_live_.... Keys are workspace-scoped machine principals minted in Settings > Developers (shown once at mint). Scopes: sessions:run (create a session, submit turns, close), sessions:read (read the session and its decision trace), environments:read and environments:write (manage the workspace's registered environments), tasks:read and tasks:write (manage the workspace's registered tasks), people:read and people:write (the people the workspace can run a session for), and usage:read (the workspace's own consumption, spend limits and rate-limit budgets). A key is minted with sessions:run, sessions:read, and tasks:read by default; every other scope must be requested, people:read and usage:read included. An ish user access token also works on the same header for personal scripts.
Headers
Path Parameters
Body
pause_on_decide, frame_on_demand, free_running A registered task in this workspace, bound by id.
- TaskRef
- TaskDescriptor
direct, intent An ad-hoc environment described inline. Mutually exclusive with environment_id; supply exactly one.
A registered environment in this workspace. Mutually exclusive with environment; supply exactly one.
Pin this session to a declared version of the registered environment, by label (case-insensitive; the canonical label is recorded). Requires environment_id. Omit to use the environment's default version, or to run unversioned when it has none. An unknown label is a 404, never a new bucket.
1 - 1201 <= x <= 200How long this session's observation frames are retained: none (discard after the turn), 30d, 90d, or indefinite. Omit to inherit the registered environment's setting; an inline environment descriptor defaults to none. Resolved once at open and fixed for the session's lifetime. Open union: new values may be added over time; clients must tolerate unknown values rather than failing on them.
none, 30d, 90d, indefinite low, medium, high 8000Response
Idempotent replay: an existing session was returned because the Idempotency-Key and request body matched a prior create.
The full session, without its decision trace.
What create and close return: a caller that opened a session holds the same object a read would give it, so nothing has to be fetched twice to learn what was actually frozen. The TRACE is deliberately absent: turns are a paged subresource of the detail read, and a create has none yet.
This session's spend in credits (0 if it had no billable turns).
direct, intent When the session left open (UTC), stamped on the first terminal transition and never moved. Null while the session is open. This is the timestamp sessions_ended usage buckets on.
Why the session ended, when that is finer than status: credits_exhausted or plan_allowance_exhausted (both end the session as balance_exhausted), or spend_cap_reached. Null for an ordinary ending. Open union: new values may be added over time; clients must tolerate unknown values rather than failing on them.
The environment as frozen at create (name + kind snapshot).
Session status. Open union: new values may be added over time; clients must tolerate unknown values rather than failing on them.
open, completed, gave_up, closed, max_turns, spend_cap_reached, balance_exhausted The session's intent, frozen when it was created. A later edit to a registered task never changes it.
Retention window resolved at open: none, 30d, 90d, or indefinite. Open union: new values may be added over time; clients must tolerate unknown values rather than failing on them.
pause_on_decide, frame_on_demand, free_running The person as they were when the session was created, frozen onto the session.
This, not the live person, is what the session was run against: it stays readable and unchanged after the person is edited or deleted, which is what makes an old trace still mean something. id is the person's id at create time.
Additional keys may be present and more may be added over time; treat anything not listed here as unspecified rather than failing on it.
Deliberation budget the session was opened with: low, medium or high. Open union: new values may be added over time; clients must tolerate unknown values rather than failing on them.