Time Portal · Sandbox
Overview
A sandbox is a Linux virtual machine whose clock and network are set to an instant. You can run commands and read and write files through its endpoints.
Endpoints
| Endpoint | Description |
|---|---|
| POST/v1/time-portal/sandbox | Create and boot a sandbox. Returns 202 immediately with state: "creating". |
| GET/v1/time-portal/sandbox | List organization sandboxes across all states, newest first. Filter by state; paginate with cursor and limit (1–100, default 50). |
| GET/v1/time-portal/sandbox/{id} | Retrieve a sandbox. Pass wait=55s to long-poll while creating until live or failed. |
| DELETE/v1/time-portal/sandbox/{id} | Terminate a sandbox immediately (204). Idempotent on already-ended sandboxes. |
| POST/v1/time-portal/sandbox/{id}/execs | Start a command asynchronously. Returns 200 with the command id. |
| GET/v1/time-portal/sandbox/{id}/execs/{exec_id}/output | Stream stdout/stderr frames from stdout_offset and stderr_offset, plus exit on completion. Supports wait and max_bytes. |
| POST/v1/time-portal/sandbox/{id}/execs/{exec_id}/input | Send stdin bytes, close stdin (eof), or send a POSIX signal to a running command. |
| PUT/v1/time-portal/sandbox/{id}/files | Write raw bytes to a file at path and offset. |
| GET/v1/time-portal/sandbox/{id}/files | Read a byte range from a file. |
| DELETE/v1/time-portal/sandbox/{id}/files | Delete a file or directory. |
| GET/v1/time-portal/sandbox/{id}/files/stat | Retrieve file type, size, permissions, and modification time. |
| GET/v1/time-portal/sandbox/{id}/files/list | List directory entries with cursor pagination. |
Every request takes x-api-key. Only create takes Accept-Datetime; later requests on the sandbox inherit its instant.
Asynchronous endpoints
| Endpoint | Returns | Then |
|---|---|---|
| Create | 202 at once, the sandbox creating | Get the sandbox with wait until live or failed |
| Command | 200 once the command has started, with its id | Read output with wait until exit is set |
Every other endpoint finishes its work before it returns. A request with wait returns as soon as the state changes or new output arrives, so you can poll in a loop without sleeping.
Create a sandbox
cURL
bash
curl https://api.epochal.com/v1/time-portal/sandbox \
-H "x-api-key: $EPOCHAL_API_KEY" \
-H "Accept-Datetime: 2026-03-01T00:00:00Z" \
-H "Idempotency-Key: 7d0c9b2e-backtest-42" \
-H "Content-Type: application/json" \
-d '{"network": "time-portal", "vcpus": 1, "memory_gib": 2, "timeout": "1h"}'| Header | Required | Value |
|---|---|---|
Accept-Datetime | Yes | The instant the sandbox's clock and network are set to, returned as its as_of. A past HTTP-date or RFC 3339 instant; one before the oldest build, 2023-04-01, is a 400. |
Idempotency-Key | No | Any unique string; a retry with the same key returns the same sandbox, so a retried create does not boot a second one. Reusing a key with a different body is a 409. |
Every body field is optional. A sandbox boots the newest Ubuntu build dated on or before as_of, with 1 vCPU and 2 GiB; see Images and Network. The free hour is sized for that default; a larger sandbox uses it up faster, so a 2 vCPU, 4 GiB one gets 30 minutes. See Pricing.
| Field | Default | What it does |
|---|---|---|
network | none | none: names do not resolve and no connection leaves the sandbox. time-portal: HTTP and HTTPS to the web as it stood at as_of, through Time Portal, and package mirrors set to it; each page read counts as one fetch request. See Images and Network. |
vcpus | 1 | Virtual CPUs reserved for the sandbox: 1, 2, 4, 8, or 16. |
memory_gib | 2 | Memory reserved, in GiB: 1, 2, 4, 8, 16, 32, or 64, at most 8 per vCPU. |
timeout | 1h | The sandbox ends this long after it boots, from 1m to 24h. It cannot be extended. |
idle_timeout | 10m, or timeout when that is shorter | The sandbox ends after this long with no command running and no request that starts a command, sends input, or writes or removes files; reads and polls do not count. From 1m to timeout. |
env | none | Environment variables for every command run in the sandbox; at most 128 and 32 KiB. |
metadata | {} | Custom key-value labels attached to the sandbox (up to 16 pairs). |
apps | [] | Prebuilt app names mounted read-only at /opt/epochal/bin (up to 8). Apps are current builds rather than builds from as_of; see Images and Network. |
Durations are whole numbers of hours, minutes, and seconds, in that order: 90s, 10m, 1h, 1h30m, or Go's 1h30m0s. Fractions such as 1.5h are refused; write 90m. Responses format each duration in its largest exact unit, so 1h30m is returned as 90m.
The create returns 202 with the sandbox creating. Until the sandbox is live, commands and file requests return 409.
cURL
bash
curl "https://api.epochal.com/v1/time-portal/sandbox/$SANDBOX_ID?wait=55s" \
-H "x-api-key: $EPOCHAL_API_KEY"The sandbox object
Create, get, and list return the same object.
JSON
json
{
"id": "sbx_7f3k9q2m4x8p1c6w",
"state": "live",
"as_of": "2026-03-01T00:00:00Z",
"network": "time-portal",
"vcpus": 1,
"memory_gib": 2,
"timeout": "1h",
"idle_timeout": "10m",
"created_at": "2026-11-02T18:04:11Z",
"booted_at": "2026-11-02T18:04:14Z",
"expires_at": "2026-11-02T19:04:14Z",
"ended_at": null,
"error": null,
"metadata": {},
"apps": []
}| Field | Meaning |
|---|---|
id | The sandbox's id. |
state | creating (accepted and booting), live (booted and accepting requests), ended (terminated, timed out, or idle-expired; files and command output have been deleted), or failed (failed to boot; error describes the cause). |
as_of | Point-in-time cutoff for the sandbox's clock and network, resolved from Accept-Datetime. |
network, vcpus, memory_gib, timeout, idle_timeout | Configuration as created, with defaults applied. |
created_at | Timestamp when sandbox creation was accepted. |
booted_at | Timestamp when the sandbox finished booting; metering starts here. null until live. |
expires_at | Latest timestamp when the sandbox will end (booted_at + timeout). |
ended_at | Timestamp when the sandbox ended. |
error | Why the sandbox failed or ended unexpectedly, with a message: expiry (lifetime_expired, idle_expired), a crash (out_of_memory, sandbox_lost), or billing (free_quota_exhausted, insufficient_credits, organization_suspended, spend_limit_reached). null otherwise, including after explicit termination. |
metadata | The labels it was created with. |
apps | The apps it was created with, each as a name and version; [] when none. |
Run a command
Start a command with POST/v1/time-portal/sandbox/{id}/execs and an argv, then read its output and exit with the output endpoint until exit is set. Output is kept only while the sandbox is live. See Commands and Files.
Sandbox lifetime
A sandbox ends at the first of its timeout, its idle_timeout, or a terminate. Once it ends, its files and the output of its commands are gone, and requests that run, read, or write in it return 409. See Lifecycle and Limits.
Errors
Errors use the same JSON shape as every other endpoint. Check type, not message. No error counts against your free requests. The sandbox adds the following errors to the 401, 402, 403, 429, 500, 503, and 504 errors every endpoint shares.
| Status | type | What to do |
|---|---|---|
400 | invalid_request | A field, header, or path is invalid, including an Accept-Datetime before the oldest build or an apps name the catalog does not offer. Fix the request. |
404 | not_found | No sandbox or command has that id in your organization. |
409 | conflict | The sandbox is still starting. Wait until its state is live before retrying. |
409 | conflict | The sandbox has ended, the command has exited, or an Idempotency-Key was reused with another body. Do not retry. |
409 | conflict | An input's seq is out of order. Resend with the error's next_seq. |
429 | rate_limit_exceeded | Too many requests, or too many sandboxes, vCPUs, or GiB running at once. Back off, or terminate sandboxes you are done with. |
Sandbox runtime failures are not HTTP errors: failed or ended sandboxes report the reason in error. See Errors.
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
GET keeps returning creating | Booting usually takes seconds and can occasionally take over a minute. | Keep polling GET /v1/time-portal/sandbox/{id}?wait=55s until state is live or failed. A failed sandbox reports the reason in error. See Lifecycle and Limits. |
Every request on a new sandbox returns 409 The sandbox is still starting. | The sandbox is not live yet. | Wait for state to become live before retrying. |
A sandbox that was live returns 409 The sandbox has ended. | It ended via termination, timeout, idle_timeout, or exhausted quota. Inspect error via GET. | Create a new sandbox because ended sandboxes cannot be restarted. See Errors. |
| Files or output are gone | The sandbox ended and its state was deleted. | Read a command to its exit and download what you need before the sandbox ends, and set idle_timeout to the longest gap between your requests. See Commands and Files. |
The sandbox ends with error.type sandbox_lost | Its host failed. | Start a new sandbox. Download results of long jobs as they finish, so a lost sandbox costs less of a rerun. |
An input is a 409 with next_seq in the body | Its seq is out of order. | Resend with seq set to next_seq. See Commands and Files. |
pip, npm, or apt cannot find a version | The mirrors are set to the sandbox's as_of; the version was released later. | Pick a version released before the instant. See Images and Network. |
| Names do not resolve and no connection leaves the sandbox | network is none, the default. | Create the sandbox with "network": "time-portal". See Images and Network. |
Next steps
A command is a program you start in a live sandbox.
A sandbox boots, runs while it is live, and ends at a timeout, a terminate, or a failure.
A sandbox boots the Ubuntu build chosen by its instant and reaches only what its network setting allows.