TTL & Lifecycle
TTL & Lifecycle
Every sandbox has a configurable time-to-live (TTL) — a hard limit after which Modbox automatically destroys all resources, regardless of whether you called destroy explicitly.
Why TTL matters
Without TTL, a sandbox lives until you explicitly destroy it. If your application crashes, your agent hangs, or you simply forget to clean up, orphaned sandboxes accumulate and consume resources.
TTL is your safety net.
Setting TTL
Pass ttl_seconds when provisioning:
Valid range: 60 seconds (1 min) to 86400 seconds (24 hours).
Default TTL per image
You can set a default TTL on an image so every sandbox provisioned from it gets that TTL automatically:
The TTL passed at provision time takes precedence over the image default.
TTL recommendations
Lifecycle events
Checking time remaining
The sandbox detail endpoint returns created_at. You can calculate remaining time:
Reaper background process
Modbox runs an internal TTL reaper every 60 seconds that scans for expired sandboxes and destroys them. This means a sandbox may live up to 60 seconds past its TTL before being destroyed.
This 60-second grace window is intentional — it avoids bursting the infrastructure with deletions and gives in-flight requests time to complete.