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

# Time Machine

> Search the web as of a past time with snapshot_as_of on the Search API, then read the same pages at that time with the Context API.

## Overview

Time Machine sets a cutoff for a search. Add `snapshot_as_of` to a `POST /search` request, and each result comes from the copy of the page that Perplexity saved at or before that time. Use it when a task depends on what was knowable at an earlier moment, such as evaluating an agent on questions with known answers or backtesting a forecast.

Each time Perplexity reads a page for its web index, it saves a copy with the time it was saved. A search with `snapshot_as_of` uses those copies:

* Search looks only at pages published by the cutoff.
* The cutoff is compared with the time a copy was saved, not with a date shown on the page.
* Each result uses the page's latest copy saved at or before the cutoff. Its `title`, `snippet`, and `date` come from that copy.

The response has the same format as any other search.

| | |
| - | - |
| Value | An RFC 3339 time with a time zone, such as `2026-11-01T00:00:00Z` or `2026-11-01T09:30:00+02:00` |
| Range | Not in the future, and not more than 365 days ago |
| Search types | `web` (default) and `fast` |
| Filters you can add | [`search_domain_filter`](https://docs.perplexity.ai/docs/search/filters/domain-filter) and [`search_language_filter`](https://docs.perplexity.ai/docs/search/filters/language-filter) |
| Cannot be combined with | `search_recency_filter` and the [date filters](https://docs.perplexity.ai/docs/search/filters/date-time-filters.md) |

## Search as of a past time

This request searches python.org as the web was 30 days ago.

First, [install a library and set `PERPLEXITY_API_KEY`](https://docs.perplexity.ai/docs/search/quickstart#installation).

```python Python theme={null}
from datetime import datetime, timedelta, timezone

from perplexity import Perplexity

client = Perplexity()

snapshot_as_of = (datetime.now(timezone.utc) - timedelta(days=30)).strftime("%Y-%m-%dT%H:%M:%SZ")

search = client.search.create(
    query="latest stable Python release",
    snapshot_as_of=snapshot_as_of,
    search_domain_filter=["python.org"],
    max_results=5
)

for result in search.results:
    print(f"{result.title}: {result.url}")
```

```typescript Typescript theme={null}
import Perplexity from '@perplexity-ai/perplexity_ai';

const client = new Perplexity();

const snapshotAsOf = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000).toISOString();

const search = await client.search.create({
    query: "latest stable Python release",
    snapshot_as_of: snapshotAsOf,
    search_domain_filter: ["python.org"],
    max_results: 5
});

for (const result of search.results) {
    console.log(`${result.title}: ${result.url}`);
}
```

```bash cURL theme={null}
curl --fail-with-body --max-time 90 https://api.perplexity.ai/search \
  -H "Authorization: Bearer $PERPLEXITY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "latest stable Python release",
    "snapshot_as_of": "2026-11-01T00:00:00Z",
    "search_domain_filter": ["python.org"],
    "max_results": 5
  }' | jq
```

The cURL example uses a fixed time, so replace it with one from the last 365 days.

## Read pages at the same time

A search result has a snippet, not the full page. To read the pages a search found, send their URLs to the [Context API](https://docs.perplexity.ai/docs/context/formats-and-freshness.md#pages-at-a-past-time) with the same `snapshot_as_of`. Both steps then use the same cutoff.

```python Python theme={null}
from datetime import datetime, timedelta, timezone

from perplexity import Perplexity

client = Perplexity()

snapshot_as_of = (datetime.now(timezone.utc) - timedelta(days=30)).strftime("%Y-%m-%dT%H:%M:%SZ")

search = client.search.create(
    query="latest stable Python release",
    snapshot_as_of=snapshot_as_of,
    search_domain_filter=["python.org"],
    max_results=3
)

response = client.context.create(
    urls=[result.url for result in search.results],
    snapshot_as_of=snapshot_as_of,
)

for result in response.results:
    if result.status.type == "ok":
        print(result.url, result.metadata.fetched_at)
```

```typescript Typescript theme={null}
import Perplexity from '@perplexity-ai/perplexity_ai';

const client = new Perplexity();

const snapshotAsOf = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000).toISOString();

const search = await client.search.create({
    query: "latest stable Python release",
    snapshot_as_of: snapshotAsOf,
    search_domain_filter: ["python.org"],
    max_results: 3
});

const response = await client.context.create({
    urls: search.results.map((result) => result.url),
    snapshot_as_of: snapshotAsOf
});

for (const result of response.results) {
    if (result.status.type === 'ok') {
        console.log(result.url, result.metadata?.fetched_at);
    }
}
```

```bash cURL theme={null}
SNAPSHOT_AS_OF="2026-11-01T00:00:00Z"

URLS=$(curl --fail-with-body --max-time 90 https://api.perplexity.ai/search \
  -H "Authorization: Bearer $PERPLEXITY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "latest stable Python release",
    "snapshot_as_of": "'"$SNAPSHOT_AS_OF"'",
    "search_domain_filter": ["python.org"],
    "max_results": 3
  }' | jq -c '[.results[].url]')

curl --fail-with-body --max-time 90 https://api.perplexity.ai/v1/context \
  -H "Authorization: Bearer $PERPLEXITY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "urls": '"$URLS"',
    "snapshot_as_of": "'"$SNAPSHOT_AS_OF"'"
  }' | jq
```

## Errors

A request that breaks one of the rules above returns HTTP 400 with `"type": "invalid_request"`:

| Request | `error.message` |
| - | - |
| The time has no time zone or is not RFC 3339 | `snapshot_as_of must be an RFC 3339 timestamp with a timezone` |
| The time is in the future | `snapshot_as_of must not be in the future` |
| The time is more than 365 days ago | `snapshot_as_of must not be older than 365 days` |
| `search_type` is `people` | `snapshot_as_of requires web or fast search` |
| `search_recency_filter` or a date filter is also set | `snapshot_as_of cannot be combined with recency, publication date, or last updated filters` |

## Next Steps

> [card] [Context API: Pages at a Past Time](https://docs.perplexity.ai/docs/context/formats-and-freshness.md#pages-at-a-past-time)
>
> Read full pages as they were stored at or before a time.

> [card] [Domain Filter](https://docs.perplexity.ai/docs/search/filters/domain-filter.md)
>
> Include or exclude specific domains, paths, and top-level domains.

> [card] [How Search Works](https://docs.perplexity.ai/docs/search/overview.md)
>
> Result fields, several queries per request, and request limits.

> [card] [API Reference](https://docs.perplexity.ai/api-reference/search-post.md)
>
> Every request parameter, the response schema, and error responses.
