# Cancel an owned active request or active structured-extraction run (/api-reference/data-api/postDataRequestsByIdCancel)

Cancels a pending, running, or CAPTCHA-solving page request. If the page is already completed, the endpoint can still cancel active dependent AI extraction runs without deleting the retained page result. Pending page cancellations attempt an immediate base-debit refund; running page cancellations are left for the existing refund-recovery flow.

## POST /api/v1/data/requests/{id}/cancel

Cancel an owned active request or active structured-extraction run

- Operation ID: `postDataRequestsByIdCancel`

- Tags: `Data API`

Cancels a pending, running, or CAPTCHA-solving page request. If the page is already completed, the endpoint can still cancel active dependent AI extraction runs without deleting the retained page result. Pending page cancellations attempt an immediate base-debit refund; running page cancellations are left for the existing refund-recovery flow.

### Security

- Required scope: `scrape:write`

- `ApiKey` (apiKey, X-API-Key)

- `ApiKeyBearer` (http)

### Parameters

- `id` (path, required) — string (uuid); UUID of the target request or batch, as returned in the id field when it was created or listed.

- `Idempotency-Key` (header) — string; Optional. Generate a unique value before a write and retain it for an exact-body retry; replay is free and a different body returns 409 IDEMPOTENCY_CONFLICT.; example="rh-docs-01J2QG-unique"

### Responses

- **200** — Cancellation accepted and persisted Error body uses the documented PublicError DTO.

  - `application/json`: #/components/schemas/CancelJobResponse

  - Example: `{
  "id": "9a20bd58-ed33-4a5b-b63f-b52bb1a62248",
  "status": "pending"
}`

- **400** — Invalid public UUID Error body uses the documented PublicError DTO.

  - `application/json`: #/components/schemas/PublicError

  - Example: `{
  "error": "Request failed",
  "code": "VALIDATION_ERROR",
  "message": "Invalid public UUID Error body uses the documented PublicError DTO.",
  "requestId": "req_01J2QG"
}`

- **404** — Not found in this tenant Error body uses the documented PublicError DTO.

  - `application/json`: #/components/schemas/PublicError

  - Example: `{
  "error": "Request failed",
  "code": "VALIDATION_ERROR",
  "message": "Not found in this tenant Error body uses the documented PublicError DTO.",
  "requestId": "req_01J2QG"
}`

- **409** — The request has no active page or dependent extraction work Error body uses the documented PublicError DTO.

  - `application/json`: #/components/schemas/PublicError

  - Example: `{
  "error": "Request failed",
  "code": "RESULT_NOT_READY",
  "message": "The request has no active page or dependent extraction work Error body uses the documented PublicError DTO.",
  "requestId": "req_01J2QG"
}`

- **503** — The public Data API is disabled Error body uses the documented PublicError DTO.

  - `application/json`: #/components/schemas/PublicError

  - Example: `{
  "error": "Request failed",
  "code": "PRICING_NOT_ACTIVE",
  "message": "The public Data API is disabled Error body uses the documented PublicError DTO.",
  "requestId": "req_01J2QG"
}`

### Referenced OpenAPI components

#### `#/components/parameters/PublicId`

```json

{
  "name": "id",
  "in": "path",
  "required": true,
  "description": "UUID of the target request or batch, as returned in the id field when it was created or listed.",
  "schema": {
    "type": "string",
    "format": "uuid"
  }
}

```

#### `#/components/parameters/IdempotencyKey`

```json

{
  "name": "Idempotency-Key",
  "in": "header",
  "required": false,
  "description": "Optional. Generate a unique value before a write and retain it for an exact-body retry; replay is free and a different body returns 409 IDEMPOTENCY_CONFLICT.",
  "schema": {
    "type": "string",
    "minLength": 8,
    "maxLength": 200
  },
  "example": "rh-docs-01J2QG-unique"
}

```

#### `#/components/schemas/CancelJobResponse`

