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

EndpointDescription
POST/v1/time-portal/sandboxCreate and boot a sandbox. Returns 202 immediately with state: "creating".
GET/v1/time-portal/sandboxList 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}/execsStart a command asynchronously. Returns 200 with the command id.
GET/v1/time-portal/sandbox/{id}/execs/{exec_id}/outputStream 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}/inputSend stdin bytes, close stdin (eof), or send a POSIX signal to a running command.
PUT/v1/time-portal/sandbox/{id}/filesWrite raw bytes to a file at path and offset.
GET/v1/time-portal/sandbox/{id}/filesRead a byte range from a file.
DELETE/v1/time-portal/sandbox/{id}/filesDelete a file or directory.
GET/v1/time-portal/sandbox/{id}/files/statRetrieve file type, size, permissions, and modification time.
GET/v1/time-portal/sandbox/{id}/files/listList 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

EndpointReturnsThen
Create202 at once, the sandbox creatingGet the sandbox with wait until live or failed
Command200 once the command has started, with its idRead 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"}'
HeaderRequiredValue
Accept-DatetimeYesThe 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-KeyNoAny 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.

FieldDefaultWhat it does
networknonenone: 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.
vcpus1Virtual CPUs reserved for the sandbox: 1, 2, 4, 8, or 16.
memory_gib2Memory reserved, in GiB: 1, 2, 4, 8, 16, 32, or 64, at most 8 per vCPU.
timeout1hThe sandbox ends this long after it boots, from 1m to 24h. It cannot be extended.
idle_timeout10m, or timeout when that is shorterThe 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.
envnoneEnvironment 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": []
}
FieldMeaning
idThe sandbox's id.
statecreating (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_ofPoint-in-time cutoff for the sandbox's clock and network, resolved from Accept-Datetime.
network, vcpus, memory_gib, timeout, idle_timeoutConfiguration as created, with defaults applied.
created_atTimestamp when sandbox creation was accepted.
booted_atTimestamp when the sandbox finished booting; metering starts here. null until live.
expires_atLatest timestamp when the sandbox will end (booted_at + timeout).
ended_atTimestamp when the sandbox ended.
errorWhy 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.
metadataThe labels it was created with.
appsThe 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.

StatustypeWhat to do
400invalid_requestA 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.
404not_foundNo sandbox or command has that id in your organization.
409conflictThe sandbox is still starting. Wait until its state is live before retrying.
409conflictThe sandbox has ended, the command has exited, or an Idempotency-Key was reused with another body. Do not retry.
409conflictAn input's seq is out of order. Resend with the error's next_seq.
429rate_limit_exceededToo 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

SymptomCauseFix
GET keeps returning creatingBooting 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 goneThe 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_lostIts 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 bodyIts seq is out of order.Resend with seq set to next_seq. See Commands and Files.
pip, npm, or apt cannot find a versionThe 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 sandboxnetwork is none, the default.Create the sandbox with "network": "time-portal". See Images and Network.

Next steps

Commands and Files

A command is a program you start in a live sandbox.

Lifecycle and Limits

A sandbox boots, runs while it is live, and ends at a timeout, a terminate, or a failure.

Images and Network

A sandbox boots the Ubuntu build chosen by its instant and reaches only what its network setting allows.