---
title: "Cancel schedule run"
method: POST
path: "/v1/schedules/{schedule_id}/runs/{run_id}/cancel"
tags: ["Schedules"]
---

# Cancel schedule run

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

## Request

- Base URL: `https://api.sandbase.ai`
- URL: `https://api.sandbase.ai/v1/schedules/{schedule_id}/runs/{run_id}/cancel`
- Auth: one of:
  - HTTP bearer
  - API key in header `X-API-Key`

Request cancellation of a pending Run. Idempotency-Key is required and the body must be {}. A finished Run is returned unchanged (202). While the Run has no Session yet (session_id null) the call returns 409 conflict; while the Run input is still being delivered it returns 409 session_input_pending. Wait and retry with the same Idempotency-Key.

## Headers

- `Idempotency-Key` string, required

## Request body

- EmptyObject

## Response `202`

Cancellation accepted

- AgentRun
  - `id` string, required: Run ID. Treat as opaque.
  - `source_type` 'service' | 'schedule', required
  - `source_id` string, required
  - `source_version` integer, required
  - `agent_id` string, required
  - `agent_version` integer, required
  - `trigger_source` 'manual' | 'scheduled', required
  - `scheduled_at` string, date-time
  - `status` 'pending' | 'succeeded' | 'failed' | 'cancelled' | 'skipped', required: skipped is used when a scheduled tick finds a pending Run.
  - `session_id` string, nullable, required: Session created for this Run; null until the Session exists.
  - `error_code` string: For example session_creation_rejected, execution_failed, schedule_configuration_invalid, concurrency_limit (skipped ticks), or an admission code such as spending_limit_exceeded.
  - `created_at` string, date-time, required
  - `updated_at` string, date-time, required

## Other responses

- `400`: invalid_request (malformed JSON, unknown fields, failed validation, or an unsupported option)
- `401`: unauthorized: missing, malformed, or conflicting API key headers
- `402`: spending_limit_exceeded: API key spending limit or organization balance exhausted
- `403`: insufficient_scope (scoped key) or org_disabled
- `404`: not_found: the resource does not exist in this organization
- `409`: conflict (the Run has no Session yet, or Idempotency-Key reused with a different body) or session_input_pending (Run input still being delivered)
- `502`: executor_rejected or executor_contract_error from the execution layer
- `503`: authorization_unavailable, admission_unavailable, executor_unavailable, storage_unavailable, or internal_error

---

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