# Authentication

> Authenticate to the Besday API with a bearer API key: how to create, scope, store, rotate and revoke keys, and what each auth error means.

Source: https://besday.com/docs/api/authentication · Updated 2026-12-03 · OpenAPI: https://besday.com/api/v1/openapi.json

Every request carries an API key in the `Authorization` header as a bearer token. There is no OAuth flow and no key in the URL.

```http
GET /api/v1/me HTTP/1.1
Host: besday.com
Authorization: Bearer bsd_live_8xQ2…
```

## Create an API key

1. Sign in to besday.com as the brand’s **owner** or an **admin**.
2. Open **Settings → API keys** and choose **New API key**.
3. Name it after what will use it (for example “Shopify sync”) and pick its access: **Read and write** or **Read only**.
4. Copy the key. It is shown once; Besday stores only a keyed hash of it.

## Key format

Keys look like `bsd_live_` followed by 43 characters (32 random bytes, base64url). Settings shows only the first and last characters afterwards.

## Scopes

| Scope | Can | Cannot |
|---|---|---|
| `read` | Every GET: account, credits, creators, orders, messages, deliveries, webhooks | Anything that changes data (403 `insufficient_scope`) |
| `read_write` | Everything in this API | Buy credits or manage keys and the team (those stay on besday.com) |

## Who a key acts as

A key acts as the team member who created it, with that member’s current role. If they leave the team, their account is deleted, or the brand is suspended, every key they made stops working at once (401). Monthly spending limits the owner set for a member apply to their keys too.

## Keep keys safe

- Keep keys on your server, in an environment variable or a secrets manager. Never in a browser, a mobile app or a repository.
- Use one key per system, so you can revoke one without touching the others.
- A brand can have 10 active keys. To rotate, create the new key, deploy it, then revoke the old one.
- Revoking (Settings → API keys → Revoke) takes effect on the next request.

## Authentication errors

| Status | Code | Meaning |
|---|---|---|
| 401 | `api_key_missing` | No `Authorization: Bearer` header was sent. |
| 401 | `api_key_invalid` | The key is malformed, unknown or revoked, or its team member, brand or account is no longer active. |
| 403 | `insufficient_scope` | A `read` key tried to change something. Create a `read_write` key. |
| 403 | `email_unverified` | The key’s team member has not verified their email address, which Besday requires before paying. |
