Cancel a session

POST/o/{org}/sessions/{session}/cancel
View .md

Ends the run and releases its sandbox. No body is read.

Authenticate with an org API key or a signed-in session.

Path parameters

orgstringrequired

The org's slug or id. A caller with no role in the org gets 404.

sessionstringrequired

The session's full id (execution_id).

Responses

202The session as GET reads it, status cancelled, or cancelling while the sandbox is still being released; it reads cancelled from then on.
execution_idstringrequired

The session id.

org_idstringrequired

The org as the request's path named it.

project_idstringoptional

The Project the console ran the session in.

Format uuid
statusstringrequired

paused is a resumable session parked between turns; needs_review finished without the proof it was asked for; cancelling appears only in the 202 answer to a cancel whose sandbox is still being released; GET reads cancelled once it is.

One ofqueuedallocatingrunningpausedinput_requiredneeds_reviewcompletedfailedcancellingcancelledexpired
harnessstringoptional

claude, codex or opencode.

agent_idstringoptional

The saved agent the session was started from, if any.

Format uuid
modelstringoptional
effortstringoptional
resultstringoptional

The agent's final answer for the last finished turn, in full.

errorobjectoptional
2 fields
codestringrequired
messagestringrequired
repo_ownerstringoptional
repo_namestringoptional
branchstringoptional
pr_urlstringoptional
input_tokensintegeroptional
output_tokensintegeroptional
cache_read_tokensintegeroptional
cache_write_tokensintegeroptional
total_tokensintegeroptional

Uncached input plus cache writes plus output.

reasoning_tokensintegeroptional
total_cost_usdnumberoptional
tool_calls_countintegeroptional
turns_countintegeroptional
artifactsarray of objectoptional

Every file the agent saved to /workspace/.rush/artifacts/. url downloads it with no credential until url_expires_at, an hour after the read; read the session again for a fresh link. GET …/artifacts/{name} with the key also downloads it.

4 item fields
namestringrequired
mime_typestringrequired
urlstringrequired

A signed https link to the file.

Format uri
url_expires_atstringrequired
Format date-time
attachmentsarray of objectoptional

The files the session was started or followed up with.

3 item fields
idstringrequired
Format uuid
namestringrequired
mime_typestringrequired
created_atstringoptional
Format date-time
completed_atstringoptional
Format date-time
401No bearer, an unknown, revoked or expired one, or an API key on a route keys cannot call.
errorstringoptional

A sentence for a person.

codestringoptional

Stable machine code, e.g. AUTH_FAILED, NOT_FOUND, VALIDATION_ERROR, RATE_LIMITED, TOKEN_LIMIT_REACHED.

error_codestringoptional

The machine code on routes that name it this way.

messagestringoptional
requestIdstringoptional
404No such resource for the caller, including one that exists in an org the caller cannot see.
errorstringoptional

A sentence for a person.

codestringoptional

Stable machine code, e.g. AUTH_FAILED, NOT_FOUND, VALIDATION_ERROR, RATE_LIMITED, TOKEN_LIMIT_REACHED.

error_codestringoptional

The machine code on routes that name it this way.

messagestringoptional
requestIdstringoptional
409The session already finished (RUN_STATE_CONFLICT).
errorstringoptional

A sentence for a person.

codestringoptional

Stable machine code, e.g. AUTH_FAILED, NOT_FOUND, VALIDATION_ERROR, RATE_LIMITED, TOKEN_LIMIT_REACHED.

error_codestringoptional

The machine code on routes that name it this way.

messagestringoptional
requestIdstringoptional
503The runtime did not confirm the cancel (CANCELLATION_UNCONFIRMED).

The runtime did not confirm the cancel (CANCELLATION_UNCONFIRMED). Read the session, then retry.

errorstringoptional

A sentence for a person.

codestringoptional

Stable machine code, e.g. AUTH_FAILED, NOT_FOUND, VALIDATION_ERROR, RATE_LIMITED, TOKEN_LIMIT_REACHED.

error_codestringoptional

The machine code on routes that name it this way.

messagestringoptional
requestIdstringoptional