# Cancel or retry a generation

> Cancel active work safely and retry eligible failures as new, independently billed generations.

Canonical: https://entirefeed.com/docs/generate/cancel-and-retry

Cancellation and retry have different cost and identity behavior. Read the current generation before choosing either action.

## Cancel active work

`POST /v1/generations/{generation_id}/cancel` requests cancellation for queued or running work. If the generation is already terminal, the endpoint returns its current state. Cancellation does not guarantee a release: final usage depends on whether billable work occurred before cancellation completed.

## Retry only eligible terminal work

Only failed or cancelled generations can be retried. Succeeded and manual-review generations cannot. Retry the latest generation in a retry sequence, and wait for any active retry to finish before starting another.

A retry accepts no request body overrides. It creates a new generation with a new `gen_...` identifier, a new current estimate, and its own balance reservation. Use a stable `Idempotency-Key` for that retry intent.

See [Errors and manual review](/docs/operate/errors-and-manual-review) before retrying an uncertain failure.

## Cancel queued or running work

### cURL

```bash
curl https://api.entirefeed.com/v1/generations/gen_0123456789abcdef0123456789abcdef/cancel \
  -X POST \
  -H "Authorization: Bearer $ENTIREFEED_API_KEY"
```

### TypeScript

```typescript
const response = await fetch("https://api.entirefeed.com/v1/generations/gen_0123456789abcdef0123456789abcdef/cancel", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.ENTIREFEED_API_KEY}`,
  },
});

if (!response.ok) throw new Error(await response.text());
console.log(await response.json());
```

### Python

```python
import os
import requests

response = requests.request(
    "POST",
    "https://api.entirefeed.com/v1/generations/gen_0123456789abcdef0123456789abcdef/cancel",
    headers={"Authorization": f"Bearer {os.environ['ENTIREFEED_API_KEY']}"},
    timeout=30,
)
response.raise_for_status()
print(response.json())
```

Read the returned generation. Cancellation can still produce settled usage when paid work completed before cancellation.

## Retry eligible terminal work

Retry only the latest failed or cancelled generation. A retry accepts no body overrides and creates a new paid generation with its own ID and reservation.

### cURL

```bash
curl https://api.entirefeed.com/v1/generations/gen_0123456789abcdef0123456789abcdef/retry \
  -X POST \
  -H "Authorization: Bearer $ENTIREFEED_API_KEY" \
  -H "Idempotency-Key: retry-product-video-001"
```

### TypeScript

```typescript
const response = await fetch("https://api.entirefeed.com/v1/generations/gen_0123456789abcdef0123456789abcdef/retry", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.ENTIREFEED_API_KEY}`,
    "Idempotency-Key": "retry-product-video-001",
  },
});

if (!response.ok) throw new Error(await response.text());
console.log(await response.json());
```

### Python

```python
import os
import requests

response = requests.request(
    "POST",
    "https://api.entirefeed.com/v1/generations/gen_0123456789abcdef0123456789abcdef/retry",
    headers={"Authorization": f"Bearer {os.environ['ENTIREFEED_API_KEY']}", "Idempotency-Key": "retry-product-video-001"},
    timeout=30,
)
response.raise_for_status()
print(response.json())
```

```json
{
  "id": "gen_fedcba9876543210fedcba9876543210",
  "object": "generation",
  "status": "queued",
  "model": "seedance-2",
  "task": "video.create",
  "created_at": "2026-07-12T09:10:00Z",
  "estimated_cost": {
    "amount_usd": "1.20"
  },
  "links": {
    "self": "https://api.entirefeed.com/v1/generations/gen_fedcba9876543210fedcba9876543210"
  }
}
```
