# Project keys

> Create, rotate and revoke the browser key and server key of a project environment.

Source: https://daster.io/docs/getting-started/project-keys/ · Last updated: 2026-11-21

Each project environment has one **browser key** and one **server key**.

| Key                       | Format            | Where to use it                                                                                                                                                 |
| ------------------------- | ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Browser (publishable) key | `daster_pk_dev_…` | Web and mobile app code. It is public and can be shown again. It admits requests but grants no data access on its own; your row-level security policies decide. |
| Server key                | `daster_sk_dev_…` | Your server only. It has the project's owner authority. It is shown once.                                                                                       |

The middle part (`dev`, `stg`, `prod`) names the environment. Keys are checked on every request with no cache, so a revoked key stops at once.

> **Warning:** Never put a server key in browser or mobile code, logs or a Git repository.

## Create the keys

1. Open **Project settings › Connection**.
2. Choose **Create project keys** and confirm.
3. The new server key appears once in a dialog. Copy it, or use **Download .env**. **Close** needs **I saved it**.

Changing keys needs a sign-in within the last 10 minutes. Organization Owners and Admins and project Maintainers can change keys; anyone on the project can see them.

## Rotate a key

1. On Project settings › Connection, choose **Rotate** next to the key.
2. The successor is active at once. The old key keeps working for an overlap:

| Key         | Default overlap | Maximum  |
| ----------- | --------------- | -------- |
| Server key  | 24 hours        | 24 hours |
| Browser key | 7 days          | 14 days  |

Or choose **Revoke the old key now** to end it immediately. Rotation never changes database passwords or your app users' sessions.

Hosted apps that run with the server key are not redeployed for you yet. Redeploy each one within the overlap so it picks up the new key.

## Revoke a key

Choose **Revoke** and type the key ID. The key stops at the next request.

## Restricted server keys

With the API you can create up to 10 narrower server keys per environment: send `restricted: { "label": "…", "scopes": [ … ] }` when you create keys. Scopes are a subset of `db:anon`, `auth:use`, `storage:public`, `realtime:subscribe` and `db:server`.

## With the API

```http
POST /v1/projects/{projectId}/keys?organizationId={organizationId}
Content-Type: application/json
X-Daster-Csrf: <csrf>
Idempotency-Key: keys-acme-dev-1

{ "confirmed": true }
```

The answer is `{ "keys": [{ "key": …, "value": "daster_sk_dev_…" }], "replayed": false }`. A server key's `value` appears only in this first answer; a replay with the same `Idempotency-Key` returns `value: null`.

- `GET /v1/projects/{projectId}/keys?organizationId=…` lists the keys (server keys masked).
- `POST …/keys/{id}/rotate` with `{ "confirmed": true, "overlapHours": 24 }` or `{ "confirmed": true, "revokeOld": true }`.
- `POST …/keys/{id}/revoke` with `{ "confirmed": true }`.

Every change is recorded in the project's activity with the key's ID, never its value.

> **Note:** Keys are made for the Development environment (`daster_pk_dev_…`, `daster_sk_dev_…`). Production keys are not available yet: changes to a Production environment's keys are refused (`production_approval_unimplemented`).
