# Authentication

Every request is authenticated with a **project key**, sent as a bearer token:

```text
Authorization: Bearer dsp_live_8Kq2Xa9vT3mQ7rW1yN5bC0dF4gH6jK2p
```

**Creating a key.** A project admin creates keys on the dashboard: **Project settings > Developer > Keys**. The secret is shown once, when the key is created or regenerated; only a hash is stored, so it can't be shown again. Production keys start with `dsp_live_`; keys of the development environment of Dispra start with `dsp_dev_`.

**What a key reaches.** A key belongs to **one project**, and optionally to **one environment** of it. It reaches everything inside: environments, services, deployments, logs, variables, volumes, domains, webhooks and shells. Creating and transferring projects, people, billing and workspace settings stay on the dashboard; those routes answer `404 not_available_with_key`.

**Access levels.**

| Access | What it can do |
|---|---|
| `read` | Every read in scope, including log and event streams. Revealing a secret value counts as a change, so `read` can't. |
| `deploy` | Everything `read` can, plus deploying, redeploying, rolling back, cancelling, restarting, stopping and starting services. |
| `full` | Everything a project admin can do in scope: create, change and delete environments, services, volumes, variables, domains and webhooks, open shells, apply dispra.yaml. |

**A key acts as its creator.** Its effective rights are the lower of its access level and its creator's current role in the project. If the creator is demoted, the key can do less at once; if they leave the workspace, the key stops working (`403 key_creator_gone`). Create keys from an account that will stay.

**Regenerating and revoking.** Regenerating gives a new secret and stops the old one at once. Revoking stops the key for good. When a project moves to another workspace, all its keys are revoked.

> Keep keys out of source control and browser code. Use one key per system (CI, a script, an integration), so you can revoke one without breaking the others, and give each the lowest access it needs.
