---
title: Cancel an Archive Search
description: Cancel a running Archive Search.
breadcrumbs: Docs > API > Cancel an Archive Search
---

> For the complete documentation index, see [llms.txt](https://dnd37xeb23o8n.cloudfront.net/jen.gilbert/astro-base/llms.txt).

# Cancel an Archive Search

## v2 (latest)

{% alert level="warning" %}
**Note**: This endpoint is in preview and is subject to change.
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help.md).
{% /alert %}

| Datadog site      | API endpoint                                                                               |
| ----------------- | ------------------------------------------------------------------------------------------ |
| app.datadoghq.com | POST https://api.datadoghq.com/api/v2/logs/archive_searches/{archive_search_id}/cancel     |
| us3.datadoghq.com | POST https://api.us3.datadoghq.com/api/v2/logs/archive_searches/{archive_search_id}/cancel |
| us5.datadoghq.com | POST https://api.us5.datadoghq.com/api/v2/logs/archive_searches/{archive_search_id}/cancel |
| app.datadoghq.eu  | POST https://api.datadoghq.eu/api/v2/logs/archive_searches/{archive_search_id}/cancel      |
| ap1.datadoghq.com | POST https://api.ap1.datadoghq.com/api/v2/logs/archive_searches/{archive_search_id}/cancel |
| ap2.datadoghq.com | POST https://api.ap2.datadoghq.com/api/v2/logs/archive_searches/{archive_search_id}/cancel |
| uk1.datadoghq.com | POST https://api.uk1.datadoghq.com/api/v2/logs/archive_searches/{archive_search_id}/cancel |
| app.ddog-gov.com  | POST https://api.ddog-gov.com/api/v2/logs/archive_searches/{archive_search_id}/cancel      |
| us2.ddog-gov.com  | POST https://api.us2.ddog-gov.com/api/v2/logs/archive_searches/{archive_search_id}/cancel  |

### Overview

Cancel a running Archive Search. Cancelling an Archive Search that has already finished is a
no-op: it returns the resource unchanged instead of returning an error.

This endpoint requires any of the following permissions:

- `logs_write_historical_view`
- `logs_write_archive_search`

### Arguments

#### Path Parameters

| Field                          | Type   | Description                              |
| ------------------------------ | ------ | ---------------------------------------- |
| archive_search_id [*required*] | string | Unique identifier of the Archive Search. |

### Response

{% tabs %}
{% tab label="200" %}
OK

{% tabs %}
{% tab label="Model" %}
Response containing a single Archive Search.

| Parent field | Field                              | Type      | Description                                                                                                                         |
| ------------ | ---------------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------- |
|              | data [*required*]                  | object    | Archive Search object.                                                                                                              |
| data         | attributes [*required*]            | object    | Attributes of an Archive Search.                                                                                                    |
| attributes   | archive_id [*required*]            | string    | ID of the archive being searched.                                                                                                   |
| attributes   | bytes_scanned [*required*]         | int64     | Number of bytes read from the archive at the end of the search.                                                                     |
| attributes   | completed_at                       | date-time | Time the Archive Search finished, as an ISO 8601 timestamp. Absent while the search is still running.                               |
| attributes   | created_at [*required*]            | date-time | Time the Archive Search was created, as an ISO 8601 timestamp.                                                                      |
| attributes   | description                        | string    | Free-text description of the Archive Search.                                                                                        |
| attributes   | events_scanned [*required*]        | int64     | Number of events read from the archive at the end of the search.                                                                    |
| attributes   | expected_duration                  | int64     | Estimated time left before the Archive Search completes, in seconds.                                                                |
| attributes   | from [*required*]                  | date-time | Start of the searched time range, as an ISO 8601 timestamp.                                                                         |
| attributes   | name [*required*]                  | string    | Name of the Archive Search.                                                                                                         |
| attributes   | query [*required*]                 | string    | Log search query used to filter the archived logs.                                                                                  |
| attributes   | rehydration                        | object    | Rehydration settings of the Archive Search. Absent when the search only scans the archive without indexing the results.             |
| rehydration  | max_rehydrated_events [*required*] | int64     | Maximum number of events to rehydrate.                                                                                              |
| rehydration  | retention_days [*required*]        | int64     | Number of days the rehydrated logs are retained for.                                                                                |
| rehydration  | tier [*required*]                  | enum      | Storage tier the matched logs are rehydrated into. Allowed enum values: `standard`, `flex`.                                         |
| attributes   | status [*required*]                | enum      | Current state of an Archive Search. Allowed enum values: `RUNNING`, `COMPLETED`, `FAILED`, `CANCELLED`, `QUOTA_REACHED`, `EXPIRED`. |
| attributes   | to [*required*]                    | date-time | End of the searched time range, as an ISO 8601 timestamp.                                                                           |
| data         | id [*required*]                    | string    | Unique identifier of the Archive Search.                                                                                            |
| data         | type [*required*]                  | enum      | Archive Search resource type. Allowed enum values: `archive_search`. Default: `archive_search`.                                     |
{% /tab %}

