Skip to main content
POST
/
batches
/
{batch_id}
/
cancel
Cancel batch
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

fetch('https://api.phaseo.app/v1/batches/{batch_id}/cancel', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
{
  "id": "<string>",
  "native_batch_id": "<string>",
  "object": "<string>",
  "endpoint": "<string>",
  "errors": {},
  "input_file_id": "<string>",
  "completion_window": "<string>",
  "status": "<string>",
  "progress": 50,
  "polling_url": "<string>",
  "websocket_url": "<string>",
  "cancel_url": "<string>",
  "output_file_id": "<string>",
  "error_file_id": "<string>",
  "created_at": 123,
  "in_progress_at": 123,
  "expires_at": 123,
  "finalizing_at": 123,
  "completed_at": 123,
  "failed_at": 123,
  "expired_at": 123,
  "cancelling_at": 123,
  "cancelled_at": 123,
  "request_counts": {
    "total": 123,
    "completed": 123,
    "failed": 123
  },
  "metadata": {},
  "request_id": "<string>",
  "provider": "<string>",
  "session_id": "<string>",
  "webhook": {
    "url": "<string>",
    "events": [
      "<string>"
    ],
    "has_secret": true,
    "delivery": {
      "total_attempts": 123,
      "delivered_events": 123,
      "delivered_event_types": [
        "video.completed"
      ],
      "pending_retries": 123,
      "next_retry_at": "<string>",
      "last_attempt_at": "<string>",
      "last_response_status": 123,
      "last_delivered_at": "<string>",
      "last_failure_at": "<string>",
      "last_error_message": "<string>"
    },
    "attempts": [
      {
        "id": "<string>",
        "delivery_key": "video.completed",
        "event_type": "video.completed",
        "attempt_number": 123,
        "max_attempts": 123,
        "tried_at": "<string>",
        "delivered_at": "<string>",
        "next_retry_at": "<string>",
        "response_status": 123,
        "error_message": "<string>",
        "response_body_preview": "<string>"
      }
    ]
  },
  "next_webhook_retry_at": "<string>",
  "last_webhook_progress": 123,
  "last_webhook_progress_at": "<string>",
  "last_webhook_dispatched_at": "<string>",
  "finalized_at": "<string>",
  "pricing_lines": [
    {}
  ],
  "billing": {
    "currency": "<string>",
    "billed": true,
    "charged": true,
    "reason": "<string>",
    "reservation_id": "<string>",
    "reservation_status": "<string>",
    "estimated_provider_cost": "<string>",
    "estimated_user_cost": "<string>",
    "settled_provider_cost": "<string>",
    "settled_user_cost": "<string>",
    "estimated_nanos": 123,
    "reserved_nanos": 123,
    "estimation_truncated": true,
    "estimation_sample_size": 123,
    "estimation_total_rows": 123,
    "total_nanos": 123,
    "cost_nanos": 123,
    "cost_usd": 123,
    "finalized_at": "<string>",
    "pricing_breakdown": {}
  }
}
Cancels a gateway-owned batch job. Use the AI Stats id returned by create, list, or status responses. native_batch_id is provider correlation metadata and should not be used in this endpoint unless it is identical to the gateway id. OpenAI batches can be cancelled while they are still active. Completed, failed, cancelled, or expired batches are already terminal and are not sent to the provider again. When cancellation succeeds, AI Stats refreshes and persists the terminal state, emits configured async webhook events, and releases held reservation amounts for voided work.

Authorizations

Authorization
string
header
required

Bearer token authentication

Path Parameters

batch_id
string
required

The ID of the batch to cancel.

Response

Batch status response

id
string
native_batch_id
string | null

Provider-native batch id when it differs from the gateway-owned id.

object
string
endpoint
string
errors
object
input_file_id
string
completion_window
string
status
string
lifecycle_status
enum<string>

Normalized async lifecycle status for polling, websocket, and webhook consumers.

Available options:
pending,
running,
completed,
failed,
cancelled,
expired
progress
integer

Coarse batch completion percentage derived from provider request counts when available. Completed batches report 100.

Required range: 0 <= x <= 100
polling_url
string<uri>
websocket_url
string<uri>

WebSocket URL for subscribing to normalized async job lifecycle updates.

cancel_url
string<uri> | null
output_file_id
string
error_file_id
string
created_at
integer
in_progress_at
integer
expires_at
integer
finalizing_at
integer
completed_at
integer
failed_at
integer
expired_at
integer
cancelling_at
integer
cancelled_at
integer
request_counts
object
metadata
object
request_id
string
provider
string
session_id
string
webhook
object

Sanitized async webhook configuration plus delivery state. Secrets are never returned; has_secret indicates whether signed deliveries are enabled. Signed deliveries include x-ai-stats-signature, x-ai-stats-timestamp, x-ai-stats-event-id, x-ai-stats-event-type, x-ai-stats-delivery-key, x-ai-stats-attempt, and x-ai-stats-max-attempts headers.

next_webhook_retry_at
string | null
last_webhook_progress
number | null
last_webhook_progress_at
string | null
last_webhook_dispatched_at
string | null
finalized_at
string | null
pricing_lines
object[]
billing
object
Last modified on June 11, 2026