---
title: Create a recovery request
description: Start targeted or query-based batch recovery.
breadcrumbs: Docs > API > Create a recovery request
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# Create a recovery request

## v2 (latest)

| Datadog site      | API endpoint                                                   |
| ----------------- | -------------------------------------------------------------- |
| app.datadoghq.com | POST https://api.datadoghq.com/api/v2/rum/recover/requests     |
| us3.datadoghq.com | POST https://api.us3.datadoghq.com/api/v2/rum/recover/requests |
| us5.datadoghq.com | POST https://api.us5.datadoghq.com/api/v2/rum/recover/requests |
| app.datadoghq.eu  | POST https://api.datadoghq.eu/api/v2/rum/recover/requests      |
| ap1.datadoghq.com | POST https://api.ap1.datadoghq.com/api/v2/rum/recover/requests |
| ap2.datadoghq.com | POST https://api.ap2.datadoghq.com/api/v2/rum/recover/requests |
| uk1.datadoghq.com | POST https://api.uk1.datadoghq.com/api/v2/rum/recover/requests |
| app.ddog-gov.com  | POST https://api.ddog-gov.com/api/v2/rum/recover/requests      |
| us2.ddog-gov.com  | POST https://api.us2.ddog-gov.com/api/v2/rum/recover/requests  |

### Overview

Start targeted or query-based batch recovery. Use the returned `data.id` to poll the recovery request for progress. Batch creation checks a fresh recoverable-session estimate against the configured maximum (100,000 by default), accepting estimates equal to the maximum. Use the count operation to check the current maximum; creation can still reject a changed estimate. Narrow the query or time range if the maximum is exceeded.

Creation is not idempotent. After an uncertain response, check session search or batch listing before retrying.

This endpoint requires the `rum_rehydration_index` permission.

### Request

#### Body Data (required)

JSON:API request body.

{% tabs %}
{% tab label="Model" %}
| Parent field            | Field                       | Type     | Description                                                                                                                                                                                                                     |
| ----------------------- | --------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|                         | data [*required*]           | object   | JSON:API resource.                                                                                                                                                                                                              |
| data                    | attributes [*required*]     | <oneOf>  | Targeted recovery (the default) or query-based batch recovery.                                                                                                                                                                  |
| attributes              | <request_type=sessions>     | object   | Recover 1 to 100 explicit archived sessions. Session IDs must be unique within the request.                                                                                                                                     |
| <request_type=sessions> | request_type                | enum     | Targeted recovery. Omitted request_type defaults to sessions. Allowed enum values: `sessions`. Default: `sessions`.                                                                                                             |
| <request_type=sessions> | sessions [*required*]       | [object] | Sessions to recover.                                                                                                                                                                                                            |
| sessions                | application_id [*required*] | uuid     | Application UUID.                                                                                                                                                                                                               |
| sessions                | session_id [*required*]     | uuid     | Session UUID.                                                                                                                                                                                                                   |
| attributes              | <request_type=batch>        | object   | Recover sessions selected by a query. The range cannot exceed 180 days; from cannot be more than 4 years ago and to cannot be more than 1 hour in the future. Session availability depends on the configured archive retention. |
| <request_type=batch>    | estimated_count             | int64    | Optional client estimate. Creation validates and stores a fresh server estimate instead of this value.                                                                                                                          |
| <request_type=batch>    | from [*required*]           | int64    | Start of the range in Unix milliseconds. Must be positive and earlier than to.                                                                                                                                                  |
| <request_type=batch>    | query [*required*]          | string   | RUM search query. Not blank, at most 4096 bytes for batch creation and count.                                                                                                                                                   |
| <request_type=batch>    | request_type [*required*]   | enum     | Query-based batch recovery. Allowed enum values: `batch`.                                                                                                                                                                       |
| <request_type=batch>    | to [*required*]             | int64    | End of the range in Unix milliseconds.                                                                                                                                                                                          |
| data                    | type                        | string   | JSON:API resource type.                                                                                                                                                                                                         |
{% /tab %}

{% tab label="Example" %}
```json
{
  "data": {
    "attributes": {
      "request_type": "sessions",
      "sessions": [
        {
          "application_id": "a33671aa-24fd-4dcd-ba4b-5bbdbafe7690",
          "session_id": "00000000-0000-4000-8000-000000000001"
        }
      ]
    },
    "type": "rum_recovery_request"
  }
}
```
{% /tab %}
{% /tabs %}

### Response

{% tabs %}
{% tab label="202" %}
Accepted

{% tabs %}
{% tab label="Model" %}
JSON:API document.

