# Cancel a job

> Stop a parent job’s remaining non-terminal children. Already-finished children keep their result.

`POST /v1/jobs/:id/cancel` cancels a parent job's remaining **non-terminal** children. Children that already reached a terminal state (`completed`, `partial`, `failed`) keep their outcome and their artifacts — cancellation only stops work that hasn't finished.

<ParamField path="id" type="string" required>
  The **parent** job id (dotless, e.g. `job_8t2q`).
</ParamField>

## Request

<CodeGroup>

```bash cURL
curl -X POST https://api.aisearchapi.dev/v1/jobs/job_8t2q/cancel \
  -H "Authorization: Bearer $AISEARCH_API_KEY"
```

```javascript Node
const res = await fetch('https://api.aisearchapi.dev/v1/jobs/job_8t2q/cancel', {
  method: 'POST',
  headers: { Authorization: `Bearer ${process.env.AISEARCH_API_KEY}` },
});
const { job } = await res.json();
```

```python Python
import os, requests

res = requests.post(
    "https://api.aisearchapi.dev/v1/jobs/job_8t2q/cancel",
    headers={"Authorization": f"Bearer {os.environ['AISEARCH_API_KEY']}"},
)
job = res.json()["job"]
```

</CodeGroup>

## Response

```json 200 OK
{
  "job": {
    "id": "job_8t2q",
    "status": "canceled"
  }
}
```

<ResponseField name="job.id" type="string">
  The parent job id.
</ResponseField>

<ResponseField name="job.status" type="string">
  The parent's status **after** cancellation. If some children had already
  completed, the rollup can be `partial` or `completed` rather than `canceled` —
  cancellation never rewrites a finished child's result.
</ResponseField>

<Note>
  Cancellation is a request to stop, not a rollback. A capture already in flight
  may still finish; a successful capture is still billed. Only work that hadn't
  started is guaranteed not to run (or be charged).
</Note>

## Errors

<ResponseField name="404" type="JOB_NOT_FOUND">
  No parent job exists for that id, or it belongs to another tenant (reads and
  writes are owner-scoped — another tenant's id is a `404`, never a `403`).
</ResponseField>

```json 404
{
  "code": "JOB_NOT_FOUND",
  "error": "no job with id 'job_8t2q'",
  "request_id": "req_9f2c1a7e4b5d48f1a3c6e8d0b2a4f6c8",
  "docs_url": "https://docs.aisearchapi.dev/guides/errors#job_not_found"
}
```

<CardGroup cols={2}>
  <Card title="Get a job" icon="file-lines" href="/api-reference/get-job">
    Read the parent rollup and per-child status.
  </Card>
  <Card title="Job lifecycle" icon="arrows-rotate" href="/guides/asynchronous">
    Terminal states and when work can still be canceled.
  </Card>
</CardGroup>
