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

# Cancel video

> Cancel a video job before generation starts

Cancels a job that is still waiting to start. A cancelled job is never billed.

A job is sent for generation as soon as it is created, so a cancel usually succeeds only right after the create. Once generation has started, cancelling returns `409` with `code: "video_not_cancellable"`, even if the job still reports `queued`. The job then runs to the end and is billed if it completes. To discard its video, [delete](https://docs.inworld.ai/api-reference/videoAPI/delete-video.md) the job once it has finished.

## API reference

**Endpoint:** `POST https://api.inworld.ai/v1/videos/{video_id}/cancel`

### Authorization

- `Authorization` (string; required) — Your [authentication](https://docs.inworld.ai/api-reference/introduction.md) credentials. For Basic authentication, populate `Basic $INWORLD_API_KEY`.

### Path parameters

- `video_id` (string; required) — The id of a video job your workspace created (`video_` followed by 32 hexadecimal characters).

### Response

Status: `200`. Content type: `application/json`.

- `id` (string; required) — The job id.
- `object` (enum<string>; required; options: "video")
- `model` (string; required)
- `status` (enum<string>; required; options: "queued", "in_progress", "completed", "failed", "cancelled") — `queued`: accepted; waiting for or being submitted for generation, so cancellation may already be unavailable. `in_progress`: generating. `completed`: generation succeeded; download available until `expires_at`. `failed`: see `error`. `cancelled`: cancelled before generation started. The last three are terminal.
- `created_at` (integer; required) — When the job was created, in Unix seconds.
- `completed_at` (integer) — When the video finished, in Unix seconds. Present once `status` is `completed`.
- `expires_at` (integer) — Until when the video can be downloaded, in Unix seconds: 7 days after it finished. Present only when `status` is `completed`.
- `seconds` (integer; required) — The requested clip length, with the model's default filled in.
- `resolution` (string; required) — The requested resolution, with the model's default filled in.
- `aspect_ratio` (string; required) — The requested aspect ratio, with the model's default filled in.
- `operation` (string) — The job's [long-running operation](https://google.aip.dev/151). Poll it with `GET https://api.inworld.ai/lro/v1alpha/{operation}` as an alternative to retrieving the job. The operation reports progress and the outcome but never the download link. See [Poll the operation instead](https://docs.inworld.ai/router/video-generation.md#poll-the-operation-instead).
- `error` (object) — Why the job failed. Present only when `status` is `failed`.
  - `code` (enum<string>; options: "content_filtered", "invalid_request", "generation_failed", "generation_timeout") — `content_filtered`: the prompt or the generated video was blocked by the model provider's content policy. `invalid_request`: the model provider rejected the request. `generation_failed`: generation failed for another reason. `generation_timeout`: generation did not finish in time.
  - `message` (string)
- `output` (object) — The finished video. Returned only by [Retrieve video](https://docs.inworld.ai/api-reference/videoAPI/retrieve-video.md), only while `status` is `completed` and before `expires_at`.
  - `videos` (object[])
    - `index` (integer)
    - `content_type` (string)
    - `bytes` (integer) — File size in bytes.
    - `url` (string) — A signed HTTPS link to the MP4. Anyone with the link can download the file until `url_expires_at`, so treat it like a secret.
    - `url_expires_at` (integer) — When `url` stops working, in Unix seconds: up to an hour after the request, and never after the job's `expires_at`.

### Response examples

#### 200: default_response

```json
{
  "id": "video_8f14e45fceea167a5a36dedd4bea2543",
  "object": "video",
  "model": "alibaba/wan-3.0",
  "status": "queued",
  "created_at": 0,
  "completed_at": 0,
  "expires_at": 0,
  "seconds": 0,
  "resolution": "720p",
  "aspect_ratio": "16:9",
  "operation": "workspaces/my-workspace/videoGenerationJobs/video_8f14e45fceea167a5a36dedd4bea2543/operations/1790000000000-a1b2c3",
  "error": {
    "code": "content_filtered",
    "message": "The request or its output was blocked by the provider's content policy."
  },
  "output": {
    "videos": [
      {
        "index": 0,
        "content_type": "video/mp4",
        "bytes": 0,
        "url": "string",
        "url_expires_at": 0
      }
    ]
  }
}
```

#### 401: default_response

```json
"Unauthorized"
```

#### 403: default_response

```json
"Forbidden"
```

#### 404: default_response

```json
{
  "error": {
    "message": "seconds must be an integer from 2 to 30",
    "type": "invalid_request_error",
    "code": "string",
    "param": "seconds"
  }
}
```

#### 409: default_response

```json
{
  "error": {
    "message": "seconds must be an integer from 2 to 30",
    "type": "invalid_request_error",
    "code": "string",
    "param": "seconds"
  }
}
```

#### 429: default_response

```json
"Rate limit exceeded"
```

#### 500: default_response

```json
{
  "error": {
    "message": "seconds must be an integer from 2 to 30",
    "type": "invalid_request_error",
    "code": "string",
    "param": "seconds"
  }
}
```

#### 503: default_response

```json
{
  "error": {
    "message": "seconds must be an integer from 2 to 30",
    "type": "invalid_request_error",
    "code": "string",
    "param": "seconds"
  }
}
```

### Code examples

#### cURL

```bash
curl -X POST 'https://api.inworld.ai/v1/videos/video_8f14e45fceea167a5a36dedd4bea2543/cancel' \
  -H "Authorization: Basic $INWORLD_API_KEY"
```

#### Python

```python
import requests

url = "https://api.inworld.ai/v1/videos/%7Bvideo_id%7D/cancel"
headers = {
  "Authorization": "<api_key>"
}

response = requests.request("POST", url, headers=headers)

print(response.text)
```

#### JavaScript

```javascript
const options = {method: 'POST', headers: {"Authorization":"<api_key>"}};

fetch('https://api.inworld.ai/v1/videos/%7Bvideo_id%7D/cancel', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));
```
