> ## 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 an extraction job, X (Twitter) API docs

> 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.

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

`DELETE https://xquik.com/api/v1/extractions/{id}`

## 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={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/bash.json","/languages/csharp.json","/languages/go.json","/languages/java.json","/languages/javascript.json","/languages/kotlin.json","/languages/php.json","/languages/python.json","/languages/ruby.json","/languages/typescript.json"]}}
curl --request DELETE \
  https://xquik.com/api/v1/extractions/aB3dE6gH9jK2 \
  --header "x-api-key: xq_YOUR_KEY_HERE"
```

```javascript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/bash.json","/languages/csharp.json","/languages/go.json","/languages/java.json","/languages/javascript.json","/languages/kotlin.json","/languages/php.json","/languages/python.json","/languages/ruby.json","/languages/typescript.json"]}}
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={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/bash.json","/languages/csharp.json","/languages/go.json","/languages/java.json","/languages/javascript.json","/languages/kotlin.json","/languages/php.json","/languages/python.json","/languages/ruby.json","/languages/typescript.json"]}}
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

| Header | Type | Required | Description |
| - | - | - | - |
| `x-api-key` | `string` | No | Your Xquik API key. Generate one from the [dashboard](https://dashboard.xquik.com/en/account?tab=api-keys). |
| `Authorization` | `string` | No | An OAuth bearer token formatted as `Bearer YOUR_TOKEN`. Send this header or `x-api-key`, not both. |

## Path parameters

| Path parameter | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | 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={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/bash.json","/languages/csharp.json","/languages/go.json","/languages/java.json","/languages/javascript.json","/languages/kotlin.json","/languages/php.json","/languages/python.json","/languages/ruby.json","/languages/typescript.json"]}}
> { "id": "aB3dE6gH9jK2", "status": "canceled" }
> ```
>
> Xquik stopped the job. It saved no rows.

> [tab] 401 Unauthenticated
>
> ```json theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/bash.json","/languages/csharp.json","/languages/go.json","/languages/java.json","/languages/javascript.json","/languages/kotlin.json","/languages/php.json","/languages/python.json","/languages/ruby.json","/languages/typescript.json"]}}
> { "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={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/bash.json","/languages/csharp.json","/languages/go.json","/languages/java.json","/languages/javascript.json","/languages/kotlin.json","/languages/php.json","/languages/python.json","/languages/ruby.json","/languages/typescript.json"]}}
> { "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={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/bash.json","/languages/csharp.json","/languages/go.json","/languages/java.json","/languages/javascript.json","/languages/kotlin.json","/languages/php.json","/languages/python.json","/languages/ruby.json","/languages/typescript.json"]}}
> { "error": "not_found", "message": "Resource not found." }
> ```
>
> No job has this ID, or it belongs to another account.

> [tab] 409 Already ended
>
> ```json theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/bash.json","/languages/csharp.json","/languages/go.json","/languages/java.json","/languages/javascript.json","/languages/kotlin.json","/languages/php.json","/languages/python.json","/languages/ruby.json","/languages/typescript.json"]}}
> { "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={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/bash.json","/languages/csharp.json","/languages/go.json","/languages/java.json","/languages/javascript.json","/languages/kotlin.json","/languages/php.json","/languages/python.json","/languages/ruby.json","/languages/typescript.json"]}}
> { "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.

## Response examples

### 200 example

```json theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/bash.json","/languages/csharp.json","/languages/go.json","/languages/java.json","/languages/javascript.json","/languages/kotlin.json","/languages/php.json","/languages/python.json","/languages/ruby.json","/languages/typescript.json"]}}
{
  "id": "aB3dE6gH9jK2",
  "status": "canceled"
}
```

* **401** `{ "error": "unauthenticated", "message": "Authentication required. Provide a valid API key or bearer token." }`
* **403** `{ "error": "api_key_paused", "message": "This API key is paused. Resume it at dashboard.xquik.com/api-keys to use it again." }`
* **404** `{ "error": "not_found", "message": "Resource not found." }`
* **409** `{ "error": "extraction_terminal", "message": "Extraction already finished. Check its status.", "status": "completed" }`
* **429** `{ "error": "rate_limit_exceeded", "message": "Too many requests. Try again later.", "retryAfter": 60 }`


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