> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pipellm.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Cancel a task

> Cancel an asynchronous task that has not finished.

Stops a task that is still `pending` or `processing`. A task that already reached a
terminal state cannot be cancelled.

<Info>
  Video created through [`POST /v2/videos`](/api-reference/video/create) is cancelled
  with `DELETE /v2/videos/{id}` instead.
</Info>

<ParamField path="task_id" type="string" required>
  Task ID, as returned when the task was created.
</ParamField>

<RequestExample>
  ```bash cURL theme={"dark"}
  curl -X POST https://api.pipellm.ai/v1/tasks/gen-1732891234-abc123xyz/cancel \
    -H "Authorization: Bearer $PIPELLM_API_KEY"
  ```
</RequestExample>

<ResponseExample>
  ```json theme={"dark"}
  {
    "id": "gen-1732891234-abc123xyz",
    "status": "cancelled",
    "type": "video_generation",
    "model": "seedance-2-0-mini",
    "created_at": "2026-09-17T08:14:02Z"
  }
  ```
</ResponseExample>

The response is the same task object returned by
[`GET /v1/tasks/{task_id}`](/api-reference/tasks/get), with `status` set to `cancelled`.

## Billing

Cancelling does not refund work the upstream provider already performed. For video, the
quote is taken when the task is created — see [Pricing](/api-reference/model-pricing).

## Errors

Same envelope as [Errors](/api-reference/errors).

<AccordionGroup>
  <Accordion title="404 not_found">
    Unknown task ID, or a task belonging to another account.
  </Accordion>

  <Accordion title="409 invalid_request_error">
    The task already reached `completed`, `failed`, or `cancelled`.
  </Accordion>
</AccordionGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.