---
title: "Cancel batch"
method: POST
path: "/batches/{batch_id}/cancel"
tags: ["batches"]
---

# Cancel batch

`POST /batches/{batch_id}/cancel`

Cancel an in-progress batch.

Pending requests will not be processed. Requests already in progress will complete. The batch status will transition to `cancelling` then `cancelled`.

## Path parameters

- `batch_id` string, required

## Response `200`

Cancellation initiated. The batch will finish processing in-flight requests.

- BatchResponse — Batch object response (OpenAI-compatible)
  - `analytics` BatchAnalytics — Aggregated analytics metrics for batch requests
    - `avg_duration_ms` number, double, nullable — Average request duration in milliseconds
    - `avg_ttfb_ms` number, double, nullable — Average time to first byte in milliseconds
    - `total_completion_tokens` integer, required — Total completion tokens across all requests
    - `total_cost` string, nullable — Total BILLED cost in credits (if pricing is available) — what the batch actually cost after prompt-cache discounts, matching the credits ledger / transactions page. (Until 2026-07 this field erroneously reported the un-discounted list price; see `total_list_cost` for that figure.)
    - `total_list_cost` string, nullable — Un-discounted list price of the same requests (no prompt-cache discounts applied). `total_list_cost - total_cost` = what caching saved on this batch. Additive field — clients that don't know it simply ignore it.
    - `total_prompt_tokens` integer, required — Total prompt tokens across all requests
    - `total_reasoning_tokens` integer, nullable — Total reasoning tokens across all requests
    - `total_requests` integer, required — Total number of requests with analytics data
    - `total_tokens` integer, required — Total tokens (prompt + completion) across all requests
  - `cancelled_at` integer, nullable
  - `cancelling_at` integer, nullable
  - `completed_at` integer, nullable
  - `completion_window` string, required — The requested processing window, or `"background"` for no-SLA spare-capacity processing.
  - `created_at` integer, required
  - `dwext` BatchDwExtResponse — Doubleword extension fields on batch responses. Returned as `"dwext": { ... }` at the top level of batch objects. Only present when there is Doubleword-specific data to surface.
    - `source` string, nullable — How the batch was created: "api", "frontend", or "sync".
    - `source_file` string, nullable — Original external file key (when source = "sync").
    - `source_id` string, nullable — Source connection ID (when source = "sync").
    - `source_name` string, nullable — Name of the source connection (when source = "sync").
    - `sync_id` string, nullable — Sync operation ID that created this batch (when source = "sync").
  - `endpoint` string, required
  - `error_file_id` string, nullable
  - `errors` BatchErrors — Batch-level errors
    - `data` BatchError[], required — Array of error details
      - `code` string, nullable — An error code identifying the error type
      - `line` integer, nullable — The line number of the input file where the error occurred, if applicable
      - `message` string, required — A human-readable message providing more details about the error
      - `param` string, nullable — The name of the parameter that caused the error, if applicable
  - `expired_at` integer, nullable
  - `expires_at` integer, nullable
  - `failed_at` integer, nullable
  - `finalizing_at` integer, nullable
  - `id` string, required
  - `in_progress_at` integer, nullable
  - `input_file_id` string, required
  - `metadata` object, nullable
  - `model` string, nullable — Model alias used by this batch's requests, or `"mixed"` when the input file spans multiple models. Cached on the batch at creation time; absent on batches created before this field existed.
  - `object` 'batch', required — Object type - always "batch"
  - `output_file_id` string, nullable
  - `request_counts` RequestCounts, required — Request counts for a batch
    - `completed` integer, required
    - `failed` integer, required
    - `total` integer, required
  - `status` string, required

## Other responses

- `404` — Batch not found or you don't have access to it.
- `500` — An unexpected error occurred. Retry the request or contact support if the issue persists.

---

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