> For a complete page index of the Captain API documentation, fetch https://docs.filesearch.dev/llms.txt?excludeSpec=true

# Cancel Job

DELETE https://api.filesearch.dev/v2/jobs/{job_id}

Cancel/delete an indexing job.

Maps to POST /v1/index-stop/\{job\_id}

Behavior:

* If job is pending or running -> transition to cancelled
* If job is already completed/failed/cancelled -> return 200 with current state (idempotent)

Returns:

* job\_id: The job identifier
* status: Current status after cancel attempt
* message: Human-readable description
* cancelled\_at: Cancellation timestamp (RFC3339)

Authentication: Requires Bearer token in Authorization header

Reference: https://docs.filesearch.dev/reference/jobs/cancel

## Request

### Path parameters

- `job_id` (string, required)

### Headers

- `authorization` (string, optional, nullable)

## Response

### 200

Successful Response

- `job_id` (string, required)
- `message` (string, required)
- `status` (string, required)
- `cancelled_at` (string, optional, nullable)
- `cleanup_initiated` (boolean, optional, nullable)

## Examples

**Response**

```json
{
  "job_id": "job_s3_abc123",
  "message": "Job deleted successfully",
  "status": "cancelled",
  "cancelled_at": "2025-01-20T08:20:00Z"
}
```

**SDK Code**

```python Python REST
import requests

BASE_URL = "https://api.filesearch.dev"
API_KEY = "your_api_key"
JOB_ID = "job_s3_abc123"

headers = {
    "Authorization": f"Bearer {API_KEY}",
}

response = requests.delete(
    f"{BASE_URL}/v2/jobs/{JOB_ID}",
    headers=headers,
    timeout=30.0
)

if response.status_code == 200:
    data = response.json()
    print(f"Job {data['job_id']} deleted at {data['cancelled_at']}")
else:
    print(f"Error: {response.status_code}")
```

```typescript TypeScript REST
const BASE_URL = "https://api.filesearch.dev";
const API_KEY = "your_api_key";
const JOB_ID = "job_s3_abc123";

const response = await fetch(
    `${BASE_URL}/v2/jobs/${JOB_ID}`,
    {
        method: "DELETE",
        headers: {
            "Authorization": `Bearer ${API_KEY}`,
        }
    }
);

if (response.ok) {
    const data = await response.json();
    console.log(`Job ${data.job_id} deleted at ${data.cancelled_at}`);
} else {
    console.error(`Error: ${response.status}`);
}
```