For the complete documentation index, see llms.txt. This page is also available as Markdown.

POST /v2/runs/{run_id}/cancel

Cancel Run

post

Request cancellation of an accessible run owned by this authenticated actor.

Ownership matches the actor type and identity that started the run, including the distinction between a personal API key and a platform session. Acceptance acknowledges the request; it does not guarantee execution has already stopped. Polling the Location URL separately requires analytics read permission.

How to use

Use the originating actor type and identity. A 202 acknowledges cancellation signalling, not a stopped execution; poll afterward. A 404 can indicate nonownership. Side effects already performed cannot be undone by cancellation.

Authentication and permissions

Required permissions: projects.run. Resource and owner access checks also apply.

Authorizations
AuthorizationstringRequired

Personal API key (sk_...) or supported user access JWT. See Authentication and authorization for endpoint restrictions and scopes. Use exactly one Authorization header.

Path parameters
run_idstring · uuidRequired
Responses
202

Cancellation accepted. Poll the Location URL for the current run state.

application/json

Base response model for StackAI API endpoints.

Provides Pydantic validation and serialization with a helper method to convert to FastAPI's JSONResponse when needed.

Serialization contract: status_code never reaches the body (it only feeds to_json_response), and response_code/meta are omitted when unset so success bodies carry no filler. Error handlers that set them keep them.

response_codestring · nullableOptional

Machine-readable response code, when provided.

post/v2/runs/{run_id}/cancel
curl
curl --fail-with-body -sS -X POST \
  "$STACKAI_BASE_URL/v2/runs/${RUN_ID}/cancel" \
  -H "Authorization: Bearer $STACKAI_API_KEY"
{
  "response_code": "text",
  "meta": {
    "ANY_ADDITIONAL_PROPERTY": "anything"
  }
}

Last updated

Was this helpful?