Time Portal · Guides

Quickstart

Get started with the search, fetch, and sandbox Time Portal APIs.

Try it in the playground

The fastest way to start using the Time Portal is through the playground in the console. No API keys needed. When you're ready to call the API from your own code, follow the steps below.

Open Playground

Get an API key

Create a key in the console and set it in your environment.

Get API Key

Shell

bash

export EPOCHAL_API_KEY="ek_…"

Pick the instant

Every Time Portal request sends the instant in the Accept-Datetime header. The instant must be in the past and on or after 1970-01-01T00:00:00Z. This tutorial uses 2026-03-01T00:00:00Z for every request, and every response echoes it back in as_of. For accepted header formats, see How the Instant Works.

Send a query to POST/v1/time-portal/search to search across time.

curl https://api.epochal.com/v1/time-portal/search \
  -H "x-api-key: $EPOCHAL_API_KEY" \
  -H "Accept-Datetime: 2026-03-01T00:00:00Z" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "european battery gigafactory delays",
    "num_results": 2
  }'

The response looks like this:

JSON

json

{
  "as_of": "2026-03-01T00:00:00Z",
  "request_id": "7c2e5f0a-93b4-4d1e-a6f8-2b0c9e4d7a15",
  "results": [
    {
      "title": "Battery plant start pushed back to late 2027",
      "url": "https://news.example.com/energy/battery-plant-delay",
      "snippet": "The cell maker said commissioning would slip by three quarters…",
      "published_at": "2026-02-11T06:12:00Z",
      "domain": "example.com",
      "language": "en",
      "entity": null
    },
    {
      "title": "Gigafactory timelines slip across Europe",
      "url": "https://analysis.example.org/energy/gigafactory-timelines",
      "snippet": "Three of the five plants announced for 2026 now target 2027 or later…",
      "published_at": "2026-01-28T09:00:00Z",
      "domain": "example.org",
      "language": "en",
      "entity": null
    }
  ]
}

Fetch

Fetch a url at the same instant as your search with POST/v1/time-portal/fetch.

curl https://api.epochal.com/v1/time-portal/fetch \
  -H "x-api-key: $EPOCHAL_API_KEY" \
  -H "Accept-Datetime: 2026-03-01T00:00:00Z" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://news.example.com/energy/battery-plant-delay",
    "max_characters": 2000
  }'

The response looks like this:

JSON

json

{
  "as_of": "2026-03-01T00:00:00Z",
  "request_id": "7c2e5f0a-93b4-4d1e-a6f8-2b0c9e4d7a15",
  "status": "success",
  "id": "6b81feebde1a4821a125fb307894e7ad",
  "url": "https://news.example.com/energy/battery-plant-delay",
  "final_url": "https://news.example.com/energy/battery-plant-delay/",
  "title": "Battery plant start pushed back to late 2027",
  "description": "The cell maker said commissioning would slip.",
  "author": "Jane Doe",
  "published_at": "2026-02-11T06:12:00Z",
  "language": "en",
  "content": "# Battery plant start pushed back to late 2027\n\nThe cell maker said…",
  "truncated": true,
  "entity": null
}

content is the page as markdown.

Sandbox

A sandbox is a Linux virtual machine whose clock starts at the instant. With "network": "time-portal", the sandbox interacts with the web time-portal'd to the past.

The following script runs one command on a new sandbox and prints its output.

Python

py

import base64
import os
import sys

import requests

API = "https://api.epochal.com/v1/time-portal/sandbox"
HEADERS = {"x-api-key": os.environ["EPOCHAL_API_KEY"]}


def call(method, path="", **kwargs):
    response = requests.request(method, API + path, timeout=90, **kwargs)
    response.raise_for_status()
    return response.json() if response.content else None


sandbox = call(
    "POST",
    headers={**HEADERS, "Accept-Datetime": "2026-03-01T00:00:00Z"},
    json={"network": "time-portal"},
)
try:
    while sandbox["state"] == "creating":
        sandbox = call("GET", f"/{sandbox['id']}", headers=HEADERS, params={"wait": "55s"})
    if sandbox["state"] != "live":
        raise RuntimeError(f"sandbox {sandbox['state']}: {sandbox['error']}")

    exec_id = call(
        "POST",
        f"/{sandbox['id']}/execs",
        headers=HEADERS,
        json={"argv": ["python3", "-c", "import datetime; print(datetime.date.today())"]},
    )["id"]

    output = {"stdout": bytearray(), "stderr": bytearray()}
    while True:
        page = call(
            "GET",
            f"/{sandbox['id']}/execs/{exec_id}/output",
            headers=HEADERS,
            params={
                "stdout_offset": len(output["stdout"]),
                "stderr_offset": len(output["stderr"]),
                "wait": "55s",
            },
        )
        for frame in page["frames"]:
            output[frame["stream"]] += base64.b64decode(frame["data_b64"])
        if page["exit"]:
            break

    print(output["stdout"].decode(errors="replace"), end="")
    print(output["stderr"].decode(errors="replace"), end="", file=sys.stderr)
    print(page["exit"])
finally:
    call("DELETE", f"/{sandbox['id']}", headers=HEADERS)

It prints 2026-03-01 and {'reason': 'exited', 'code': 0}: the sandbox's clock starts at the specified instant.

  • Creating a sandbox returns 202 immediately with state: "creating". The first loop long-polls GET /v1/time-portal/sandbox/{id}?wait=55s until the sandbox becomes live.
  • Starting a command returns its id immediately. The second loop reads output from each byte offset until exit is present, buffering raw bytes before decoding so multi-byte UTF-8 sequences are not split across frames.
  • The finally block terminates the sandbox. Once a sandbox stops, its filesystem and command output are discarded.

CLI

The epochal CLI runs an agent inside a Time Portal sandbox gated to a past timestamp.

Shell

bash

epochal time-portal run --model claude-sonnet-5-5 --as-of 2024-10-06 \
  "Will AI research win a Nobel Prize this year?"

To install it and run your first agent, see the CLI page. The Clients section also has an MCP server and SDKs for Rust and Python.

Next steps

CLI

Run an agent inside the Time Portal with one command.

Search

Time Portal search gives ranked results from the time-gated web.

Fetch

Time Portal fetch gives an archived copy of a page from the time-gated web.

Sandbox

A sandbox is a Linux virtual machine whose clock and network are set to an instant.

How the Instant Works

Every Time Portal request evaluates against a point-in-time cutoff specified in Accept-Datetime.

Errors

Standard JSON error envelope, HTTP status codes, sandbox failure types, and retry rules.