Skip to main content
You want your product to give every one of its users a computer: a notebook, a coding workspace, an agent that works on their files. Each user gets their own sandbox, it is still there when they come back, and you show it inside your own UI. Why it fits. Sandboxes are isolated from each other by their own kernel (Security). A paused sandbox keeps its memory and files, costs only storage, and does not count towards your plan’s sandboxes at once (Limits). So the number that matters is users active right now, not users in total.
1

Tag each sandbox with your user's ID

Keep the API key on your server. Find the user’s sandbox by metadata, resume it if it exists, create it if not:
sandbox_for_user.py
Keys starting with anona. are reserved; pick your own prefix. On plans without a maximum lifetime, timeout=-1 removes the deadline and idle pause alone decides (Lifecycle).
2

Show it in your page

Your server mints a short-lived viewer token and your page puts the URL in an iframe. pty gives the user a terminal, desktop a screen:
viewer_url.py
Tokens last up to 10 minutes; the embed asks your page for a fresh one before that. See Embed it. To show a web app the user built, use a preview link instead.
3

Keep your own records in step

Subscribe a webhook to sandbox.lifecycle.paused, resumed and killed, and update your database from it rather than polling. Deliveries are at least once and unordered: deduplicate on webhook-id and order by timestamp.
4

Know what each user costs

OpenTelemetry export sends per-sandbox CPU, memory and network to your own backend every minute, tagged with the sandbox ID, so you can bill or limit per user.
Never send your API key to the browser. Everything the page needs (a viewer token, a preview link) is minted by your server and expires on its own.
Runnable example: examples/python/sandbox_per_user.py in the public SDK repository. It prints what happens at each step.