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

# Cancel Job

> Cancel a pending job in the queue

## Overview

Cancel a job that is still waiting in the queue. Jobs that are already processing or completed cannot be cancelled.

## Header Parameters

<ParamField header="x-api-key" type="string" required>
  Your API key for authentication
</ParamField>

## Path Parameters

<ParamField path="id" type="uuid" required>
  The job UUID to cancel
</ParamField>

## Response

<ResponseField name="message" type="string">
  Success message
</ResponseField>

<ResponseField name="job_id" type="string">
  The cancelled job ID
</ResponseField>

## Examples

<CodeGroup>
  ```bash Cancel a Job theme={null}
  curl -X DELETE "https://api.tornadoapi.io/jobs/550e8400-e29b-41d4-a716-446655440000" \
    -H "x-api-key: sk_your_api_key"
  ```

  ```javascript Node.js theme={null}
  const response = await fetch(
    'https://api.tornadoapi.io/jobs/550e8400-e29b-41d4-a716-446655440000',
    {
      method: 'DELETE',
      headers: {
        'x-api-key': 'sk_your_api_key'
      }
    }
  );

  const data = await response.json();
  console.log(data);
  ```

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

  response = requests.delete(
      'https://api.tornadoapi.io/jobs/550e8400-e29b-41d4-a716-446655440000',
      headers={'x-api-key': 'sk_your_api_key'}
  )

  print(response.json())
  ```
</CodeGroup>

## Success Response

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "message": "Job cancelled successfully",
    "job_id": "550e8400-e29b-41d4-a716-446655440000"
  }
  ```
</ResponseExample>

## Error Responses

<ResponseExample>
  ```json 400 Bad Request theme={null}
  {
    "error": "Job cannot be cancelled (not in queue or already processing)"
  }
  ```

  ```json 401 Unauthorized theme={null}
  {
    "error": "Missing x-api-key header"
  }
  ```

  ```json 401 Unauthorized theme={null}
  {
    "error": "Invalid API Key"
  }
  ```

  ```json 404 Not Found theme={null}
  {
    "error": "Job not found"
  }
  ```

  ```json 500 Internal Server Error theme={null}
  {
    "error": "Failed to cancel job"
  }
  ```
</ResponseExample>

## Notes

* Only jobs with status `Pending` (in queue) can be cancelled
* Jobs that are already `Processing`, `Completed`, or `Failed` cannot be cancelled
* Cancelled jobs are marked as `Failed` with the error message "Job cancelled by user"
* Cancellation is atomic - if successful, the job is guaranteed to be removed from the queue
