Skip to main content
Sessions transition between creating, running, paused, destroying, and destroyed. Pausing preserves filesystem and memory state so that resuming is fast and cheap. The start endpoint is a convenience that handles every transition (creating → running, paused → running, dev server boot) in a single atomic call.
Required scope for all four endpoints: sessions:write.
You usually don’t need to resume explicitly. Sessions auto-pause after roughly 20 minutes idle, and the endpoints you’d reach for next resume in place rather than rejecting:
  • the file endpoints (read, write, list, search, upload, download, mkdir, rename, delete) and run-server
  • the terminal WebSocket, which backs runtm-api session exec and session connect
  • the prompt WebSocket
  • POST /api/v2/sessions/{id}/start
The first call after a resume takes a few extra seconds. If the resume itself fails, those endpoints return 400 with the reason rather than a bare “not running”. Call resume explicitly when you want to warm a sandbox ahead of time, or pause when you deliberately want to stop the clock.

Pause Session

POST /api/sessions/{session_id}/pause Pauses a running session. The sandbox is snapshotted (filesystem and memory) and held for the duration of your plan’s paused-session retention. While paused, sessions accrue no compute cost but are not interactive. Calling pause on an already-paused session is a no-op and returns 200. Calling pause while a prompt is actively running returns 409.

Path Parameters

string
required
Session UUID.

Query Parameters

string
default:"manual"
Why the session was paused. Reasonable values: manual, inactivity, e2b_auto, ttl_expired. Surfaces in activity logs only.

Response

string
Session UUID.
string
ISO 8601 timestamp.
string
Human-readable confirmation.

Resume Session

POST /api/sessions/{session_id}/resume Resumes a paused session, restoring the exact state captured at pause time. Custom instructions, environment variables, and template secrets are re-injected. Calling resume on an already-running session is a no-op.

Path Parameters

string
required
Session UUID.

Response

string
Session UUID.
string
ISO 8601 timestamp.
string
Human-readable confirmation.

Start Session

POST /api/sessions/{session_id}/start Convenience endpoint that always returns a running sandbox with the dev server up (or an explicit error). It handles every transition transparently:
  • creating → polls the sandbox until provisioning completes, then starts the dev server.
  • paused → resumes and starts the dev server.
  • running → idempotent: starts/checks the dev server, no-op if already up.
  • destroyed / error / destroying → returns 410.
Use this from automation that doesn’t want to track state machines manually.

Path Parameters

string
required
Session UUID.

Response

string
Session UUID.
string
Always running on success.
string
Live preview URL (when a server boots).
integer
Port the dev server is bound to.
string
Detected type (e.g. node, python, static).
string
Detected framework, when known.
boolean
true when the server responded to a health probe.
string
Optional human-readable status message.

Cleanup Old Paused Sessions

POST /api/sessions/cleanup Triggers an idempotent maintenance pass that:
  1. Sends warning notifications for sessions approaching their paused-retention limit.
  2. Destroys sessions that have exceeded their plan’s paused retention period.
This is the same job a scheduler runs periodically. Trigger it manually if you need to force cleanup ahead of schedule (for example, while migrating). The pass applies the standard platform retention policy: 90 days on the free plan, indefinite on paid plans (configured per session at pause time).
This is a maintenance trigger and is not required for normal operation - the platform runs the same pass on a schedule. Calling it more often does not extend or shorten any individual session’s retention; sessions are only acted on once their retention has elapsed.

Response

integer
Number of sessions destroyed in this run.
integer
Number of sessions that received expiration warnings.
string
Human-readable summary.