# Authentication

> For AI agents: the index of these docs is at https://shippified.net/docs/llms.txt (every page it lists has a Markdown version like this one).

Authenticate with API keys or session tokens, choose a key's access, manage keys, and know which actions refuse keys.

Every authenticated endpoint reads one header:

```http
Authorization: Bearer <token>
```

Shippified accepts two kinds of token in that header. Use an **API key** for anything you write: scripts, servers, the SDK, the MCP server. **Session tokens** are what the dashboard and mobile app get when a person signs in.

| Token | Format | Lifetime | Where it comes from | Use it for |
| --- | --- | --- | --- | --- |
| API key | `sk_` + 32 URL-safe base64 characters (35 characters in all) | Until you revoke it | **Settings → Developer**, or `POST /api/account/api-keys` | Your code, the SDK, the MCP server |
| Session token | 64 hexadecimal characters | 14 days from sign-in; activity doesn't extend it | Signing in to the dashboard | The dashboard and mobile app |

The server tells them apart by prefix: a token that starts with `sk_` is looked up as an API key, and anything else as a session token. Cookies and query-string tokens are never read.

:::hint{style="danger"}
A **Read & write** key can read every order, change or delete orders, and create webhook subscriptions. Even a **Read-only** key can read everything in the workspace. Keep every key out of source control, browser code and mobile apps.
:::

## What a key is allowed to do

Every API key has one of two access levels, its _scope_. You pick it when you create the key and can't change it later; to change access, create a new key and revoke the old one.

| Scope | In the dashboard | Allowed requests | Refused |
| --- | --- | --- | --- |
| `read` | **Read-only** | `GET` (and `HEAD` / `OPTIONS`) on any endpoint that accepts an API key | Every other method: `403 {"error": "This API key is read-only. Use a read & write key for this request."}` |
| `write` | **Read & write** | Every method, including creating, editing and deleting orders, sources, bots, templates, subscriptions and webhook subscriptions | Creating or revoking API keys (see below) |

Two rules apply to every key, whatever its scope:

- **No API key manages API keys.** `POST /api/account/api-keys` and `DELETE /api/account/api-keys/:id` with an `sk_` key return `403 {"error": "API keys can't manage API keys — use the dashboard."}`. Listing keys (`GET`) is allowed. Create and revoke keys in the dashboard, or with a session token.
- **No API key exports or deletes the account.** Those return `401`; see **Actions that refuse API keys** below.

Keys created before scopes existed have no stored scope and behave as **Read & write**; the API reports them as `"scope": "write"`.

## Create an API key in the dashboard

:::stepper
::step{title="Open the Developer tab"}
Click **Settings** in the sidebar, then the **Developer** tab. The **API keys** card is at the top.

