---
title: "Cancel script run"
method: POST
path: "/script_runs/{id}/cancel"
tags: ["ScriptRuns"]
---

# Cancel script run

`POST /script_runs/{id}/cancel`

## Request

- Base URL: `https://api.crevio.co/v1`
- URL: `https://api.crevio.co/v1/script_runs/{id}/cancel`
- Auth: API key in header `Authorization`

Cancels a script run that has not started. A running script runs to its end or its timeout (`409 run_not_cancellable`).

## Path parameters

- `id` string, required

## Headers

- `Idempotency-Key` string

## Response `200`

The cancelled run

- ScriptRun
  - `object` string, required
  - `id` string, required
  - `status` 'queued' | 'in_progress' | 'completed' | 'failed' | 'cancelled' | 'timed_out', required
  - `result` unknown, required
  - `result_truncated` boolean, required: The value was too large to return, so `result` holds the start of its JSON text instead.
  - `output` string, nullable, required: What the script printed: its start and end when long, with the cut marked.
  - `error` string, nullable, required
  - `args` string[], required
  - `calls` object[], required: Every tool call the script made, in order: `{role, status, read_only, error_code, approval_id}`. A 202 call did not run and names its approval.
  - `approvals` Approval[], required: What the script's gated calls froze, as each stands now. Approving one runs that call, never the script again.
    - `object` 'approval', required
    - `id` string, required
    - `approval_id` string, required
    - `status` 'draft' | 'pending_approval' | 'approved' | 'executed' | 'failed' | 'denied', required: `pending_approval` waits for a person. It ends `executed` (see `result`), `failed` (see `error`) or `denied` (see `reason`).
    - `kind` 'pipedream' | 'composio' | 'rest' | 'mcp' | 'native' | 'saved_tool' | 'site' | 'vault' | 'elicitation', required
    - `action_type` string, nullable, required
    - `title` string, nullable, required
    - `details` object[], required: What runs, as `{label, value}` pairs: recipients, subject, amounts and the other arguments a person checks.
    - `request` object, nullable, required: An API call's frozen request, `{http_method, path, params}`, with secrets masked. Null for other kinds.
    - `app_slug` string, nullable, required
    - `tool_name` string, nullable, required
    - `result` object, nullable, required
    - `error` string, nullable, required
    - `reason` string, nullable, required
    - `chat_id` string, nullable, required
    - `created_at` string, required
    - `resolved_at` string, nullable, required
  - `pending_approval_ids` string[], required: Approvals still waiting for a decision: POST /approvals/{id}/approve or /deny.
  - `artifacts` Artifact[], required: Files the script wrote to `outputDir`.
    - `object` string, required
    - `id` string, required
    - `filename` string, required
    - `content_type` string, nullable, required
    - `size` integer, required
  - `timeout_seconds` integer, required
  - `started_at` string, nullable, required
  - `completed_at` string, nullable, required
  - `created_at` string, date-time, required

## Other responses

- `400`: Bad request
- `401`: Authentication required
- `403`: Forbidden
- `404`: Resource not found
- `409`: Conflict
- `429`: Rate limit exceeded — 600 requests per minute per owner on the free tier: every API key and OAuth token one person holds on an account shares one budget, and the account's team keys share another. Retry after the number of seconds in `Retry-After`.
- `500`: Internal server error

## Changes

- **2026-12-05** `ccbd8fcbd6d7`: 2 info
  - added the required property `approvals/items/details` to the response with the `200` status
  - added the required property `approvals/items/request` to the response with the `200` status
- **2026-12-04** `6be3ac8d9549`: 1 warning
  - added the new `site` enum value to the `approvals/items/kind` response property for the response status `200`
- **2026-11-15** `56c22ab9b282`: 7 warning, 1 info
  - added the new `idempotency_error` enum value to the `error/type` response property for the response status `400`
  - added the new `idempotency_error` enum value to the `error/type` response property for the response status `401`
  - added the new `idempotency_error` enum value to the `error/type` response property for the response status `403`
  - added the new `idempotency_error` enum value to the `error/type` response property for the response status `404`
  - …4 more
- **2026-11-03** `e3252049784c`: 2 info
  - added the required property `approvals` to the response with the `200` status
  - added the required property `pending_approval_ids` to the response with the `200` status
- **2026-10-23** `bf736a72ee9c`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/crevio/apis/crevio-api-v1/changes/script_runs/:id/cancel/post.md)

---

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