> ## 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 Search Job

> Stop a search job that is queued or actively running.

Stops a search job that is queued or currently running. Search jobs usually resolve in a few seconds, but a degraded upstream network can occasionally make one run much longer than normal — use this to stop waiting on it rather than polling indefinitely.

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

## Example Request

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

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

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

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

## Response

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

## What Polling Sees After Cancelling

A search job has no separate "cancelled" job state — cancelling either removes it from the queue before it started, or signals the running job to stop at its next checkpoint (between search sources/attempts, not mid-request):

* If the job hadn't started yet, a subsequent [GET /search/{jobId}](/api-reference/search/search-status) returns 404 (`JOB_NOT_FOUND`).
* If the job was already running, it keeps reporting `status: "active"` for a brief moment, then settles to `status: "failed"` with `error: "Search cancelled"`.

No credits are charged for a cancelled job.


## OpenAPI

````yaml DELETE /search/{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:
  /search/{jobId}:
    delete:
      tags:
        - Search
      summary: Cancel Search Job
      description: >-
        Cancel a search job that is queued or actively running. No credits are
        charged for a cancelled job.
      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: abc-123
        '400':
          description: >-
            Job is already in a terminal state (completed or failed) and cannot
            be cancelled
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                status: error
                message: Cannot cancel a job that has already completed.
        '401':
          description: Invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Not authorized to access this job
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                status: error
                message: You do not have permission to access this job.
        '404':
          description: Job not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                status: error
                message: Search job not found
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

````