---
title: "Cancel a run"
method: POST
path: "/v1/runs/{run_id}/cancel"
tags: ["runs"]
---

# Cancel a run

`POST /v1/runs/{run_id}/cancel`

## Request

- Base URL: `https://coasty.ai`
- URL: `https://coasty.ai/v1/runs/{run_id}/cancel`
- Auth: one of:
  - API key in header `X-API-Key`
  - HTTP bearer
- TypeScript: <https://skmtc.dev/coasty/apis/coasty-public-api/docs/v1/runs/:run_id/cancel/post.ts> (a function with typed inputs; its response is checked against the schema)

Scope: `runs:write`. Free. Cancels an in-flight run.

## Response `200`

The cancelled run.

- RunResponse
  - `id` string, required
  - `object` 'agent.run', required
  - `status` 'queued' | 'running' | 'awaiting_human' | 'succeeded' | 'failed' | 'cancelled' | 'timed_out', required
  - `machine_id` string, nullable
  - `machine` object, nullable
    - `mode` 'automatic'
    - `status` 'provisioning' | 'starting' | 'reconciling' | 'ready' | 'terminated' | 'cleanup_failed': Lifecycle of the ephemeral machine Coasty created for this run. `starting` means the provider handle and billing record are durable but the desktop may still be booting; execution readiness is verified separately before the agent is allowed to start. `reconciling` means a provisioning outcome is being recovered from the provider journal, and the run keeps its lease while that resolves. `cleanup_failed` means the run reached a terminal outcome but teardown did not confirm.
    - `id` string, nullable
    - `cleanup` 'always'
    - `cleanup_status` 'pending' | 'terminating' | 'retrying' | 'terminated'
    - `error` object
  - `task` string
  - `cua_version` string
  - `instructions` string, nullable
  - `max_steps` integer
  - `deadline_seconds` integer: EFFECTIVE wall-clock budget after the server applied its ceiling. Echoed back so a clamp is never silent: request 86400 against a lower server ceiling and you see the value the run is actually held to, instead of discovering it as a surprise DEADLINE_EXCEEDED.
  - `awaiting_human_timeout_seconds` integer: EFFECTIVE awaiting-human timeout after the server applied its ceiling, echoed back for the same reason as deadline_seconds.
  - `on_awaiting_human` string
  - `steps_completed` integer
  - `credits_charged` integer
  - `cost_cents` integer
  - `result` object, nullable: Terminal outcome envelope: `passed` (boolean), `status`, `summary`, `usage`, and `verdict` only when a verifier pass ran. `summary` is the LAST 2000 characters of the trajectory, so it carries the agent's final answer; it is not the full trajectory and there is no `output` field. To read a complete trajectory, or a final answer you intend to parse, use GET /v1/runs/{run_id}/log.
  - `error` object, nullable
  - `awaiting_human_reason` string, nullable
  - `metadata` object, nullable
  - `llm` RunLlmInfo: Credential-free BYOK attribution returned by agent runs and workflow runs. Only these allowlisted fields are public.
    - `provider` 'anthropic' | 'openai', required
    - `model` string, required
    - `key_fingerprint` string, required
    - `key_source` 'header' | 'stored', required
    - `key_scrubbed` boolean, required
  - `webhook_url` string, nullable: Lifecycle callback destination. Agent Run terminal callbacks are transactionally queued in a durable outbox and delivered at least once, with at most 3 durably recorded delivery attempts. A crash after HTTP send but before durable acknowledgement can add duplicate physical sends. Stable Coasty-Delivery equals body id and logical delivered_at survives retries; receivers must deduplicate it. The non-terminal awaiting-human callback is best-effort in-process, can be missed on a worker failure, and uses (run.id, event, run.awaiting_human_since) for deduplication. GET the run for authoritative state.
  - `webhook_secret` string, nullable: Returned by create and its exact bounded Idempotency-Key replay; null on get/list. The pinned per-run secret is encrypted at rest through delivery/replay recovery and later scrubbed. Verify raw-body deliveries with HMAC-SHA256 before accepting the Coasty-Delivery deduplication key.
  - `created_at` string, nullable
  - `started_at` string, nullable
  - `awaiting_human_since` string, nullable
  - `finished_at` string, nullable
  - `request_id` string, nullable

## Other responses

- `400`: Invalid request body or parameters.
- `401`: Missing, invalid, or revoked API key. Pass `X-API-Key: sk-coasty-live-...` (or test).
- `403`: API key lacks the required scope or tier-feature is unavailable on the caller's plan.
- `404`: Resource not found in this key's namespace.
- `409`: The resource state conflicts with this operation.
- `413`: The request body exceeds the endpoint limit.
- `422`: The JSON shape is valid but one or more values violate the endpoint contract.
- `429`: Rate or concurrency limit exceeded.
- `500`: Unexpected server error. Retry with exponential backoff.
- `502`: An upstream dependency returned an invalid response.
- `503`: A required service is temporarily unavailable.
- `504`: An upstream dependency timed out.

---

[API](https://skmtc.dev/coasty/apis/coasty-public-api.md) - [All operations](https://skmtc.dev/coasty/apis/coasty-public-api/llms.txt) - [OpenAPI document](https://skmtc.dev/coasty/apis/coasty-public-api/revisions/f50d93b0d8a1?raw)
