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

# Cancel a task run

`POST /task-runs/{run_id}/cancel`

Cancels a running or queued task run.

## Path parameters

- `run_id` string, required

## Response `200`

OK

- GetTaskRunResponse — A task run object representing a single execution of a task.
  - `id` string, required — Unique identifier for the task run, prefixed with `trun_`.
  - `object` string, required — Always `task_run`.
  - `status` string, required — Run status: `queued`, `running`, `canceling`, `interaction_required`, `review_required`, `completed`, `canceled`, or `failed`.
  - `result` string, nullable, required — Run result after completion: `success`, `failure`, or `unknown`. Null while running.
  - `task_id` string, required — The task that was executed. Prefixed with `task_`.
  - `trigger_id` string, nullable, required — The trigger that created this run, if any. Prefixed with `trg_`. `null` for runs created directly through the API.
  - `credential_id` string, nullable, required — The credential used for authentication, if any. Prefixed with `cred_`.
  - `session_id` string, nullable, required — The session this run executed within, if any. Prefixed with `sess_`.
  - `agent_id` string, required — The agent that executed this run. Prefixed with `agt_`.
  - `source_id` string, nullable, required — The source this run connected to, if any. Prefixed with `src_`.
  - `runtime_ms` union, required — Execution time in milliseconds.
    - integer
    - string, int32
  - `input` unknown
  - `tokenized` string[], nullable — Names of input fields whose values were tokenized when the run was created. The listed fields are removed from `input`. Returned alongside `input` (only when `include=input` is requested and one or more fields were vaulted); omitted otherwise.
  - `output` unknown, required
  - `storage` TaskRunStorageItem[], nullable — Files captured during the run, each with inline extraction (if any). Returned only when `include=storage` is requested.
    - `id` string, required — Unique identifier for the storage item, prefixed with `stor_`.
    - `object` string, required — Always `storage`.
    - `file_name` string, required — Original file name.
    - `file_type` string, required — MIME type of the file.
    - `file_size` union, required — Size of the file in bytes.
      - integer
      - string, int64
    - `url` string, nullable — Signed URL to download the file. Time-limited.
    - `extraction` unknown
    - `purpose` 'attachment' | 'extraction' | 'output', required — How the file relates to the run: `attachment` (a file you provided as task input for the agent to use), `extraction` (a file you provided as task input that Deck extracts data from directly, skipping the agent), or `output` (a file the agent captured during the run).
    - `created_at` string, date-time, required — When the storage item was created.
  - `storage_deduplicated` TaskRunDeduplicatedFile[], nullable — Files skipped by deduplication during the run. Returned only when `include=storage_deduplicated` is requested and the run's task has `storage.deduplication` enabled; omitted otherwise. An empty array means deduplication ran and no files were skipped.
    - `file_name` string, required — Name of the skipped file as the agent captured it.
    - `duplicate_of` string, required — Storage ID of the surviving item this file matched, prefixed with `stor_`. Fetch `GET /v2/storage/{duplicate_of}` for the original's file name, extraction, and a fresh signed URL. The referenced item is deleted on the normal file retention schedule, after which the ID no longer resolves.
    - `task_run_id` string, required — The task run that originally captured the matched file, prefixed with `trun_`. This is the earlier capture run, not the run this entry appears on.
    - `created_at` string, date-time, required — When the file was skipped.
  - `artifacts` TaskRunArtifactData — Run-level visibility artifacts returned when include=artifacts is requested.
    - `screenshots` TaskRunScreenshot[] — Screenshots captured during the run.
      - `file_name` string, required — Original file name.
      - `file_type` string, required — MIME type of the screenshot.
      - `file_size` union, required — Size of the file in bytes.
        - integer
        - string, int64
      - `url` string, nullable — Signed URL to download the screenshot. Time-limited.
      - `reasoning` string, nullable — AI reasoning at the time of capture, if recorded.
      - `created_at` string, date-time, required — When the screenshot was captured.
  - `errors` TaskRunError[], nullable, required — Error details if the run failed. Same structure as API-level errors.
    - `type` string, required — Error category (e.g. `source`, `auth`, `task`, `rate_limit`). Determines the class of failure.
    - `code` string, required — Machine-readable error code. Use this for programmatic handling.
    - `message` string, required — Human-readable explanation. Do not rely on this for logic — it may change.
    - `field` string, nullable — The input field that caused the error, when applicable.
    - `resolution` string, nullable — Hint for how an agent should recover (auth, docs URL, or backoff).
  - `interaction` unknown, required
  - `created_at` string, date-time, required — ISO 8601 timestamp of when the resource was created.
  - `updated_at` string, date-time, required — ISO 8601 timestamp of when the resource was last updated.
  - `request_id` string, required — Unique identifier for the API request. Include this when contacting support.

## Other responses

- `400` — Bad request — validation error or malformed input.
- `401` — Unauthorized.
- `403` — Forbidden.
- `404` — Not found — the requested resource does not exist.
- `409` — Conflict — the request is valid but cannot be completed in the current state.
- `422` — Unprocessable content — the request body is understood but contains invalid values.
- `429` — Too many requests or session concurrency exceeded. Retry with backoff; honor Retry-After and RateLimit headers when present.
- `500` — Internal server error.

---

[API](https://skmtc.dev/deck/apis/deck-api.md) · [All operations](https://skmtc.dev/deck/apis/deck-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/deck/deck-api/revisions/eba6e2cc9351/schema)
