> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fibre.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Concepts

> Every word the Fibre docs use, defined once: sandbox, size, runtime, image, snapshot, exec and commands, sleep and wake, lifetime, labels, address, API key.

This page explains the ideas behind Fibre, in the order you will meet them. Each idea gets a few sentences and a
link to the page that covers it in depth. If you read only one page before you start building, make it this one.

## Sandbox

A **sandbox** is an isolated Linux machine that you start with a single API call. It has its own processes, its
own files, its own network and its own HTTPS address. Code running in one sandbox cannot see or touch your
systems, or any other sandbox.

You usually create one sandbox per unit of work: one per user of your app, one per agent task, or one per
conversation. Each sandbox has an ID such as `sbx-1a2b3c4d5e`, which you use in every call that concerns it.
[More about sandboxes](https://docs.fibre.dev/sandboxes/overview.md).

## Size, runtime and image

When you create a sandbox, three choices decide what kind of machine it is. You can leave all three out and get
sensible defaults.

* **Size** is how much machine you get: `xsmall`, `small` (the default), `medium`, `large` or `xlarge`. Each size has a fixed amount of
  CPU, memory and disk, and its own price per hour. [Sizes and prices](https://docs.fibre.dev/get-started/pricing.md).
* **Runtime** is how the sandbox runs. `standard` suits almost everything: code, tools, tests and browsers. `vm` is
  a full virtual machine with its own Linux kernel, for software that needs one, such as Docker or systemd. Both
  cost the same. [More about runtimes](https://docs.fibre.dev/sandboxes/runtimes.md).
* **Image** is the set of files the sandbox starts with. Fibre's default image already has a shell, Python, Node,
  git and a browser. You can also use any public image, or build your own. [More about images](https://docs.fibre.dev/setup/images.md).

## Running code: exec and commands

There are two ways to run something in a sandbox, and the difference matters:

* An **exec** runs a command and waits for it to finish, then gives you its output. It is the simplest option,
  and it stops the command after 30 seconds. Use it for quick things.
* A **command** runs in the background for as long as it needs. You can watch its output as it is written, send
  it input, stop it, or keep it running even while the sandbox sleeps. Use it for installs, test runs, servers and
  agents.

[More about running commands](https://docs.fibre.dev/sandboxes/running-commands.md).

## Files

The **files** API lets you read, write, list and delete files in a sandbox directly, without going through a
shell. It is how you put code and data in, and take results out. [More about files](https://docs.fibre.dev/sandboxes/files.md).

## Sleep and wake

This is what makes Fibre different from a regular server. When nothing has happened in a sandbox for a while (5
minutes, unless you choose another **idle timeout**), the sandbox **goes to sleep**. Its memory is saved together
with everything else, and you stop paying for compute.

The next time anything uses the sandbox (a command, a file call, or someone opening its address) it **wakes up**
exactly where it was. Running programs carry on, data in memory is still there, and open browser tabs are still
open. You do not need to write any code to save or restore state. [More about sleep and wake](https://docs.fibre.dev/sandboxes/sleep-and-wake.md).

## Lifetime

Sleep is not deletion, and neither is time passing: **a sandbox is kept until you delete it**, asleep or awake.
Fibre never deletes one on its own. If you want a sandbox to delete itself, give it a **lifetime**, from 60 seconds
up to 10 years, counted from when you set it. You can change or remove the lifetime at any time. [More about lifetime](https://docs.fibre.dev/sandboxes/sleep-and-wake.md#lifetime).

## Snapshots

A **snapshot** is a sandbox saved together with its memory and its running programs. When you start a new sandbox
from a snapshot, it begins exactly as the snapshot was: dependencies already installed, servers already running.
Snapshots let you do slow setup work once instead of in every sandbox. [More about snapshots](https://docs.fibre.dev/setup/snapshots.md).

## Labels

**Labels** are key-value tags that you attach to a sandbox, such as `user: 42` or `task: fix-login`. You can list
sandboxes by label, so you never need to store sandbox IDs in your own database: you simply ask for "the sandboxes
of user 42". [Finding sandboxes again](https://docs.fibre.dev/sandboxes/overview.md#find-it-again).

## Address

Every sandbox has its own HTTPS address, in its `url` field. If a program in the sandbox listens on the sandbox's
exposed port, anyone with the address can reach it in a browser. This is how you show a user the app an agent
built, or share a preview. [More about public URLs](https://docs.fibre.dev/connect/public-urls.md).

## API keys and your organization

Your code signs in with an **API key**. A key can be limited: to certain kinds of action, to a single sandbox, or
to a set lifetime. A key that only works on one sandbox is the safe way to let an agent inside that sandbox use
Fibre. [More about API keys](https://docs.fibre.dev/get-started/api-keys.md).

Your **organization** is your account. Sandboxes, keys, usage and billing all belong to it.

## States

At any moment, a sandbox's `status` is one of these:

| Status | What it means | Billed |
| - | - | - |
| `running` | Awake. Commands, files and its address all respond | Per second |
| `standby` | Asleep, with its memory saved. The next call wakes it | Nothing for compute |

A sandbox that has been deleted, or whose lifetime has ended, no longer exists. Asking for it returns
`404 sandbox_not_found`.

## Quick reference

| Word | In one line |
| - | - |
| **Sandbox** | An isolated Linux machine, started with one call |
| **Size** | How much CPU, memory and disk it has |
| **Runtime** | `standard`, or `vm` for a full virtual machine |
| **Image** | The files it starts with |
| **Exec** | Run a command and wait, up to 30 seconds |
| **Command** | Run something in the background, as long as needed |
| **Sleep / wake** | Pauses with its memory when idle, resumes on the next call |
| **Lifetime** | Optional: when it is deleted automatically. Without one, it is kept until you delete it |
| **Snapshot** | A saved sandbox that new sandboxes start from |
| **Labels** | Your own tags, for finding sandboxes again |
| **Address** | Its HTTPS URL |
| **API key** | How your code signs in |

## See them on a real sandbox

Create a sandbox and look at its answer: you will find most of the ideas above as fields.

```bash title="CLI" run theme={null}
SBX=$(fibre create --lifetime 5m --label docs=concepts --json | jq -r .id)
fibre get "$SBX"   # its status, runtime, size, public URL and when it is deleted
fibre delete "$SBX"
```

```typescript title="TypeScript" run theme={null}
import { Sandbox } from "@fibre-dev/sdk";

const sbx = await Sandbox.create({ lifetime: 300, labels: { docs: "concepts" } });
console.log(sbx.status, sbx.runtime, sbx.url, sbx.expiresAt);
await sbx.delete();
```

```python title="Python" run theme={null}
from fibre import Sandbox

sbx = Sandbox.create(lifetime=300, labels={"docs": "concepts"})
print(sbx.status, sbx.runtime, sbx.url, sbx.expires_at)
sbx.delete()
```

```bash title="curl" run capture=SBX=.id theme={null}
curl -sS -X POST "$FIBRE_API_URL/v1/sandboxes" \
  -H "Authorization: Bearer $FIBRE_API_KEY" -H "Content-Type: application/json" \
  -d '{"lifetime_sec": 300, "labels": {"docs": "concepts"}}'
```

> [accordion] Response
>
> ```json title="response" expected theme={null}
> {
>   "id": "…",
>   "status": "running",
>   "runtime": "standard",
>   "idle_timeout_sec": 300,
>   "expires_at": "…",
>   "labels": {
>     "docs": "concepts"
>   },
>   "url": "…"
> }
> ```

```bash title="curl: delete it" run theme={null}
curl -sS -X DELETE "$FIBRE_API_URL/v1/sandboxes/$SBX" -H "Authorization: Bearer $FIBRE_API_KEY"
```

## Next

> [card] [Quickstart](https://docs.fibre.dev/get-started/quickstart.md)
>
> Put these ideas to work: start a sandbox and run code in it.

> [card] [Pricing and limits](https://docs.fibre.dev/get-started/pricing.md)
>
> What each size costs, the plans, and every limit.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.