![The Developer tab with the API keys card, one active key and the Create key button](https://cdn.forumulate.com/5b8789b1-481a-41f5-8e5a-5f30d11f5151/a3c3b1f6-3467-42b9-971c-7c147fe99181/settings-developer.webp)
::
::step{title="Name the key"}
Under **Mint a new key**, type a label that says where the key will live, such as `Production SDK` or `n8n workflow`. The label is only for you. If you leave it empty the button stays disabled; through the API an empty name becomes `Untitled key`.
::
::step{title="Choose its access"}
Below the name, pick **Read-only** (selected by default) or **Read & write**. The line underneath explains the choice: "GET requests only — anything that changes data gets a 403." or "Reads and changes data, including webhook subscriptions. Can't create or revoke API keys." Pick **Read & write** for the SDK or MCP server if they need to add or change anything.
::
::step{title="Create and copy it"}
Click **Create key**. A panel titled "Save this key now — it won't be shown again." shows the full key and its access (for example "Access: Read-only."). Click **Copy**, paste the key somewhere safe (a password manager or your secrets store), then click **I've saved it** to hide it.

![A newly created key shown once, with Copy and I've saved it buttons](https://cdn.forumulate.com/5b8789b1-481a-41f5-8e5a-5f30d11f5151/87a19474-4d68-435a-9891-32eda885c145/dev-key-created.webp)
::
::step{title="Check it's listed"}
The key now appears under **Active keys** with its name, its first 11 characters (for example `sk__uMF392z…`), its access (**Read-only** or **Read & write**) and its creation date.
::
:::

The eye button (**Inspect key**) shows the key's ID, its **Access**, and a reminder that the secret can't be recovered. The bin button (**Revoke key**) asks "Revoke this API key?" and, once you confirm with **Revoke key**, the key stops working at once: "Any scripts using it will start getting 401s immediately."

![The Inspect key panel showing the key ID and a note that the secret is only available at mint time](https://cdn.forumulate.com/5b8789b1-481a-41f5-8e5a-5f30d11f5151/e26770a2-a852-4b28-a3a5-a4dc06624b01/dev-inspect-key.webp)

## Manage keys through the API

Creating and revoking keys needs a signed-in session token; an API key gets `403 {"error": "API keys can't manage API keys — use the dashboard."}`. In practice, create and revoke keys in **Settings → Developer**. Any API key can list keys.

### Create a key

`POST /api/account/api-keys`

| Body field | Type | Required | Notes |
| --- | --- | --- | --- |
| `name` | string | No | Trimmed and cut to 80 characters. Empty or missing becomes `"Untitled key"`. |
| `scope` | `"read"` or `"write"` | No | Defaults to `"write"` when omitted (the dashboard pre-selects Read-only instead). Any other value returns `400`. |

:::tabs
::tab{title="curl"}
```bash
curl -s -X POST https://shippified.net/api/account/api-keys \
  -H "Authorization: Bearer $SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"Inventory sync","scope":"read"}'
```
::
::tab{title="TypeScript SDK"}
```typescript
// The client must be built with a session token, not an sk_ key.
const { key, record } = await shippified.apiKeys.create("Inventory sync", { scope: "read" });
// `key` is the raw sk_… value. It is never returned again.
```
::
::tab{title="MCP"}
"Create a read-only Shippified API key called Inventory sync." (tool `create_api_key`, arguments `name` and optional `scope`; works only when the MCP server runs with a session token)
::
:::

Response `201 Created`:

```json
{
  "key": "sk_3kq9V0xExampleExampleExample1234",
  "record": {
    "id": "key_m1x2y3z4_a1b2c3",
    "name": "Inventory sync",
    "prefix": "sk_3kq9V0xE",
    "scope": "read",
    "createdAt": "2026-09-24T15:02:11.482Z"
  }
}
```

Store `key` right away. The server keeps only a SHA-256 hash of it plus the 11-character `prefix`.

### List keys

`GET /api/account/api-keys` returns `{ "items": [ … ] }`. Each item has `id`, `name`, `prefix`, `scope` (`"read"` or `"write"`), `createdAt` and, once the key has been used, `lastUsedAt` (updated on every request that authenticates with it). The list isn't paginated: an account can hold at most 25 keys. The hash is never returned.

:::tabs
::tab{title="curl"}
```bash
curl -s https://shippified.net/api/account/api-keys \
  -H "Authorization: Bearer $SHIPPIFIED_API_KEY"
```
::
::tab{title="TypeScript SDK"}
```typescript
const { items } = await shippified.apiKeys.list();
```
::
::tab{title="MCP"}
"List my Shippified API keys." (tool `list_api_keys`)
::
:::

### Revoke a key

`DELETE /api/account/api-keys/:id` with a session token returns `200 {"ok": true}`, or `404 {"error": "API key not found"}`. The next request with that key gets `401`. The **Revoke key** button in the dashboard does the same.

:::tabs
::tab{title="curl"}
```bash
curl -s -X DELETE https://shippified.net/api/account/api-keys/key_m1x2y3z4_a1b2c3 \
  -H "Authorization: Bearer $SESSION_TOKEN"
```
::
::tab{title="TypeScript SDK"}
```typescript
// Session-token client only.
await shippified.apiKeys.delete("key_m1x2y3z4_a1b2c3");
```
::
::tab{title="MCP"}
"Revoke the API key key_m1x2y3z4_a1b2c3." (tool `revoke_api_key`; session token only)
::
:::

### Rotate a key

Keys can't be rotated in place. Instead:

1. Create a new key with the same access.
2. Deploy it everywhere the old one is used.
3. Watch the old key's `lastUsedAt` stop changing, then revoke it.

### Limits

| Rule | Value |
| --- | --- |
| Keys per account | 25. Creating a 26th returns `429 {"error": "API key limit reached (25). Revoke unused keys first."}` |
| Expiry | None. A key works until revoked. |
| Name length | 80 characters |
| Scope | Set at creation; can't be changed |

## Session tokens

People sign in to the dashboard through Shippified's sign-in service at `auth.shippified.net` (email and password, email code, Discord or Google), or with the older **Use your password instead** form. Each path ends with the server issuing a session token, which the web app keeps in the browser's local storage and sends as a bearer token.

The endpoints that issue sessions are built for the dashboard, not for scripts: they need a human (a sign-in service token, an OAuth consent, or a Cloudflare Turnstile check when the deployment has one configured). Use an API key for programmatic access.

| Endpoint | Body | Success |
| --- | --- | --- |
| `POST /api/auth/login` | `email`, `password`, `turnstileToken` | `200 {token, user, state}` |
| `POST /api/auth/register` | `email`, `password` (8+ characters), optional `displayName`, `turnstileToken` | `201 {token, user, state}` |
| `POST /api/auth/atlas-login` | `token` (a one-time token from the sign-in service) | `200 {token, user, state}` |

- Wrong credentials: `401 {"error": "Invalid email or password"}`.
- Missing or failed Turnstile check: `400` with the reason.
- These endpoints share a rate limit of 10 requests a minute per client IP; over it you get `429` with `Retry-After: 60`.

Sessions expire 14 days after sign-in. To end one early, send it to `DELETE /api/auth/session`, which deletes the token in the header and always returns `200 {"ok": true}`. It doesn't touch API keys.

## Check who you are

`GET /api/auth/me` accepts either token type and returns `{ user, state }`: the account and a full workspace snapshot.

:::tabs
::tab{title="curl"}
```bash
curl -s https://shippified.net/api/auth/me \
  -H "Authorization: Bearer $SHIPPIFIED_API_KEY" | jq '.user'
```
::
::tab{title="TypeScript SDK"}
```typescript
const state = await shippified.getState();   // GET /api/state; state.user is the same object
console.log(state.user.webhookHandle);
```
::
::tab{title="MCP"}
"Show my Shippified account details." (tool `get_state`)
::
:::

`user` contains `id`, `username`, `email`, `displayName`, `createdAt`, `publicProfile`, `publicStats`, `webhookHandle`, `timezone`, `plan`, `subscriptionStatus`, `subscriptionPeriodEnd`, `subscriptionPriceId` and `emailVerified`. You need `webhookHandle` to build Discord intake URLs; see [Getting orders in](https://shippified.net/docs/intake).

## Actions that refuse API keys

Two account endpoints accept **only a signed-in session**. They refuse any `sk_…` key with `401`, so a leaked key can't download everything or destroy the account. In the dashboard they live under **Settings → Profile**.

| Endpoint | What it does | Error with an API key |
| --- | --- | --- |
| `GET /api/account/export` | Downloads everything the account owns as JSON | `401 {"error": "Sign in to export your data (API keys can't do this)."}` |
| `DELETE /api/account` | Permanently deletes the account | `401 {"error": "Sign in to delete your account (API keys can't do this)."}` |

The export (sent with `Content-Disposition: attachment`) contains `exportedAt`, `account`, `settings`, `orders`, `emailSources`, `bots`, `customTemplates`, `subscriptions`, `shares`, `apiKeys` and `intakeMessages` (the stored emails and webhook posts). Working secrets are left out: no password hash or one-time tokens, no mailbox passwords or OAuth tokens (sources keep only the IMAP host, port, TLS flag and username, or the connected Gmail or Outlook address), no API key hashes, no webhook signing secrets, and Discord webhook URLs are cut to their host.

Deletion needs the account's email typed back:

```bash
curl -s -X DELETE https://shippified.net/api/account \
  -H "Authorization: Bearer $SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"confirmEmail":"you@example.com"}'
```

A missing or different `confirmEmail` (compared after trimming, ignoring case) returns `400 {"error": "Type your account email exactly to confirm deletion."}`. On success (`200 {"ok": true}`) the account and everything it owns are removed, every session and API key stops working, an active Stripe subscription is cancelled, and the sign-in identity is deleted too.

:::hint{style="danger"}
Account deletion is immediate and can't be undone. Export first if you might want your data. See [Account and privacy](https://shippified.net/guides/account-and-privacy).
:::

## Credentials that aren't bearer tokens

Some URLs carry their own credential because the sender can't set headers. Treat each full URL as a secret.

| Credential | Used by | Details |
| --- | --- | --- |
| Discord intake URL `/api/webhooks/discord/:handle/:slug` | Monitor bots | The unguessable handle plus the bot's slug. Never add an API key to it. See [Getting orders in](https://shippified.net/docs/intake). |
| Forwarding address `<slug>@shippified.net` | Your mail provider's forwarding rule | The random slug routes mail to one email source. |
| Embed copier URL `/api/embed-copier/:secret/submit` | The embed copier Discord bot | Shown and rotated under **Settings → Developer → Embed Copier**. See the [embed copier guide](https://shippified.net/guides/embed-copier). |
| Webhook signing secret `whsec_…` | Shippified, when it calls you | Proves a delivery came from Shippified. See [Webhooks](https://shippified.net/docs/webhooks). |

## When authentication fails

| Situation | Status | Body |
| --- | --- | --- |
| No `Authorization` header, a malformed one, an unknown or revoked key, an expired or signed-out session | `401` | `{"error": "Not authenticated"}` |
| Read-only key used for anything but `GET` | `403` | `{"error": "This API key is read-only. Use a read & write key for this request."}` |
| Any API key creating or revoking a key | `403` | `{"error": "API keys can't manage API keys — use the dashboard."}` |
| API key used for export or deletion | `401` | `{"error": "Sign in to … (API keys can't do this)."}` |
| 26th API key | `429` | `{"error": "API key limit reached (25). Revoke unused keys first."}` |

A bad key and an expired session get the same `401`; the response doesn't say which. `403` only ever means the key's scope doesn't allow the request; a resource owned by another account returns `404`.

:::expandable{title="My key worked yesterday and now returns 401"}
Someone revoked it (check **Active keys** in **Settings → Developer**), or you're sending a session token that passed its 14-day expiry. Session tokens start without `sk_`. Create an API key for anything long-running.
:::

:::expandable{title="I lost the key right after creating it"}
It can't be recovered: only a hash is stored. Revoke it and create a new one.
:::

:::expandable{title="Can I give a teammate or tool read-only access?"}
Yes: create the key with **Read-only**. It can read everything in the workspace but gets `403` on any change. Create a separate key per tool so you can revoke one without breaking the others.
:::

:::expandable{title="My key returns 403"}
Either it's a **Read-only** key and the request isn't a `GET` (create a **Read & write** key), or you're creating or revoking API keys with a key (do that in the dashboard). The error message says which.
:::

## Security checklist

- Keep keys in environment variables or a secrets manager. The `sk_` prefix makes leaked keys easy to find with `grep` or a secret scanner.
- Use one key per integration, named after it, and make it **Read-only** unless it has to change data.
- Review `lastUsedAt` and revoke keys you no longer use.
- Never put a key in browser or mobile code. The API allows cross-origin calls, but a key in a web page is readable by anyone. Call Shippified from your own backend.

:::cards
::card{title="REST API conventions" href="./rest-api"} Errors, pagination and rate limits.
::card{title="Webhooks" href="./webhooks"} Verify that deliveries come from Shippified.
::card{title="Developer tools guide" href="../guides/developer-tools"} The Developer tab, control by control.
:::

---

## For AI agents

- This page for a human reader: https://shippified.net/docs/authentication
- The whole space as one Markdown file: https://shippified.net/docs/llms-full.txt
- Live search + fetch over MCP: https://shippified.net/docs/_api/public/orgs/5b8789b1-481a-41f5-8e5a-5f30d11f5151/spaces/ae0c5af4-cc84-4899-9078-2faf8e7a6fc5/mcp
  - Install (Claude CLI): `claude mcp add api-docs --transport http https://shippified.net/docs/_api/public/orgs/5b8789b1-481a-41f5-8e5a-5f30d11f5151/spaces/ae0c5af4-cc84-4899-9078-2faf8e7a6fc5/mcp`

This Markdown is the same content the page renders — safe to quote and to ground answers in.
