---
name: epochal-api
description: Call the Epochal Time Portal API over HTTP — POST /v1/time-portal/search (point-in-time search), POST /v1/time-portal/fetch (archived pages), and time-gated Linux sandboxes.
---

# Epochal API Platform

Search and fetch archived web pages as of any past timestamp, and run code in a time-gated sandbox, with one API key.

## Calling the API

- Base URL: `https://api.epochal.com`
- Authenticate every request with the `x-api-key` header; read the key from `EPOCHAL_API_KEY` rather than hardcoding it.
- Set the point-in-time cutoff with the `Accept-Datetime` header, required on Search, Fetch, and sandbox creation only (past RFC 3339, ISO 8601, or HTTP-date; `>= 1970-01-01T00:00:00Z` for Search/Fetch, `>= 2023-04-01T00:00:00Z` for sandbox creation). Other sandbox endpoints do not take it.
- Bodies are JSON except where the reference says otherwise: sandbox file contents are raw bytes in both directions (`PUT` and `GET` on `/v1/time-portal/sandbox/{id}/files`), and Fetch with `format: "page"` returns the archived document itself with its outcome in the `x-fetch-status-code` and `x-fetch-status-message` headers.
- Some responses have no body: `204` from terminating a sandbox or removing a file, and `416` (with `Content-Range`) from a file read past the end. Check the status code before decoding.
- Read an endpoint's reference before calling it for exact field constraints, sample requests, and error codes.

## Endpoints

