---
title: Search archived sessions
description: Search archived RUM sessions. Use meta.page.next_cursor to retrieve the next page.
breadcrumbs: Docs > API > Search archived sessions
---

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

# Search archived sessions

## v2 (latest)

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

### Overview

Search archived RUM sessions. Use `meta.page.next_cursor` to retrieve the next page.

This endpoint requires the `rum_rehydration_filter_read` 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*] | object  | Archived-session query. A window wider than configured archive retention is narrowed before searching.                                                                                           |
| attributes   | cursor                  | string  | Opaque next-page cursor. Keep the query, time range, and hide_retained value unchanged.                                                                                                          |
| attributes   | from [*required*]       | int64   | Start of the range in Unix milliseconds. Must be positive and earlier than to.                                                                                                                   |
| attributes   | hide_retained           | boolean | When true, exclude sessions already present in hot RUM storage. When false, those sessions can appear in the results. Keep this value unchanged when continuing with a cursor. Default: `false`. |
| attributes   | limit                   | int32   | Page size, at most 1000 (default 50). Values at or below zero use 50. Default: `50`.                                                                                                             |
| attributes   | query [*required*]      | string  | RUM search query. Must not be empty.                                                                                                                                                             |
| attributes   | to [*required*]         | int64   | End of the range in Unix milliseconds.                                                                                                                                                           |
| data         | id                      | string  | Optional resource identifier.                                                                                                                                                                    |
| data         | type                    | string  | JSON:API resource type.                                                                                                                                                                          |
{% /tab %}

{% tab label="Example" %}
```json
{
  "data": {
    "type": "rum_archive_sessions_request",
    "attributes": {
      "query": "service:rum18600-fixture",
      "from": 1636024271000,
      "to": 1636629071000,
      "limit": 1
    }
  }
}
```
{% /tab %}
{% /tabs %}

### Response

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

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

| Parent field    | Field                        | Type      | Description                                                                                                                                                                                                             |
| --------------- | ---------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|                 | data [*required*]            | [object]  | Archived sessions.                                                                                                                                                                                                      |
| data            | attributes [*required*]      | object    | Archived session metadata.                                                                                                                                                                                              |
| attributes      | account_id [*required*]      | string    | Session account id, or null when unavailable.                                                                                                                                                                           |
| attributes      | anonymous_id [*required*]    | string    | Session anonymous id, or null when unavailable.                                                                                                                                                                         |
| attributes      | application_id [*required*]  | uuid      | Application UUID.                                                                                                                                                                                                       |
| attributes      | country [*required*]         | string    | Session country, or null when unavailable.                                                                                                                                                                              |
| attributes      | recovery_status [*required*] | object    | Session recovery state. A missing recovery record can be represented as null. Optional request_id and recovered_at are omitted when unavailable.                                                                        |
| recovery_status | recovered_at                 | date-time | Recovery timestamp, when available.                                                                                                                                                                                     |
| recovery_status | request_id                   | string    | Associated recovery request ID.                                                                                                                                                                                         |
| recovery_status | status [*required*]          | enum      | Session availability or recovery state. `RECOVERED` indicates that the session is ready to query. Allowed enum values: `AVAILABLE`, `PENDING`, `PROCESSING`, `RECOVERED`, `FAILED`, `RETAINED`, `EXPIRED`, `CANCELLED`. |
| attributes      | service [*required*]         | string    | Service name.                                                                                                                                                                                                           |
| attributes      | session_id [*required*]      | string    | Session identifier.                                                                                                                                                                                                     |
| attributes      | timestamp [*required*]       | int64     | Session timestamp in Unix milliseconds.                                                                                                                                                                                 |
| attributes      | user_id [*required*]         | string    | Session user id, or null when unavailable.                                                                                                                                                                              |
| attributes      | version [*required*]         | string    | Session version, or null when unavailable.                                                                                                                                                                              |
| data            | id [*required*]              | string    | Resource identifier.                                                                                                                                                                                                    |
| data            | type [*required*]            | enum      | JSON:API resource type. Allowed enum values: `rum_archive_session`.                                                                                                                                                     |
|                 | meta [*required*]            | object    | Search metadata.                                                                                                                                                                                                        |
| meta            | page [*required*]            | object    | Search pagination.                                                                                                                                                                                                      |
| page            | next_cursor                  | string    | Opaque continuation cursor. Omitted when no further page is available.                                                                                                                                                  |
| page            | total_count [*required*]     | int64     | Search result count. Can be zero on continuation pages even when sessions are returned. Use `next_cursor` to determine whether more pages are available.                                                                |
{% /tab %}

{% tab label="Example" %}
```json
{
  "data": [
    {
      "attributes": {
        "account_id": "account-123",
        "anonymous_id": "anonymous-123",
        "application_id": "a33671aa-24fd-4dcd-ba4b-5bbdbafe7690",
        "country": "US",
        "recovery_status": {
          "recovered_at": "example",
          "request_id": "11111111-1111-4111-8111-111111111111",
          "status": "AVAILABLE"
        },
        "service": "web",
        "session_id": "00000000-0000-4000-8000-000000000001",
        "timestamp": 1789905600000,
        "user_id": "user-123",
        "version": "1.0.0"
      },
      "id": "11111111-1111-4111-8111-111111111111",
      "type": "rum_archive_session"
    }
  ],
  "meta": {
    "page": {
      "next_cursor": "example",
      "total_count": 0
    }
  }
}
```
{% /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="429" %}
Too Many Requests

{% 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
# 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/sessions" \
-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": {
    "type": "rum_archive_sessions_request",
    "attributes": {
      "query": "service:rum18600-fixture",
      "from": 1636024271000,
      "to": 1636629071000,
      "limit": 1
    }
  }
}
EOF
```
{% /tab %}
{% /tabs %}