| Parent field | Field                           | Type      | Description                                                                                                                                                                                                       |
| ------------ | ------------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|              | data [*required*]               | object    | JSON:API resource.                                                                                                                                                                                                |
| data         | attributes [*required*]         | object    | Accepted recovery request.                                                                                                                                                                                        |
| attributes   | created_at [*required*]         | date-time | Creation time.                                                                                                                                                                                                    |
| attributes   | discovery_status                | enum      | Batch discovery state. QUEUED indicates that the request is waiting for processing capacity. Allowed enum values: `QUEUED`, `PENDING`, `SLICING`, `DISCOVERED`, `PROCESSING`, `COMPLETED`, `FAILED`, `CANCELLED`. |
| attributes   | estimated_count                 | int64     | Batch estimate stored at creation, when present. New batches use a fresh server estimate; older batches may contain a client-supplied estimate.                                                                   |
| attributes   | failed_sessions [*required*]    | int64     | Failed session count.                                                                                                                                                                                             |
| attributes   | processed_sessions [*required*] | int64     | Processed session count.                                                                                                                                                                                          |
| attributes   | status [*required*]             | enum      | Recovery request state. Allowed enum values: `PENDING`, `PROCESSING`, `COMPLETED`, `FAILED`, `CANCELLED`, `EXPIRED`.                                                                                              |
| attributes   | total_sessions                  | int64     | Total targeted sessions. Omitted while a batch total is unknown.                                                                                                                                                  |
| data         | id [*required*]                 | string    | Resource identifier.                                                                                                                                                                                              |
| data         | type [*required*]               | enum      | JSON:API resource type. Allowed enum values: `rum_recovery_request`.                                                                                                                                              |
{% /tab %}

{% tab label="Example" %}
```json
{
  "data": {
    "attributes": {
      "created_at": "2026-09-21T12:00:00Z",
      "discovery_status": "QUEUED",
      "estimated_count": 0,
      "failed_sessions": 0,
      "processed_sessions": 0,
      "status": "PENDING",
      "total_sessions": 0
    },
    "id": "11111111-1111-4111-8111-111111111111",
    "type": "rum_recovery_request"
  }
}
```
{% /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="401" %}
Unauthorized

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

| Field               | Type  | Description                                                                                   |
| ------------------- | ----- | --------------------------------------------------------------------------------------------- |
| errors [*required*] | [any] | Errors as plain-text messages or JSON:API error objects containing status, title, and detail. |
{% /tab %}

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

{% tab label="403" %}
Forbidden

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

| Field               | Type  | Description                                                                                   |
| ------------------- | ----- | --------------------------------------------------------------------------------------------- |
| errors [*required*] | [any] | Errors as plain-text messages or JSON:API error objects containing status, title, and detail. |
{% /tab %}

{% tab label="Example" %}
```json
{
  "errors": [
    "Forbidden"
  ]
}
```
{% /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="409" %}
Conflict. Targeted sessions are already retained, in flight, or previously failed, or a concurrent batch was created.

{% 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, or the batch recovery queue is full.

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

| Field               | Type  | Description                                                                                   |
| ------------------- | ----- | --------------------------------------------------------------------------------------------- |
| errors [*required*] | [any] | Errors as plain-text messages or JSON:API error objects containing status, title, and detail. |
{% /tab %}

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

### Code Example

{% tabs %}
{% tab label="Curl" %}
```bash
## batch

# 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
export DD_API_KEY="<DD_API_KEY>"
export DD_APP_KEY="<DD_APP_KEY>"

curl -X POST "https://api.${DD_SITE}/api/v2/rum/recover/requests" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "estimated_count": 100,
      "from": 1789905600000,
      "query": "service:web",
      "request_type": "batch",
      "to": 1789992000000
    },
    "type": "rum_recovery_request"
  }
}
EOF

## default

# 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
export DD_API_KEY="<DD_API_KEY>"
export DD_APP_KEY="<DD_APP_KEY>"

curl -X POST "https://api.${DD_SITE}/api/v2/rum/recover/requests" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "sessions": [
        {
          "application_id": "a33671aa-24fd-4dcd-ba4b-5bbdbafe7690",
          "session_id": "00000000-0000-4000-8000-000000000001"
        }
      ]
    },
    "type": "rum_recovery_request"
  }
}
EOF

## targeted

# 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
export DD_API_KEY="<DD_API_KEY>"
export DD_APP_KEY="<DD_APP_KEY>"

curl -X POST "https://api.${DD_SITE}/api/v2/rum/recover/requests" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "sessions": [
        {
          "application_id": "a33671aa-24fd-4dcd-ba4b-5bbdbafe7690",
          "session_id": "00000000-0000-4000-8000-000000000001"
        }
      ]
    },
    "type": "rum_recovery_request"
  }
}
EOF
```
{% /tab %}
{% /tabs %}
