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

# Cancel Crawl Job

> Stop a crawl job that is queued or actively running. Pages already processed are kept.

Stops a crawl job that is queued or currently running. Pages that were already processed before the cancellation are preserved — you can still retrieve them with [GET /crawl/{jobId}/pages](/api-reference/crawling/crawl-pages). The job status moves to `cancelled`.

Cancelling a job that has already reached a terminal state (`completed`, `failed`, or `cancelled`) returns a 400.

## Example Request

<CodeGroup>
  ```bash cURL theme={null}
  curl -X DELETE https://api.spidra.io/api/crawl/abc-123 \
    -H "Authorization: Bearer YOUR_API_KEY"
  ```

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

  requests.delete(
      "https://api.spidra.io/api/crawl/abc-123",
      headers={"Authorization": "Bearer YOUR_API_KEY"}
  )
  ```

  ```javascript Node.js theme={null}
  await fetch("https://api.spidra.io/api/crawl/abc-123", {
    method: "DELETE",
    headers: { Authorization: "Bearer YOUR_API_KEY" }
  });
  ```
</CodeGroup>

## Response

```json theme={null}
{
  "status": "cancelled",
  "jobId": "abc-123"
}
```

## Retrieving Partial Results

After cancelling, call [GET /crawl/{jobId}/pages](/api-reference/crawling/crawl-pages) to retrieve any pages that completed before the job was stopped.

```bash theme={null}
curl https://api.spidra.io/api/crawl/abc-123/pages \
  -H "Authorization: Bearer YOUR_API_KEY"
```

Only pages with `status: "success"` will have data. Any pages that were mid-flight when the job was cancelled will not appear.


## OpenAPI

````yaml DELETE /crawl/{jobId}
openapi: 3.1.0
info:
  title: Spidra API
  version: 1.0.0
  description: >-
    Public API endpoints for web scraping via Spidra. Authenticate with
    `Authorization: Bearer YOUR_API_KEY`.
servers:
  - url: https://api.spidra.io/api
security:
  - BearerAuth: []
  - ApiKeyAuth: []
paths:
  /crawl/{jobId}:
    delete:
      tags:
        - Crawling
      summary: Cancel Crawl Job
      description: >-
        Cancel a crawl job that is queued or actively running. Pages already
        processed are kept; in-progress pages are stopped. The job status moves
        to 'cancelled'.
      parameters:
        - name: jobId
          in: path
          required: true
          schema:
            type: string
          description: The job ID to cancel
      responses:
        '200':
          description: Job cancelled
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    enum:
                      - cancelled
                  jobId:
                    type: string
              example:
                status: cancelled
                jobId: f3c2a1b0-4d5e-6f7a-8b9c-0d1e2f3a4b5c
        '400':
          description: >-
            Job is already in a terminal state (completed, failed, or cancelled)
            and cannot be cancelled
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                status: error
                message: 'Cannot cancel a job with status: completed'
        '401':
          description: Invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Job not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    ErrorResponse:
      type: object
      properties:
        status:
          type: string
          enum:
            - error
        message:
          type: string
      required:
        - status
        - message
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API key
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````