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
Response
response
curl: delete it
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.
fix-login:
Response
Response
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 withuser: 42, you can
simply ask Fibre for “the sandboxes of user 42” and get it back, with nothing stored on your side.
Response
Response
response
- Several labels narrow the list.
?label.user=42&label.task=fix-loginreturns 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 anext_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".
., _ 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
Response
response
"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 theIdempotency-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
Output
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
Response
response
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:
Errors
Every error has a message, a stablecode, and a request_id.
Related
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.