Skip to main content
A sandbox is one isolated Linux machine for one job: a user’s workspace, an agent’s task, a conversation, a test run. You create it when the job starts, tag it with your own IDs, and delete it when the job is done. In between, it sleeps by itself whenever nothing is happening, so you can keep thousands around and pay only for the ones doing work. This page follows a sandbox through that life: how to create one, how to find it again later, what you can change while it runs, how to retry safely, and how to delete it.

Create one

The simplest sandbox needs no options at all. You get Fibre’s default image (Linux with a shell, Python, Node, git and a browser), ready for you to run commands in:
response
curl: delete it
The call waits until the sandbox is running, and then answers. You do not need to check back to see whether it has started. Keep the id from the answer, because every other call refers to the sandbox by it.

A sandbox for one user’s task

In a real app you usually set a few things when you create a sandbox:
  • Its size, so it has enough CPU and memory for the work.
  • Environment variables, so the code inside knows its context.
  • Labels that tie it to your own records, such as the user and the task, so you can find it again later.
  • When it should sleep, and when it should be deleted.
Here is a workspace for user 42, who is working on a task called fix-login:
response

Every option

Every option is optional: leave any of them out to get the default. Where the SDKs use a different name, it is shown in brackets.
A sandbox started from a snapshot takes its image, size, runtime and environment from that snapshot. When you use snapshot, you can only set lifetime_sec, idle_timeout_sec and labels yourself.

Find it again

Your app needs a way to find a user’s sandbox the next time they show up. You could store each sandbox’s ID in your own database, but there is a simpler way: labels. Because you tagged the sandbox with user: 42, you can simply ask Fibre for “the sandboxes of user 42” and get it back, with nothing stored on your side.
response
A few details about listing:
  • Several labels narrow the list. ?label.user=42&label.task=fix-login returns only sandboxes that have both.
  • Results come newest first, 50 per page (you can ask for up to 200 with limit). When there are more, the answer includes a next_cursor. Pass it back as ?cursor= to get the next page. In the SDKs, Sandbox.list() does the paging for you.
  • To get one sandbox by its ID, call GET /v1/sandboxes/{id}. This works for sleeping sandboxes too, and it does not wake them: you simply see "status": "standby".
Label keys can use lowercase letters, digits, ., _ and -, and can be up to 63 characters long. Values can be up to 128 characters.

Change it while it lives

Most settings are fixed once a sandbox is created. Three things can change while it runs: how long it lives, how quickly it goes to sleep, and its labels. This is useful, for example, to give a busy user’s sandbox more time, or to mark a task as ready for review:
response
Sending labels replaces the whole set of labels. To add one label, send it together with the labels you want to keep, as in the example above.
A new lifetime counts from the moment you set it, from 60 seconds up to 10 years. To remove it, so the sandbox is kept until you delete it, send "lifetime_sec": null (lifetime: null in TypeScript, lifetime=None in Python, fibre update --no-lifetime in the CLI).

Retry without making two

Networks sometimes drop answers. If your request to create a sandbox times out, you cannot tell whether the sandbox was created or not. If you simply try again, you might end up with two sandboxes, and pay for both. The fix is an idempotency key: a unique value of your choosing, sent in the Idempotency-Key header. If Fibre sees the same key twice, it does not create a second sandbox. It returns the first one instead. This example sends the same request twice with the same key, and gets one sandbox back both times:
curl
output
  • Use a new key for each sandbox you mean to create. A random UUID works well. Fibre remembers each key for 24 hours.
  • Reusing a key with a different request is refused (422 idempotency_key_reused), so a key can never be mixed up with another create.
  • The SDKs do this for you. Every Sandbox.create() sends its own key, so the SDK’s automatic retries never create a second sandbox.

Delete it

response
Deleting a sandbox is final. The machine, its files and its saved memory are all removed, and they cannot be recovered. Asking for the sandbox afterwards returns 404 sandbox_not_found. Fibre never deletes a sandbox on its own. One you do not delete is kept, asleep while nothing happens in it, and its storage counts towards your bill, unless you gave it a lifetime. To clean up everything that belongs to one user, list their sandboxes by label and delete each one:
If a user might come back, it is usually better to let the sandbox sleep than to delete it. A sleeping sandbox costs nothing for compute and wakes up with everything in place. Delete a sandbox when the user clearly says they are done, for example by deleting their project, rather than on a timer.

Errors

Every error has a message, a stable code, and a request_id.

Run commands

Now that it runs, make it do something.

Sleep and wake

What a sandbox keeps while it sleeps.

Runtimes

When you need Docker or a full VM.

API keys

A key that works on one sandbox only.