# Cancel an audiobook (/reference/api/audiobooks/cancel-audiobook)

```json
[
  {
    "method": "POST",
    "path": "/api/v1/documents/{id}/audiobooks/{audiobookId}/cancel",
    "operationId": "cancelAudiobook",
    "tags": [
      "Audiobooks"
    ],
    "summary": "Cancel an audiobook",
    "x-required-scope": "audio:generate",
    "security": [
      {
        "oauth": [
          "audio:generate"
        ]
      },
      {
        "sessionCookie": []
      },
      {
        "secureSessionCookie": []
      }
    ],
    "responses": {
      "200": {
        "description": "Cancelled state, which later reads also report. Chapter cancel is rejected.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Audiobook"
            }
          }
        }
      },
      "429": {
        "description": "Compute admission or usage is limited.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        },
        "headers": {
          "Retry-After": {
            "description": "Seconds until retry.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        }
      },
      "default": {
        "description": "Request failed. Inspect error.code and error.message.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "description": "Formats and speeds of the same settings share one generation run, so stopping it also cancels the other whole-book requests that share it. POST to the collection with the same settings resumes from the cached audio."
  }
]
```

## Components

```json
{
  "#/components/schemas/Audiobook": {
    "type": "object",
    "properties": {
      "id": {
        "type": "string"
      },
      "documentId": {
        "type": "string",
        "pattern": "^[a-f0-9]{64}$"
      },
      "status": {
        "type": "string",
        "enum": [
          "idle",
          "preparing",
          "queued",
          "generating",
          "complete",
          "stopped",
          "usage_limited",
          "interrupted",
          "failed",
          "building",
          "waiting",
          "ready",
          "cancelled"
        ],
        "description": "cancelled: someone stopped the request. A POST with the same settings resumes it from the cached audio."
      },
      "progress": {
        "type": [
          "number",
          "null"
        ],
        "minimum": 0,
        "maximum": 1
      },
      "provider": {
        "type": "string",
        "description": "Speech provider, as a request names it."
      },
      "model": {
        "type": "string"
      },
      "voice": {
        "type": "string"
      },
      "modelSpeed": {
        "type": "number",
        "description": "The rate the model speaks at; speed is the finished file's playback speed."
      },
      "requestedAt": {
        "type": [
          "string",
          "null"
        ],
        "format": "date-time",
        "description": "When it was last requested or cancelled; null when nobody has asked for it."
      },
      "format": {
        "type": "string",
        "enum": [
          "mp3",
          "m4b"
        ]
      },
      "speed": {
        "type": "number"
      },
      "chapter": {
        "type": [
          "integer",
          "null"
        ]
      },
      "downloadUrl": {
        "type": [
          "string",
          "null"
        ]
      },
      "filename": {
        "type": [
          "string",
          "null"
        ]
      },
      "webUrl": {
        "type": "string",
        "format": "uri"
      },
      "webDownloadUrl": {
        "type": [
          "string",
          "null"
        ],
        "format": "uri"
      },
      "retryAfterMs": {
        "type": [
          "number",
          "null"
        ]
      },
      "generation": {
        "type": "object",
        "properties": {
          "state": {
            "type": "string",
            "enum": [
              "idle",
              "preparing",
              "queued",
              "generating",
              "complete",
              "stopped",
              "usage_limited",
              "interrupted",
              "failed"
            ]
          },
          "operationId": {
            "type": [
              "string",
              "null"
            ]
          },
          "issue": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "code": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "message": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "code",
                  "message"
                ]
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "state",
          "operationId",
          "issue"
        ]
      },
      "segments": {
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "plannedSegments": {
                "type": "integer"
              },
              "completedSegments": {
                "type": "integer"
              },
              "skippedSegments": {
                "type": "integer"
              },
              "lastSkipIssue": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "code": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "message": {
                        "type": [
                          "string",
                          "null"
                        ]
                      }
                    },
                    "required": [
                      "code",
                      "message"
                    ]
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "chapters": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "index": {
                      "type": "integer"
                    },
                    "title": {
                      "type": "string"
                    },
                    "spineHref": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "page": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "plannedSegments": {
                      "type": "integer"
                    },
                    "completedSegments": {
                      "type": "integer"
                    },
                    "skippedSegments": {
                      "type": "integer"
                    },
                    "generatingSegments": {
                      "type": "integer"
                    },
                    "durationMs": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "index",
                    "title",
                    "spineHref",
                    "page",
                    "plannedSegments",
                    "completedSegments",
                    "skippedSegments",
                    "generatingSegments",
                    "durationMs"
                  ]
                }
              }
            },
            "required": [
              "plannedSegments",
              "completedSegments",
              "skippedSegments",
              "lastSkipIssue",
              "chapters"
            ]
          },
          {
            "type": "null"
          }
        ]
      },
      "artifact": {
        "type": "object",
        "properties": {
          "state": {
            "type": "string",
            "enum": [
              "none",
              "building",
              "waiting",
              "ready",
              "stale",
              "failed"
            ]
          },
          "operationId": {
            "type": [
              "string",
              "null"
            ]
          },
          "issue": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "code": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "message": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "code",
                  "message"
                ]
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "state",
          "operationId",
          "issue"
        ]
      }
    },
    "required": [
      "id",
      "documentId",
      "status",
      "progress",
      "provider",
      "model",
      "voice",
      "modelSpeed",
      "requestedAt",
      "format",
      "speed",
      "chapter",
      "downloadUrl",
      "filename",
      "webUrl",
      "webDownloadUrl",
      "retryAfterMs",
      "generation",
      "segments",
      "artifact"
    ]
  },
  "#/components/schemas/Error": {
    "type": "object",
    "properties": {
      "error": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "retryAfterMs": {
            "type": "number",
            "minimum": 0
          }
        },
        "required": [
          "code",
          "message"
        ]
      }
    },
    "required": [
      "error"
    ]
  }
}
```