---
title: "Cancel a music generation"
method: POST
path: "/api/v1/music-generations/{id}/cancel"
tags: ["Music"]
---

# Cancel a music generation

`POST /api/v1/music-generations/{id}/cancel`

## Request

- Base URL: `https://your-deployment.example.com`
- URL: `https://your-deployment.example.com/api/v1/music-generations/{id}/cancel`
- Auth: one of:
  - HTTP bearer
  - API key in header `x-api-key`

Requests cancellation and returns the job. A job still `pending` (waiting to start, or to retry) moves to `cancelled` shortly after and its reserved credits are returned. The provider renders a song in one call that cannot be interrupted and is billed once it starts, so a `running` job cannot be cancelled: the request is refused with a 409 (`not_cancellable`), and the job runs to its end, charged if the song is produced. A finished job is returned unchanged.

## Path parameters

- `id` string, required

## Response `200`

The job after the cancel request.

- CancelMusicGenerationResponse200
  - `id` string, required
  - `object` 'music_generation', required
  - `state` 'pending' | 'running' | 'storing' | 'succeeded' | 'failed' | 'blocked' | 'cancelled', required
  - `model` string, required
  - `prompt` string, required
  - `lyrics` string, nullable, required: The lyrics you sent, or null.
  - `instrumental` boolean, required
  - `duration_seconds` number, required: The length requested (the model default when omitted).
  - `source` 'api' | 'studio' | 'agent', required
  - `error` object, nullable, required
    - `code` 'content_blocked' | 'provider_timeout' | 'provider_error' | 'region_unavailable' | 'output_too_large' | 'cancelled', required
    - `message` string, required
  - `output` object, nullable, required
    - `availability` 'ready' | 'pending_scan' | 'unavailable', required: `ready`: url is set. `pending_scan`: the saved file is still being scanned; re-fetch the job until it changes (self-hosted installs can stay here for up to ~30 minutes). `unavailable`: the file was blocked by the scan or deleted and url will never be set; stop polling.
    - `url` string, nullable, required: Signed download URL, valid until expires_at; re-fetch the job for a fresh one. Set only when availability is `ready`, otherwise null.
    - `expires_at` string, nullable, required: ISO 8601. When url stops working; null whenever url is.
    - `content_type` string, required
    - `duration_seconds` number, required: The length of the song produced, which can differ from the request.
    - `lyrics` string, nullable, required: What the model sang, as plain lines; null for instrumental output or when the provider does not report it.
    - `file_id` string, nullable, required: The Files entry, or null when the song was stored outside Files.
  - `credits` object, required
    - `reserved` number, nullable, required
    - `settled` number, nullable, required
  - `created_at` string, required
  - `updated_at` string, required

## Other responses

- `401`: Missing or invalid credentials.
- `403`: The API key lacks the `ai:generate` scope.
- `404`: No music generation with that id was requested by the caller (a malformed id is also a 404).
- `405`: The path does not serve this HTTP method.
- `409`: The song is already rendering (`running`); `errorCode` is `not_cancellable`.
- `422`: Request failed validation.
- `429`: Per-user rate limit exceeded.

---

[API](https://skmtc.dev/bike4mind/apis/bike4mind-api.md) · [All operations](https://skmtc.dev/bike4mind/apis/bike4mind-api/llms.txt) · [OpenAPI document](https://skmtc.dev/bike4mind/apis/bike4mind-api/revisions/0de0bdb0d113?raw)
