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

# Cancel a job

> POST /jobs/{job_id}/cancel — stop a pending or running job

Cancels a pending or running job and returns its resulting state. Idempotent: cancelling a job that has already finished (or was already cancelled) is a no-op that returns the current state unchanged.

```text theme={"dark"}
POST /jobs/{job_id}/cancel
```

There is no separate `cancelled` status. A cancelled job lands in `status: "failed"` with `error.code: "cancelled"` — so a poller that watches for terminal states needs no special case.

<Note>
  Cancellation can race with completion: if the job succeeds in the instant the
  cancel arrives, the response reflects the real outcome (`succeeded`, result
  intact) rather than pretending it was cancelled.
</Note>

## Request

<ParamField path="job_id" type="uuid" required>
  The job to cancel. Another tenant's job returns `404`.
</ParamField>

## Response

The same job object as [`GET /jobs/{job_id}`](/api-reference/get-job).

## Example

```bash theme={"dark"}
curl -s -X POST "$NDI_BASE/jobs/b1e6d5c4-2a3f-4e89-a0b1-c2d3e4f5a6b7/cancel" \
  -H "X-API-Key: $NDI_API_KEY"
```

```json theme={"dark"}
{
  "job_id": "b1e6d5c4-2a3f-4e89-a0b1-c2d3e4f5a6b7",
  "action": "ground",
  "status": "failed",
  "result": null,
  "error": { "code": "cancelled", "message": "cancelled by client request" },
  "created_at": "2026-07-12T21:15:40Z",
  "started_at": "2026-07-12T21:15:41Z",
  "completed_at": "2026-07-12T21:16:02Z"
}
```
