> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xquik.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Cancel a Twitter extraction job with the Xquik API

> Cancel an active Xquik extraction job by its ID. The job stops, saves no rows & uses no credits. Handle the 200, 401, 403, 404, 409 & 429 API responses.

> [tab] 200
>
> ```json theme={null}
> {
>   "id": "aB3dE6gH9jK2",
>   "status": "canceled"
> }
> ```

> [tab] 401
>
> ```json theme={null}
> {
>   "error": "unauthenticated",
>   "message": "Authentication required. Provide a valid API key or bearer token."
> }
> ```

> [tab] 403
>
> ```json theme={null}
> {
>   "error": "api_key_paused",
>   "message": "This API key is paused. Resume it at dashboard.xquik.com/api-keys to use it again."
> }
> ```

> [tab] 404
>
> ```json theme={null}
> {
>   "error": "not_found",
>   "message": "Resource not found."
> }
> ```

> [tab] 409
>
> ```json theme={null}
> {
>   "error": "extraction_terminal",
>   "message": "Extraction already finished. Check its status.",
>   "status": "completed"
> }
> ```

> [tab] 429
>
> ```json theme={null}
> {
>   "error": "rate_limit_exceeded",
>   "message": "Too many requests. Try again later.",
>   "retryAfter": 60
> }
> ```

> For the complete documentation index, see [llms.txt](https://docs.xquik.com/llms.txt).

## Cancel one extraction job

Send `DELETE /extractions/{id}` to stop a `pending` or `running` job. The job
ends as `canceled`. It saves no rows & uses no credits. A repeat request on a
canceled job answers `200`, so a retry is safe.

Use the job ID from [Create Extraction](https://docs.xquik.com/api-reference/extractions/create.md) or
[List Extractions](https://docs.xquik.com/api-reference/extractions/twitter-scraping-job-history.md). An
API key needs the exports scope for this route.

```bash cURL theme={null}
curl --request DELETE \
  https://xquik.com/api/v1/extractions/aB3dE6gH9jK2 \
  --header "x-api-key: xq_YOUR_KEY_HERE"
```

```javascript Node.js theme={null}
const jobId = "aB3dE6gH9jK2";
const response = await fetch(`https://xquik.com/api/v1/extractions/${jobId}`, {
  method: "DELETE",
  headers: { "x-api-key": "xq_YOUR_KEY_HERE" },
});
const body = await response.json();

if (!response.ok) {
  throw new Error(`${response.status} ${body.error}: ${body.message}`);
}

console.log(`${body.id} is ${body.status}`);
```

```python Python theme={null}
import requests

job_id = "aB3dE6gH9jK2"
response = requests.delete(
    f"https://xquik.com/api/v1/extractions/{job_id}",
    headers={"x-api-key": "xq_YOUR_KEY_HERE"},
)
body = response.json()

if not response.ok:
    raise RuntimeError(f'{response.status_code} {body["error"]}: {body["message"]}')

print(f'{body["id"]} is {body["status"]}')
```

## Know when a job can stop

Only a `pending` or `running` job can stop. A finished job answers `409` with
its `status`. Its rows stay as they were.

To keep the rows a job already found, let it finish. Then read them through
[Extraction results](https://docs.xquik.com/api-reference/extractions/twitter-extraction-results.md).

## Headers

**x-api-key** `string`

Your Xquik API key. Generate one from the [dashboard](https://dashboard.xquik.com/en/account?tab=api-keys).

**Authorization** `string`

An OAuth bearer token formatted as `Bearer YOUR_TOKEN`. Send this header or `x-api-key`, not both.

## Path parameters

**id** `string` *required*

Extraction job ID returned from [Create Extraction](https://docs.xquik.com/api-reference/extractions/create.md) or [List Extractions](https://docs.xquik.com/api-reference/extractions/twitter-scraping-job-history.md).

## Response

> [tab] 200 Canceled
>
> ```json theme={null}
> { "id": "aB3dE6gH9jK2", "status": "canceled" }
> ```
>
> Xquik stopped the job. It saved no rows.

> [tab] 401 Unauthenticated
>
> ```json theme={null}
> { "error": "unauthenticated", "message": "Authentication required. Provide a valid API key or bearer token." }
> ```
>
> The API key or bearer token is missing or invalid.

> [tab] 403 Forbidden
>
> ```json theme={null}
> { "error": "insufficient_scope", "message": "This API key lacks the exports scope. Add it at dashboard.xquik.com/api-keys.", "requiredScope": "exports" }
> ```
>
> The API key lacks the exports scope, or it is paused.

> [tab] 404 Not found
>
> ```json theme={null}
> { "error": "not_found", "message": "Resource not found." }
> ```
>
> No job has this ID, or it belongs to another account.

> [tab] 409 Already ended
>
> ```json theme={null}
> { "error": "extraction_terminal", "message": "Extraction already finished. Check its status.", "status": "completed" }
> ```
>
> The job already finished. `status` names how it ended.

> [tab] 429 Rate limited
>
> ```json theme={null}
> { "error": "rate_limit_exceeded", "message": "Too many requests. Try again later.", "retryAfter": 60 }
> ```
>
> Wait for the `Retry-After` header, then retry once.

> [!NOTE]
>
> **Related.** [Create Extraction](https://docs.xquik.com/api-reference/extractions/create.md) starts a new job, and [List Extractions](https://docs.xquik.com/api-reference/extractions/twitter-scraping-job-history.md) shows each job's status.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.