---
title: "Create an Archive Search"
method: POST
path: "/api/v2/logs/archive_searches"
tags: ["Logs Archive Searches"]
---

# Create an Archive Search

`POST /api/v2/logs/archive_searches`

## Request

- Base URL: `https://api.datadoghq.com`
- URL: `https://api.datadoghq.com/api/v2/logs/archive_searches`
- Auth: one of:
  - API key in header `DD-API-KEY` and API key in header `DD-APPLICATION-KEY`
  - OAuth 2
    - Authorization code: `/oauth2/v1/authorize`
    - Token URL: `/oauth2/v1/token`
- TypeScript: <https://skmtc.dev/datadog/apis/datadog-api-v2-collection/docs/api/v2/logs/archive_searches/post.ts> (a function with typed inputs; its response is checked against the schema)

Start a search over the logs stored in an archive.

Without a `rehydration` object, the search only scans the archive and reports how much data
matched. With one, the matched logs are also indexed into a retained historical view, which
requires the `logs_write_historical_view` permission.

## Request body

- ArchiveSearchCreateRequest: Request to create an Archive Search.
  - `data` ArchiveSearchCreateRequestData, required: Archive Search object to create.
    - `attributes` ArchiveSearchCreateRequestAttributes, required: Attributes accepted when creating an Archive Search.
      - `archive_id` string, required: ID of the archive to search. Use the Logs Archives API to list the archives of the organization.
      - `description` string: Free-text description of the Archive Search.
      - `from` string, date-time, required: Start of the time range to search, as an ISO 8601 timestamp.
      - `name` string, required: Name of the Archive Search.
      - `query` string, required: Log search query used to filter the archived logs.
      - `rehydration` ArchiveSearchCreateRehydration: Rehydration settings. Include this object to index the matched logs into a retained historical view. Omit it to run an Archive Search that only scans the archive.
        - `max_rehydrated_events` integer, required: Maximum number of events to rehydrate. The organization's reindexing limit is configured in millions, so this value is at least 1,000,000.
        - `retention_days` integer, required: Number of days the rehydrated logs are retained for.
        - `tier` 'standard' | 'flex', required: Storage tier the matched logs are rehydrated into.
      - `to` string, date-time, required: End of the time range to search, as an ISO 8601 timestamp. Must be after `from`.
    - `type` 'archive_search', required: Archive Search resource type.

## Response `200`

OK

- ArchiveSearchResponse: Response containing a single Archive Search.
  - `data` ArchiveSearchResponseData, required: Archive Search object.
    - `attributes` ArchiveSearchResponseAttributes, required: Attributes of an Archive Search.
      - `archive_id` string, required: ID of the archive being searched.
      - `bytes_scanned` integer, required: Number of bytes read from the archive at the end of the search.
      - `completed_at` string, date-time: Time the Archive Search finished, as an ISO 8601 timestamp. Absent while the search is still running.
      - `created_at` string, date-time, required: Time the Archive Search was created, as an ISO 8601 timestamp.
      - `description` string: Free-text description of the Archive Search.
      - `events_scanned` integer, required: Number of events read from the archive at the end of the search.
      - `expected_duration` integer: Estimated time left before the Archive Search completes, in seconds.
      - `from` string, date-time, required: Start of the searched time range, as an ISO 8601 timestamp.
      - `name` string, required: Name of the Archive Search.
      - `query` string, required: Log search query used to filter the archived logs.
      - `rehydration` ArchiveSearchRehydration: Rehydration settings of the Archive Search. Absent when the search only scans the archive without indexing the results.
        - `max_rehydrated_events` integer, required: Maximum number of events to rehydrate.
        - `retention_days` integer, required: Number of days the rehydrated logs are retained for.
        - `tier` 'standard' | 'flex', required: Storage tier the matched logs are rehydrated into.
      - `status` 'RUNNING' | 'COMPLETED' | 'FAILED' | 'CANCELLED' | 'QUOTA_REACHED' | 'EXPIRED', required: Current state of an Archive Search.
      - `to` string, date-time, required: End of the searched time range, as an ISO 8601 timestamp.
    - `id` string, required: Unique identifier of the Archive Search.
    - `type` 'archive_search', required: Archive Search resource type.

## Other responses

- `400`: Bad Request
- `403`: Forbidden
- `404`: Not Found
- `429`: Too many requests

---

[API](https://skmtc.dev/datadog/apis/datadog-api-v2-collection.md) - [All operations](https://skmtc.dev/datadog/apis/datadog-api-v2-collection/llms.txt) - [OpenAPI document](https://skmtc.dev/datadog/apis/datadog-api-v2-collection/revisions/3f70db624329?raw)