```json

{
  "type": "object",
  "additionalProperties": false,
  "required": [
    "id",
    "status",
    "page_status",
    "page_cancelled",
    "page_was_active",
    "recipe_runs",
    "refund_status",
    "refund_tokens",
    "batch_refresh_status"
  ],
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "status": {
      "type": "string",
      "const": "cancelled",
      "description": "Logical request/extraction cancellation status."
    },
    "page_status": {
      "type": "string",
      "description": "Persisted underlying page-request status after cancellation. It remains completed when cancellation only stopped extraction work."
    },
    "page_cancelled": {
      "type": "boolean",
      "description": "True when an active page request was changed to cancelled."
    },
    "page_was_active": {
      "type": "boolean",
      "description": "True when the page was pending, running, or solving a CAPTCHA before this cancellation."
    },
    "recipe_runs": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "was_active",
        "cancelled_ids"
      ],
      "properties": {
        "was_active": {
          "type": "boolean",
          "description": "True when at least one queued, waiting, or running dependent recipe run was cancelled."
        },
        "cancelled_ids": {
          "type": "array",
          "items": {
            "type": "string",
            "format": "uuid"
          },
          "description": "Owned dependent recipe runs cancelled atomically with this request operation."
        }
      }
    },
    "refund_status": {
      "type": "string",
      "enum": [
        "completed",
        "pending_recovery",
        "not_applicable"
      ],
      "description": "Pending page cancellations attempt an immediate refund; running page cancellations remain recoverable work; extraction-only cancellation does not refund the already-completed page request."
    },
    "refund_tokens": {
      "type": "integer",
      "minimum": 0,
      "description": "Base tokens included in the page cancellation refund path; zero for extraction-only cancellation."
    },
    "batch_refresh_status": {
      "type": "string",
      "enum": [
        "completed",
        "pending_recovery"
      ]
    }
  }
}

```

#### `#/components/schemas/PublicError`

```json

{
  "type": "object",
  "additionalProperties": false,
  "required": [
    "error",
    "code",
    "message",
    "requestId"
  ],
  "properties": {
    "error": {
      "type": "string"
    },
    "code": {
      "type": "string",
      "description": "Stable public error code. PROXY_QUOTE_EXPIRED means the optional quote_version supplied at admission is no longer current; refresh the pricing view and submit again."
    },
    "message": {
      "type": "string"
    },
    "requestId": {
      "type": "string"
    }
  }
}

```

### Complete operation object

```json

{
  "operationId": "postDataRequestsByIdCancel",
  "tags": [
    "Data API"
  ],
  "summary": "Cancel an owned active request or active structured-extraction run",
  "description": "Cancels a pending, running, or CAPTCHA-solving page request. If the page is already completed, the endpoint can still cancel active dependent AI extraction runs without deleting the retained page result. Pending page cancellations attempt an immediate base-debit refund; running page cancellations are left for the existing refund-recovery flow.",
  "x-required-scope": "scrape:write",
  "x-mcp-name": "data_cancel_request",
  "x-mcp-annotations": {
    "readOnlyHint": false,
    "destructiveHint": true,
    "idempotentHint": false,
    "openWorldHint": false
  },
  "parameters": [
    {
      "$ref": "#/components/parameters/PublicId"
    },
    {
      "$ref": "#/components/parameters/IdempotencyKey"
    }
  ],
  "responses": {
    "200": {
      "description": "Cancellation accepted and persisted Error body uses the documented PublicError DTO.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/CancelJobResponse"
          },
          "example": {
            "id": "9a20bd58-ed33-4a5b-b63f-b52bb1a62248",
            "status": "pending"
          }
        }
      }
    },
    "400": {
      "description": "Invalid public UUID Error body uses the documented PublicError DTO.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/PublicError"
          },
          "example": {
            "error": "Request failed",
            "code": "VALIDATION_ERROR",
            "message": "Invalid public UUID Error body uses the documented PublicError DTO.",
            "requestId": "req_01J2QG"
          }
        }
      },
      "x-docs-retryable": false
    },
    "404": {
      "description": "Not found in this tenant Error body uses the documented PublicError DTO.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/PublicError"
          },
          "example": {
            "error": "Request failed",
            "code": "VALIDATION_ERROR",
            "message": "Not found in this tenant Error body uses the documented PublicError DTO.",
            "requestId": "req_01J2QG"
          }
        }
      },
      "x-docs-retryable": false
    },
    "409": {
      "description": "The request has no active page or dependent extraction work Error body uses the documented PublicError DTO.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/PublicError"
          },
          "example": {
            "error": "Request failed",
            "code": "RESULT_NOT_READY",
            "message": "The request has no active page or dependent extraction work Error body uses the documented PublicError DTO.",
            "requestId": "req_01J2QG"
          }
        }
      },
      "x-docs-retryable": true
    },
    "503": {
      "description": "The public Data API is disabled Error body uses the documented PublicError DTO.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/PublicError"
          },
          "example": {
            "error": "Request failed",
            "code": "PRICING_NOT_ACTIVE",
            "message": "The public Data API is disabled Error body uses the documented PublicError DTO.",
            "requestId": "req_01J2QG"
          }
        }
      },
      "x-docs-retryable": true
    }
  },
  "security": [
    {
      "ApiKey": []
    },
    {
      "ApiKeyBearer": []
    }
  ],
  "servers": [
    {
      "url": "https://api.runharvester.com",
      "description": "RunHarvester public API"
    }
  ]
}

```