Type Definition
Properties
Duration after which the sandbox will sleep if no requests are received.Can be:
- A string like
"30s","3m","5m","1h"(seconds, minutes, or hours) - A number representing seconds (e.g.,
180for 3 minutes)
keepAlive is true.Base URL for the sandbox API (advanced use cases)
Keep the container alive indefinitely by preventing automatic shutdown.When
true:- Container never auto-sleeps
- Must call
sandbox.destroy()explicitly to cleanup - Use for long-running services or when activity can’t be automatically detected
sandbox.destroy() when done to avoid resource leaks.Normalize sandbox ID to lowercase for preview URL compatibility.Required for preview URLs because hostnames are case-insensitive (RFC 3986).Important: Different
normalizeId values create different Durable Object instances:getSandbox(ns, "MyProject")→ DO key:"MyProject"getSandbox(ns, "MyProject", {normalizeId: true})→ DO key:"myproject"
true in a future version. To prepare:- Use lowercase IDs, or
- Explicitly pass
normalizeId: true
Container startup timeout configuration. Tune based on container characteristics.Can also be configured via environment variables:
SANDBOX_INSTANCE_TIMEOUT_MSSANDBOX_PORT_TIMEOUT_MSSANDBOX_POLL_INTERVAL_MS
Example: Basic Configuration
Example: Keep Alive for Long-Running Service
Example: Heavy Container Timeouts
Example: Fail-Fast Configuration
Example: Environment Variable Timeouts
Timeout Configuration Guide
Default Settings (Most Use Cases)
Heavy Containers
Fail-Fast Applications
Notes
- Options are set when calling
getSandbox(), not when creating the namespace - Container timeouts can be configured per-sandbox or globally via env vars
normalizeIdaffects Durable Object routing - different values create different instanceskeepAlive: truerequires manual cleanup to avoid resource leaks- Sleep timeout resets on each request
- Sleeping sandboxes restart automatically on next request
- Startup timeouts account for container provisioning delays
See Also
- getSandbox - Create sandbox instances
- Sandbox - Sandbox class reference
- Performance Guide - Optimization tips