---
title: "Cancel an extraction"
method: POST
path: "/extractions/{extraction_id}/cancel"
tags: ["Extractions"]
---

# Cancel an extraction

`POST /extractions/{extraction_id}/cancel`

## Request

- Base URL: `https://api.invoicedataextraction.com/v1`
- URL: `https://api.invoicedataextraction.com/v1/extractions/{extraction_id}/cancel`
- Auth: HTTP bearer

Stops an extraction that is queued or processing. The request is recorded at once and
the extraction stops at its next opportunity; wait for it with `getExtraction` until its
status is `cancelled`, whose `credits_deducted` covers the work done. An extraction that
was about to finish may complete instead. The request has no body. Idempotent: a repeat
returns the same result and records nothing new.

Rate limit: 30 requests per minute per API key.

## Path parameters

- `extraction_id` string, uuid, required

## Query parameters

- `scope` 'own' | 'team'

## Response `200`

While the extraction is still processing, confirmation that the request was recorded; once it has been cancelled, the cancelled status as `getExtraction` returns it.

- union
  - CancellationRequestedResponse
    - `success` true, required
    - `extraction_id` string, uuid, required
    - `status` 'processing', required
    - `cancellation_requested` true, required
    - `cancel_requested_at` string, date-time, required: When the request was first recorded.
  - ExtractionCancelled: No output is produced; `credits_deducted` covers the work done before the extraction stopped.
    - `success` true, required
    - `status` 'cancelled', required
    - `extraction_id` string, uuid, required
    - `credits_deducted` integer, nullable, required
    - `cancellation_reason` 'user' | 'unanswered' | 'answers_rejected', required: `user`: cancelled from the dashboard or with `cancelExtraction`. `unanswered`: a question was not answered by `answer_by`. `answers_rejected`: three answers were refused.
    - `credits_balance` integer, required
    - `credits_reserved` integer, required

## Other responses

- `400`: `INVALID_INPUT`: the request does not match the contract; `details.issues` lists each problem with its `path`.
- `401`: `UNAUTHENTICATED`, `API_KEY_EXPIRED` or `API_KEY_REVOKED`.
- `403`: `FORBIDDEN`: `scope=team` from a caller who is not a team admin.
- `404`: `EXTRACTION_NOT_FOUND`: no extraction with this id within the caller's scope.
- `409`: `EXTRACTION_NOT_CANCELLABLE`: already completed or failed; `details.status` says which.
- `429`: `RATE_LIMITED`: wait `details.retry_after_seconds` (also the `Retry-After` header), then retry.
- `500`: `INTERNAL_ERROR`: retry after a short delay.

---

[API](https://skmtc.dev/invoicedataextraction/apis/invoice-data-extraction-api.md) · [All operations](https://skmtc.dev/invoicedataextraction/apis/invoice-data-extraction-api/llms.txt) · [OpenAPI document](https://skmtc.dev/invoicedataextraction/apis/invoice-data-extraction-api/revisions/16d920350483?raw)
