# Cancel a music generation job

Request cooperative cancellation of a generation job. The worker stops at its next safe checkpoint.

Idempotent — cancelling an already-cancelled or terminal job (`succeeded`, `failed`, `cancelled`, `refused`) is a no-op and returns the job's current state unchanged. Only active (`queued` or `running`) jobs are flagged for cancellation. Scoped to the caller's organization and user (IDOR-safe).

## Path parameters

**`organization_id`** string required

The organization the job is scoped to. The caller must belong to it.

**`job_id`** string required

Id of the generation job (`mgen_`-prefixed).

## Returns

The music generation job object in its current state.

**`id`** string · Job id (`mgen_`-prefixed).

**`status`** string · One of `queued`, `running`, `succeeded`, `failed`, `cancelled`, `refused`.

**`progress`** integer · Generation progress, 0–100.

**`engine`** string · Internal engine key the job targets.

**`mode`** string · `creation` or `focus`.

**`created_at`** string · When the job was created (UTC).

**`result_track_id`** string · Id of the produced track once succeeded.

**`error_message`** string · User-safe error description when the job failed.

**`refusal_reason`** string · Reason the request was refused, when `status` is `refused`.

**`playback_url`** string · Short-TTL signed URL for the master audio, present only on a succeeded job.

**`track`** object · Embedded track summary, present only on a succeeded job.

Example

```bash cURL
curl -X POST "https://api.aitronos.com/v1/music/org_abc123/generations/mgen_2f8b1c4e9a7d/cancel" \
  -H "X-API-Key: $FREDDY_API_KEY"
```


```python Python SDK
from aitronos import Aitronos  # pip install aitronos-sdk

client = Aitronos(api_key="your-api-key")

job = client.post("/v1/music/org_abc123/generations/mgen_2f8b1c4e9a7d/cancel")
print(job["status"])
```


```python Python
import os
import requests

api_key = os.environ["FREDDY_API_KEY"]

response = requests.post(
    "https://api.aitronos.com/v1/music/org_abc123/generations/mgen_2f8b1c4e9a7d/cancel",
    headers={"X-API-Key": api_key},
)
print(response.json()["status"])
```


```javascript JavaScript
const apiKey = process.env.FREDDY_API_KEY;

const response = await fetch(
  'https://api.aitronos.com/v1/music/org_abc123/generations/mgen_2f8b1c4e9a7d/cancel',
  { method: 'POST', headers: { 'X-API-Key': apiKey } }
);

const job = await response.json();
console.log(job.status);
```

**Response:**


```json 200 OK
{
  "id": "mgen_2f8b1c4e9a7d",
  "status": "cancelled",
  "progress": 42,
  "engine": "studio",
  "mode": "creation",
  "created_at": "2026-06-28T10:30:00Z",
  "result_track_id": null,
  "error_message": null,
  "refusal_reason": null,
  "playback_url": null,
  "track": null
}
```

Errors

```json 401 Unauthorized
{
  "success": false,
  "error": {
    "code": "AUTHENTICATION_REQUIRED",
    "message": "Authentication required. Please provide a valid API key.",
    "system_message": "Missing or invalid authorization header",
    "type": "authentication_error",
    "status": 401,
    "details": {},
    "trace_id": "req_abc123xyz",
    "timestamp": "2026-06-28T10:30:00Z"
  }
}
```


```json 404 Not Found
{
  "success": false,
  "error": {
    "code": "RESOURCE_NOT_FOUND",
    "message": "The requested resource could not be found.",
    "system_message": "Music generation job not found",
    "type": "client_error",
    "status": 404,
    "details": { "job_id": "mgen_2f8b1c4e9a7d" },
    "trace_id": "req_jkl012mno",
    "timestamp": "2026-06-28T10:30:00Z"
  }
}
```

## Related Resources

- [Create a generation job](/docs/api-reference/music/create-generation)
- [Get a generation job](/docs/api-reference/music/get-generation)
- [List generation jobs](/docs/api-reference/music/list-generations)