{% tab label="Example" %}
```json
{
  "data": {
    "attributes": {
      "archive_id": "mhmyYmyLTOaFYKvhNadu1w",
      "bytes_scanned": 402764439,
      "completed_at": "2026-01-02T12:30:00Z",
      "created_at": "2026-01-02T12:00:00Z",
      "description": "Investigating the checkout latency spike.",
      "events_scanned": 1500,
      "expected_duration": 120,
      "from": "2026-01-01T00:00:00Z",
      "name": "checkout-latency-investigation",
      "query": "service:checkout status:error",
      "rehydration": {
        "max_rehydrated_events": 1000000,
        "retention_days": 15,
        "tier": "standard"
      },
      "status": "RUNNING",
      "to": "2026-01-02T00:00:00Z"
    },
    "id": "nv2eu4srgyzdkulggjzg2zkmmzifa2rum5iq",
    "type": "archive_search"
  }
}
```
{% /tab %}
{% /tabs %}
{% /tab %}

{% tab label="400" %}
Bad Request

{% tabs %}
{% tab label="Model" %}
API error response.

| Parent field | Field               | Type     | Description                                                                     |
| ------------ | ------------------- | -------- | ------------------------------------------------------------------------------- |
|              | errors [*required*] | [object] | A list of errors.                                                               |
| errors       | detail              | string   | A human-readable explanation specific to this occurrence of the error.          |
| errors       | meta                | object   | Non-standard meta-information about the error                                   |
| errors       | source              | object   | References to the source of the error.                                          |
| source       | header              | string   | A string indicating the name of a single request header which caused the error. |
| source       | parameter           | string   | A string indicating which URI query parameter caused the error.                 |
| source       | pointer             | string   | A JSON pointer to the value in the request document that caused the error.      |
| errors       | status              | string   | Status code of the response.                                                    |
| errors       | title               | string   | Short human-readable summary of the error.                                      |
{% /tab %}

{% tab label="Example" %}
```json
{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}
```
{% /tab %}
{% /tabs %}
{% /tab %}

{% tab label="403" %}
Forbidden

{% tabs %}
{% tab label="Model" %}
API error response.

| Parent field | Field               | Type     | Description                                                                     |
| ------------ | ------------------- | -------- | ------------------------------------------------------------------------------- |
|              | errors [*required*] | [object] | A list of errors.                                                               |
| errors       | detail              | string   | A human-readable explanation specific to this occurrence of the error.          |
| errors       | meta                | object   | Non-standard meta-information about the error                                   |
| errors       | source              | object   | References to the source of the error.                                          |
| source       | header              | string   | A string indicating the name of a single request header which caused the error. |
| source       | parameter           | string   | A string indicating which URI query parameter caused the error.                 |
| source       | pointer             | string   | A JSON pointer to the value in the request document that caused the error.      |
| errors       | status              | string   | Status code of the response.                                                    |
| errors       | title               | string   | Short human-readable summary of the error.                                      |
{% /tab %}

{% tab label="Example" %}
```json
{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}
```
{% /tab %}
{% /tabs %}
{% /tab %}

{% tab label="404" %}
Not Found

{% tabs %}
{% tab label="Model" %}
API error response.

| Parent field | Field               | Type     | Description                                                                     |
| ------------ | ------------------- | -------- | ------------------------------------------------------------------------------- |
|              | errors [*required*] | [object] | A list of errors.                                                               |
| errors       | detail              | string   | A human-readable explanation specific to this occurrence of the error.          |
| errors       | meta                | object   | Non-standard meta-information about the error                                   |
| errors       | source              | object   | References to the source of the error.                                          |
| source       | header              | string   | A string indicating the name of a single request header which caused the error. |
| source       | parameter           | string   | A string indicating which URI query parameter caused the error.                 |
| source       | pointer             | string   | A JSON pointer to the value in the request document that caused the error.      |
| errors       | status              | string   | Status code of the response.                                                    |
| errors       | title               | string   | Short human-readable summary of the error.                                      |
{% /tab %}

{% tab label="Example" %}
```json
{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}
```
{% /tab %}
{% /tabs %}
{% /tab %}

{% tab label="429" %}
Too many requests

{% tabs %}
{% tab label="Model" %}
API error response.

| Field               | Type     | Description       |
| ------------------- | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |
{% /tab %}

{% tab label="Example" %}
```json
{
  "errors": [
    "Bad Request"
  ]
}
```
{% /tab %}
{% /tabs %}
{% /tab %}
{% /tabs %}

### Code Example

{% tabs %}
{% tab label="Curl" %}
```bash
# Path parameters
export archive_search_id="nv2eu4srgyzdkulggjzg2zkmmzifa2rum5iq"

# Set your Datadog site and credentials
export DD_SITE="datadoghq.com" # Or us3.datadoghq.com, us5.datadoghq.com, datadoghq.eu, ap1.datadoghq.com, ap2.datadoghq.com, uk1.datadoghq.com, ddog-gov.com, us2.ddog-gov.com
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/logs/archive_searches/${archive_search_id}/cancel" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"
```
{% /tab %}
{% /tabs %}
