cs_ followed by 16 characters. Fields of the Session object: API schema.
Status
Each change is a
session.status_changed event with from and to.
Create and list
HTTP only:POST /sessions with a CreateSessionBody, and GET /sessions.
id is a session id chosen by the client; input is the first message. Accepted values for model, effort, speed and mode are in the session’s capabilities.
access sets who may use the session (Access). Without it, the session gets the organization’s apiAccessDefault.
GET /sessions lists only the sessions you may use. That holds for admins too: being an admin shows you no one else’s session. A session’s own short-lived key lists only that session, and cannot create sessions (403 forbidden, reason: "computer_principal").
Read
sessions.get (GET /sessions/{id}) returns the Session, including the active turn id, queued turns, open asks, running subagents and lastSeq. minSeq reads your own write: Session journal.
Watch
To follow a session as it runs, read its events over HTTP, then subscribe toevents:<id> (and deltas:<id> for text as it is written) on Live. Watching never resumes a suspended session. Its capabilities (models with their effort levels, permission modes, and features) are at GET /sessions/{id}/capabilities.
Update
sessions.update (PATCH /sessions/{id}, HTTP only like every write) changes any of title, model, effort, speed, mode, archived, metadata and access (Access). It returns the session and a seq.
Only the session’s owner may update it. Anyone else it is shared with, admins included, gets 403 forbidden with reason: "owner_only". They can still read and watch the session, send messages, answer asks, and stop or interrupt it. A new message un-archives an archived session, whoever sends it.
Access
Sessions started from the dashboard, opc or the API have anaccess field, {"mode", "people"}:
Using a session means everything that reads or drives it: get, list, watch on Live, history (events, turns, asks, subagents), writes, terminals and workspace files. Anyone with access drives the session with its owner’s secrets and subscription. To someone without access, the session does not exist:
404 session_not_found.
Set it when you create the session, or change it with PATCH /sessions/{id}:
Two fields on the session say where you stand:
Organization default
GET /settings returns {"settings":{"apiAccessDefault":"owner"}}. apiAccessDefault is the access of new sessions started from the dashboard, opc or the API without access: owner (the default) or org. A session an agent starts takes the access of the session that started it. An organization admin changes it with PATCH /settings and {"apiAccessDefault":"org"}. Anyone else gets 403 admin_required. Slack sessions keep their own default, set in Slack.
Set aside
Triage lists the asks waiting on you. Setting a session aside moves its ask out of that list until something newer needs you. HTTP only:PUT /sessions/{id}/aside sets it, DELETE /sessions/{id}/aside brings it back. Both return the session.
Compact
sessions.compact (POST /sessions/{id}/compact) queues a compaction as a turn and returns the same result as turns.send.
instructions (up to 10,000 characters) is passed to the harness’s /compact command. The session.compacted event gives beforeTokens, afterTokens and auto (true when the harness compacted on its own). See Context and compaction.
Suspend
sessions.suspend (POST /sessions/{id}/suspend) stops the session’s runner. The journal and workspace stay on the computer.
Suspending cancels queued turns, stops running subagents, closes open asks as
interrupted, and records runtime.suspended with reason: "requested". The other reasons are idle and lost.
Resume
sessions.resume (POST /sessions/{id}/resume) starts the runtime of a suspended session, or of an idle one whose runner has exited after two hours idle, and returns at once; runtime.starting and runtime.connected events follow. On a session that is not suspended it returns the session unchanged. Sending a turn to a suspended session also starts it.