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

# Cancel Extract

> Cancel a running extract. Stops an active extract job that is currently processing.

<Tip>
  **When to use:** Use this endpoint when you need to stop an extraction job that is currently running. This is useful if:

  * You started an extraction job by mistake
  * The extraction is taking longer than expected and you want to stop it
  * You need to free up resources for other operations
</Tip>

<Note>
  **Cancellation Requirements:** You can only cancel executions that are currently running (status `"running"`).

  * If an execution has already completed or failed, it cannot be canceled
  * Executions that are waiting for a crawl to complete (status `"pending"` with `waiting_for` in meta) cannot be canceled until they start running
  * The endpoint will return an error if you attempt to cancel a non-running execution
</Note>

## Request

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

<ParamField path="execution_id" type="string" required>
  The execution ID returned from [`POST /v2/extract`](/v2/api-reference/endpoints/extract/extract)
</ParamField>

## Response

<ResponseField name="status" type="string">
  Status after cancellation. Always `"canceled"` on success.
</ResponseField>

<ResponseField name="execution_id" type="string">
  The execution identifier that was canceled
</ResponseField>

<ResponseField name="stop_date" type="string | null">
  ISO 8601 timestamp when the execution was stopped (null if not available)
</ResponseField>

<RequestExample dropdown>
  ```powershell cURL theme={null}
  # Cancel a running execution (urls input)
  curl -X DELETE "https://api.getcatalog.ai/v2/extract/extract-urls-965b1912-6af0-4ed8-b7e3-184b85e788b7" \
    -H "x-api-key: $CATALOG_API_KEY"

  # Cancel a running execution (vendor input)
  curl -X DELETE "https://api.getcatalog.ai/v2/extract/extract-nike-com-51d87084" \
    -H "x-api-key: $CATALOG_API_KEY"
  ```

  ```javascript JavaScript theme={null}
  // Cancel execution
  const executionId = 'extract-urls-965b1912-6af0-4ed8-b7e3-184b85e788b7';

  const response = await fetch(
    `https://api.getcatalog.ai/v2/extract/${executionId}`,
    {
      method: 'DELETE',
      headers: {
        'x-api-key': 'YOUR_API_KEY'
      }
    }
  );

  if (!response.ok) {
    const error = await response.json();
    console.error('Failed to cancel:', error.error.message);
    if (error.error.code === 'INVALID_REQUEST') {
      console.log('Execution may not be running or is waiting for a crawl');
    }
  } else {
    const data = await response.json();
    console.log(`Execution ${data.execution_id} canceled at ${data.stop_date}`);
  }
  ```

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

  execution_id = 'extract-nike-com-51d87084'

  # Cancel execution
  response = requests.delete(
      f'https://api.getcatalog.ai/v2/extract/{execution_id}',
      headers={'x-api-key': 'YOUR_API_KEY'}
  )

  if response.status_code == 200:
      data = response.json()
      print(f"Execution {data['execution_id']} canceled at {data['stop_date']}")
  elif response.status_code == 400:
      error = response.json()
      print(f"Cannot cancel: {error['error']['message']}")
      print("Execution may not be running or is waiting for a crawl")
  elif response.status_code == 404:
      print('Execution not found or does not belong to your organization')
  else:
      print(f'Error: {response.status_code}')
  ```
</RequestExample>

<ResponseExample>
  ```json DELETE Response (Success) theme={null}
  {
    "status": "canceled",
    "execution_id": "extract-urls-965b1912-6af0-4ed8-b7e3-184b85e788b7",
    "stop_date": "2025-01-15T10:35:22.000Z"
  }
  ```

  ```json Error Response (Execution Not Running) theme={null}
  {
    "error": {
      "message": "Execution is not running and cannot be canceled",
      "code": "INVALID_REQUEST",
      "request_id": "req-12345678-1234-1234-1234-123456789abc"
    }
  }
  ```

  ```json Error Response (Waiting for Crawl) theme={null}
  {
    "error": {
      "message": "Execution is waiting for crawl to complete and cannot be canceled yet",
      "code": "INVALID_REQUEST",
      "request_id": "req-12345678-1234-1234-1234-123456789abc"
    }
  }
  ```

  ```json Error Response (Execution Not Found) theme={null}
  {
    "error": {
      "message": "Execution not found",
      "code": "NOT_FOUND",
      "request_id": "req-12345678-1234-1234-1234-123456789abc"
    }
  }
  ```
</ResponseExample>
