Skip to main content
POST
Cancel a batch

Overview

Moves a validating or in_progress batch to cancelling, then cancelled once in-flight requests drain. Requests that already completed stay in the output file and are billed; the rest are written to the error file as batch_cancelled. Cancelling a terminal batch returns 400.

Authorizations

Authorization
string
header
required

Morph API key, passed as Authorization: Bearer sk-.... Create keys at https://www.morphllm.com/dashboard/api-keys.

Path Parameters

batch_id
string
required

Identifies the batch to cancel. The batch_ prefixed id of a batch that is still validating or in_progress.

Example:

"batch_5f4e3d2c-1b0a-4f9e-8d7c-6b5a4f3e2d1c"

Response

The batch, now cancelling (or already terminal if it finished first).

A batch and where it is in its lifecycle.

id
string
required

Batch identifier, batch_ prefixed.

Example:

"batch_5f4e3d2c-1b0a-4f9e-8d7c-6b5a4f3e2d1c"

object
string
required

Object type, always batch.

Example:

"batch"

endpoint
string
required

The endpoint every line targets. Always /v1/chat/completions.

Example:

"/v1/chat/completions"

input_file_id
string
required

The file the batch reads its requests from.

Example:

"file_9c2c1c3e-5b6a-4f0e-8d0f-2a1b3c4d5e6f"

completion_window
string
required

Always 24h. Requests still queued when the window closes are written to the error file as batch_expired.

Example:

"24h"

metadata
object | null
required

The key-value pairs you attached at creation, or null.

Example:
created_at
integer
required

Unix timestamp (seconds) for when the batch was created.

Example:

1780000000

status
enum<string>
required

Lifecycle state. completed, failed, expired, and cancelled are terminal. expired and cancelled batches still expose partial output.

Available options:
validating,
in_progress,
finalizing,
completed,
failed,
expired,
cancelling,
cancelled
Example:

"in_progress"

output_file_id
string | null
required

File holding one BatchOutputLine per request the model answered. Set once the batch is terminal; null before that and when nothing completed.

Example:

null

error_file_id
string | null
required

File holding one BatchErrorLine per request that never got a model response. Set once the batch is terminal; null before that and when nothing failed.

Example:

null

in_progress_at
integer | null
required

Unix timestamp (seconds) for when processing started. null until it happens.

Example:

1780000012

finalizing_at
integer | null
required

Unix timestamp (seconds) for when output files started being written. null until it happens.

Example:

null

completed_at
integer | null
required

Unix timestamp (seconds) for when the batch completed. null until it happens.

Example:

null

failed_at
integer | null
required

Unix timestamp (seconds) for when the batch failed. null until it happens.

Example:

null

expired_at
integer | null
required

Unix timestamp (seconds) for when the batch expired. null until it happens.

Example:

null

expires_at
integer | null
required

Unix timestamp (seconds) for when the completion window closes. null until it happens.

Example:

1780086400

cancelling_at
integer | null
required

Unix timestamp (seconds) for when cancellation was requested. null until it happens.

Example:

null

cancelled_at
integer | null
required

Unix timestamp (seconds) for when cancellation finished. null until it happens.

Example:

null

request_counts
object
required

Progress counters. Advance while the batch is in_progress; final once it is terminal.

Example:
errors
object | null
required

Why the batch failed validation, or null.

Example:

null

usage
object | null
required

Token totals so far, or null before any request has completed.

Example:
model
string

The model the batch runs on, once validation has read it from the input file.

Example:

"morph-glm53flash"