Cancel a run

Cancel a running or pending run. Returns the updated run resource — same shape as GET /runs/{id} — read after the terminal pipeline ran, so status is cancelled and cost/duration reflect the final state.

POST/api/runs/{id}/cancel

Authorization

better-auth.session_token<token>

Cookie session from Better Auth. Requires X-Org-Id header for org-scoped routes.

In: cookie

Path Parameters

id*string

Header Parameters

X-Org-Id?string

Organization ID. Required for cookie auth. Not needed for API key auth (org resolved from key).

Formatuuid
X-Space-Id?string

Space ID. Required for space-scoped routes (agents, runs, schedules, and space-scoped module routes). Not needed for API key auth (space resolved from key).

curl -X POST "https://your-instance/api/runs/string/cancel"
{
  "id": "run_cm1abc123def456",
  "packageId": "@acme/email-sorter",
  "userId": "usr_k7x9m2p4q1",
  "endUserId": null,
  "apiKeyId": null,
  "orgId": "org_r3t5w8y1z6",
  "spaceId": "spc_1d4e7a90-3c21-4b6f-8e05-6a9c2f7b1d38",
  "scheduleId": null,
  "status": "cancelled",
  "input": {
    "folder": "inbox",
    "maxEmails": 50
  },
  "result": null,
  "artifacts": null,
  "checkpoint": {},
  "error": "Cancelled by user",
  "metadata": null,
  "generation": null,
  "generation_override": null,
  "started_at": "2026-01-15T10:30:00Z",
  "completed_at": "2026-01-15T10:30:45Z",
  "duration": 45000,
  "cost": 0.0012,
  "cost_pricing_status": "priced",
  "unread": false,
  "runNumber": 18,
  "token_usage": null,
  "version_label": "1.2.0",
  "version_ref": "1.2.0",
  "proxy_label": null,
  "model_label": "Claude Sonnet 4",
  "model_source": "org",
  "runner_name": null,
  "runner_kind": null,
  "agent_scope": "@acme",
  "agent_name": "email-sorter",
  "runOrigin": "platform",
  "contextSnapshot": null,
  "modelCredentialId": null,
  "connection_overrides": null,
  "dependency_overrides": null,
  "user_name": "Pierre",
  "end_user_name": null,
  "api_key_name": null,
  "schedule_name": null,
  "connections_used": null,
  "package_ephemeral": false,
  "file_counts": {
    "input": 0,
    "output": 0
  }
}
{
  "type": "https://docs.appstrate.dev/errors/unauthorized",
  "title": "Unauthorized",
  "status": 401,
  "detail": "Invalid or missing session",
  "code": "unauthorized",
  "request_id": "req_abc123"
}
{
  "type": "https://docs.appstrate.dev/errors/forbidden",
  "title": "Forbidden",
  "status": 403,
  "detail": "Insufficient permissions",
  "code": "forbidden",
  "request_id": "req_abc123"
}
{
  "type": "https://docs.appstrate.dev/errors/not-found",
  "title": "Not Found",
  "status": 404,
  "detail": "Resource not found",
  "code": "not_found",
  "request_id": "req_abc123"
}
{
  "type": "about:blank",
  "title": "Conflict",
  "status": 409,
  "detail": "Run has already completed and cannot be cancelled",
  "code": "conflict",
  "request_id": "req_def456"
}