Skip to main content
An API key is how Fibre knows who is making a request. Every request you send includes a key, in the Authorization header, and Fibre uses it to decide which account the request belongs to and what it is allowed to do. A key does not have to be all-powerful. You can create keys that can only do certain things, keys that only work on one sandbox, and keys that stop working after a set time. This page shows how, and why you would want to.

Use your key

Create your first key in the dashboard, under API keys. It starts with fb_live_. Copy it as soon as it is created: Fibre shows it only once and keeps only a fingerprint of it, so it cannot be shown again. If you lose it, create a new one. Send the key as a bearer token. The SDKs read it from the FIBRE_API_KEY environment variable, or you can pass it in yourself:
A key from the dashboard can do everything your account can do. That is convenient on your own machine, but risky anywhere else. For a CI job, a script or an agent, it is much safer to create a key that can do only what that job needs. If such a key leaks, the damage is limited to what it was allowed to do.

A key for one job

1

Create it with scopes and an expiry

Two settings narrow a key down:
  • scopes lists what the key may do. sandboxes.read, for example, lets it look at sandboxes but not create or change them. All the scopes are listed further down.
  • expires_in_sec sets when the key stops working.
This creates a key that can only read sandboxes, and only for the next hour:
response
2

Use it

Now try the new key. Listing sandboxes is a read, so it works. Starting a sandbox is a write, so Fibre refuses it and says which scope was missing:
response
A key can create other keys only if it has the keys.write scope. Even then, it can never create a key that can do more than itself, or one that lives longer than itself. So a limited key can never be used to make an unlimited one.

A key for one sandbox

When an agent runs inside a sandbox, it often needs to use Fibre itself: to read its own files, start a background command, or extend its own lifetime. Giving it your main key would let it reach every sandbox you own. Instead, bind a key to that one sandbox with the resource field. The bound key works on that sandbox and nothing else, and it is revoked automatically when the sandbox is deleted. Here is the whole flow:
1

Start a sandbox

2

Create a key bound to it

response
3

Hand it to the program inside

Pass the key to the program inside the sandbox as an environment variable of the command that starts it. Only that command, and the programs it starts, can see it:
4

It reaches its own sandbox, and nothing else

response
If the key is used for anything outside its sandbox, such as listing all sandboxes, Fibre refuses it:
curl
response
If the key asks for a different sandbox by its ID, Fibre answers 404 sandbox_not_found, as if that sandbox did not exist. The key cannot even learn which other sandboxes you have.

List and revoke keys

You can list all the keys of your account at any time. The list shows each key’s name, its first few characters (prefix, so you can recognise it), its scopes and when it was last used. It never shows the key itself. To revoke a key, delete it. A revoked key stops working immediately.
curl: revoke one
response
curl: delete the sandbox

Scopes

A scope combines an area of the API with what the key may do there:
  • sandboxes.read lets the key look, for example list sandboxes or read their status. Any GET request needs .read.
  • sandboxes.write lets the key make changes, for example create, update or delete sandboxes, or run commands. Every other request needs .write.
  • sandboxes.* allows both, and * on its own allows everything in every area.
These are the areas:

Errors

If a request is refused because of its key, the answer tells you why:

Keep keys safe

A few habits keep your account safe:
  • Keep keys out of your code. Read them from environment variables or a secret manager, and never commit them to a repository.
  • Give each job its own key. A CI pipeline, a script and an agent should each have a separate key, with only the scopes and the lifetime they need. Then one leak affects one job.
  • Inside a sandbox, use a bound key. It cannot reach anything beyond that sandbox.
  • If a key leaks, revoke it. Nothing else needs to change: create a new key and carry on.