- `POST /v1/time-portal/search` — Search and rank the web as it existed in the past. [Reference](https://docs.epochal.com/reference/timePortalSearch.md)
- `POST /v1/time-portal/fetch` — Retrieve an archived URL as it existed at `Accept-Datetime`, either as markdown with metadata (`format: structured`) or as the raw document (`format: page`). [Reference](https://docs.epochal.com/reference/timePortalFetch.md)
- `GET /v1/time-portal/sandbox` — List the organization's sandboxes across all states. [Reference](https://docs.epochal.com/reference/sandboxList.md)
- `POST /v1/time-portal/sandbox` — Create and boot a Linux sandbox gated to `Accept-Datetime`. The sandbox starts in the `creating` state and becomes `live` once it is ready to run commands. [Reference](https://docs.epochal.com/reference/sandboxCreate.md)
- `GET /v1/time-portal/sandbox/{id}` — Retrieve a sandbox by ID. When `wait` is set and `state` is `creating`, the request waits until the sandbox becomes `live` or `failed`. Sandboxes in any other state return immediately. [Reference](https://docs.epochal.com/reference/sandboxGet.md)
- `DELETE /v1/time-portal/sandbox/{id}` — Terminate the sandbox immediately. Its files and command output are permanently deleted, and usage metering stops. Terminating an already-ended sandbox succeeds. [Reference](https://docs.epochal.com/reference/sandboxTerminate.md)
- `POST /v1/time-portal/sandbox/{id}/execs` — Start a command asynchronously in a `live` sandbox. Returns the command `id` immediately, and you can read output and exit status from the output endpoint. Commands run as `root` in the image's `HOME`. Multiple commands can run concurrently, and an active command resets `idle_timeout`. Send an `Idempotency-Key` header to make retries safe. [Reference](https://docs.epochal.com/reference/sandboxExec.md)
- `GET /v1/time-portal/sandbox/{id}/execs/{exec_id}/output` — Read stdout and stderr frames from the given byte offsets, along with `exit` once the command finishes. When `wait` is set, the request waits until new output arrives or the command exits. Keep polling from the updated offsets until `exit` is present. Output is retained only while the sandbox is `live` and returns `409` after it ends. [Reference](https://docs.epochal.com/reference/sandboxExecOutput.md)
- `POST /v1/time-portal/sandbox/{id}/execs/{exec_id}/input` — Send stdin bytes, close stdin (`eof`), or send a signal to a running command. Use `seq` starting from `0` to order input requests safely across retries. Stdin closes immediately after `stdin_b64` unless `stdin_open` was enabled when starting the command. Returns `409` if the command has already exited. [Reference](https://docs.epochal.com/reference/sandboxExecInput.md)
- `GET /v1/time-portal/sandbox/{id}/files` — Read a byte range of a file. Returns `206` with `Content-Range: bytes <first>-<last>/<size>` clamped to the file length; `200` for an empty file; and `416` with `Content-Range: bytes */<size>` when the range starts past the end. `bytes=<first>-` reads up to 16 MiB from `first`. [Reference](https://docs.epochal.com/reference/sandboxReadFile.md)
- `PUT /v1/time-portal/sandbox/{id}/files` — Write up to 8 MiB at `offset`, creating any missing parent directories. Writing at offset 0 replaces the file, while a non-zero offset writes at that byte position so larger files can be uploaded in chunks. [Reference](https://docs.epochal.com/reference/sandboxWriteFile.md)
- `DELETE /v1/time-portal/sandbox/{id}/files` — Remove a file or an empty directory, or a directory and everything under it with `recursive`. A non-empty directory without `recursive` is a `400`. [Reference](https://docs.epochal.com/reference/sandboxRemoveFile.md)
- `GET /v1/time-portal/sandbox/{id}/files/stat` — Retrieve a file's type, size, permissions, and modification time. [Reference](https://docs.epochal.com/reference/sandboxStatFile.md)
- `GET /v1/time-portal/sandbox/{id}/files/list` — List directory entries with each `path` relative to the requested directory. [Reference](https://docs.epochal.com/reference/sandboxListFiles.md)

## Guides

- [Overview](https://docs.epochal.com/docs/get-started/introduction.md): The Epochal API allows you to deploy your agent in a rich point-in-time environment across the web.
- [Authentication](https://docs.epochal.com/docs/get-started/authentication.md): All requests are authenticated via the x-api-key header.
- [Pricing](https://docs.epochal.com/docs/get-started/pricing.md): Every organization gets 100 search and fetch requests and one hour of sandbox time; for more, contact us.
- [Rate Limits](https://docs.epochal.com/docs/get-started/rate-limits.md): Organization and per-IP rate limits, retry behavior, and pacing guidance.
- [Quickstart](https://docs.epochal.com/docs/time-portal/quickstart.md): Get started with the search, fetch, and sandbox Time Portal APIs.
- [How the Instant Works](https://docs.epochal.com/docs/time-portal/how-the-instant-works.md): Every Time Portal request evaluates against a point-in-time cutoff specified in Accept-Datetime.
- [World Entities](https://docs.epochal.com/docs/time-portal/entities.md): Search and fetch return companies, people, places, crypto assets, and a city's weather as world entities that share one envelope.
- [Search](https://docs.epochal.com/docs/time-portal/search.md): Time Portal search gives ranked results from the time-gated web.
- [Fetch](https://docs.epochal.com/docs/time-portal/fetch.md): Time Portal fetch gives an archived copy of a page from the time-gated web.
- [Overview](https://docs.epochal.com/docs/time-portal/sandbox.md): A sandbox is a Linux virtual machine whose clock and network are set to an instant.
- [Commands and Files](https://docs.epochal.com/docs/time-portal/sandbox/commands-and-files.md): A command is a program you start in a live sandbox.
- [Lifecycle and Limits](https://docs.epochal.com/docs/time-portal/sandbox/lifecycle-limits-and-pricing.md): A sandbox boots, runs while it is live, and ends at a timeout, a terminate, or a failure.
- [Images and Network](https://docs.epochal.com/docs/time-portal/sandbox/images-and-network.md): A sandbox boots the Ubuntu build chosen by its instant and reaches only what its network setting allows.
- [Clients](https://docs.epochal.com/docs/clients.md): Open-source CLI, MCP server, and Rust and Python SDKs for the Epochal API.
- [CLI](https://docs.epochal.com/docs/clients/cli.md): Run an agent inside the Time Portal with one command.
- [MCP Server](https://docs.epochal.com/docs/clients/mcp-server.md): Expose time-gated web search and fetch tools to MCP-compatible agents.
- [SDKs](https://docs.epochal.com/docs/clients/sdks.md): The epochal-api and epochal-sandbox packages for Rust and Python.
- [For Agents](https://docs.epochal.com/docs/resources/for-agents.md): Machine-readable markdown docs, Agent Skill installation, MCP setup, and guidelines for integrating Time Portal into AI agents.
- [FAQ](https://docs.epochal.com/docs/resources/faq.md): Frequently asked questions about Time Portal, API keys, the free trial, rate limits, and errors.
- [Getting Help](https://docs.epochal.com/docs/resources/getting-help.md): Support channels, status page, and what to include when reporting an API issue.
- [Versioning and Deprecation](https://docs.epochal.com/docs/resources/versioning-and-deprecation.md): Backward-compatible changes ship without a new path version; breaking changes ship under a new version such as /v2/.
- [Errors](https://docs.epochal.com/docs/resources/errors.md): Standard JSON error envelope, HTTP status codes, sandbox failure types, and retry rules.

## Changelog

- [Changelog](https://docs.epochal.com/changelog.md): Product updates and announcements from Epochal.

The whole corpus in one file is at https://docs.epochal.com/llms-full.txt.
