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

# Authentication and API keys

> Create scoped API keys, limit them to specific apps, databases or buckets, and send them as bearer tokens.

## Send the key

Every request carries the key in the `Authorization` header:

```bash theme={null}
curl https://api.servbase.net/app/list -H "Authorization: Bearer $SERVBASE_API_KEY"
```

> [!WARNING]
>
> Treat a key like a password. Keep it in CI secrets or a password manager, never in source code, client-side JavaScript or a public repository. If a key leaks, delete it in the dashboard right away; it stops working immediately.

## Create a key

Workspace owners open **API** in the dashboard sidebar and select **Create API key**, then choose:

1. **A name**, so you can tell keys apart, for example `github-actions-shop`.
2. **Scopes**: what the key may do (below).
3. **Resources**: for applications, databases and object storage, whether the key reaches **all** of them or only **specific** ones.

The full key is shown **once**. Servbase stores only a hash of it, so a lost key cannot be shown again: delete it and create a new one.

A key acts with your access in the workspace it was created in. It stops working when it is deleted, when you lose access to the workspace, or while the workspace owner's account is suspended or banned.

## Scopes

Give a key only the scopes it needs. A request outside a key's scopes is refused with `403`.

> [tab] Applications
>
> | Scope | Allows |
> | - | - |
> | `apps:read` | View applications, deployments, build logs and request statistics |
> | `apps:deploy` | Deploy, redeploy and rebuild applications |
> | `apps:restart` | Restart running Python and Node.js applications |
> | `apps:power` | Stop and start applications |

> [tab] Databases
>
> | Scope | Allows |
> | - | - |
> | `databases:read` | List databases and database users, without passwords |
> | `databases:credentials` | Read a database's credentials and connection details |
> | `databases:create` | Create databases |
> | `databases:update` | Change a database's password |
> | `databases:delete` | Delete databases |

> [tab] Object storage
>
> | Scope | Allows |
> | - | - |
> | `storage:read` | List buckets, list and download objects |
> | `storage:write` | Upload and overwrite objects |
> | `storage:delete` | Delete objects |
> | `storage:buckets` | Create, change and delete buckets |

> [tab] Billing
>
> | Scope | Allows |
> | - | - |
> | `billing:read` | Read the credit balance and credit history |

> [!NOTE]
>
> Keys created before the storage scopes were split keep what they could do: a key with `storage:write` also has `storage:delete` and `storage:buckets`.

## Limit a key to specific resources

For applications, databases and object storage, a key can reach **all** of them or only **specific** ones you choose:

* Lists return only the resources the key may reach. Any other resource answers `404`, as if it did not exist.
* A key limited to specific buckets cannot create buckets.
* Resources created later are not added to the key. Create a new key to include them.

Normal rules still apply on top of a key's scopes. For example, only a running app with a successful build can be stopped, restart works only for Python and Node.js apps, and deploys are refused while an app is stopped.

## Recommended keys

| Use | Scopes | Limit to |
| - | - | - |
| CI that deploys one app | `apps:read`, `apps:deploy` | That application |
| Uptime or status dashboard | `apps:read` | The apps it shows |
| Backup job that uploads files | `storage:write` | The backup bucket |
| App that reads its database credentials | `databases:credentials` | That database |
| Finance report | `billing:read` | Not applicable |

## What keys never see

* Application details include the **names** of an app's variables, never their values.
* Database passwords are returned only by `GET /db/{db_id}/credentials`, which needs `databases:credentials`.


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