# Authentication Bearer tokens, key format, scopes, and rotation. Every request carries your API key as a bearer token, in one of these headers: ```text Authorization: Bearer : x-api-key: : ``` The key's two parts are joined by a colon and sent as one token. The OpenAI SDKs send `Authorization` and the Anthropic SDKs send `x-api-key`. Both work on every `/v1` endpoint that takes an API key. If a request carries both, the API uses `Authorization`. The [Model servers API](https://docs.privatemind.com/model-servers-api.html), the [Workspaces API](https://docs.privatemind.com/workspaces-api.html) and the [Kubernetes API](https://docs.privatemind.com/kubernetes-api.html) take `Authorization` only. The Model servers API also accepts the short-lived token of a [service identity](https://docs.privatemind.com/model-servers-api.html#service-identities) with **May manage model servers** ticked. The model list is the one endpoint that answers without a key. See [Verifying a key works](https://docs.privatemind.com/authentication.html#verifying-a-key-works). ## Key shape - **Access key id**: 32 characters, starting with `PMIND`. It encodes the user who owns the key. - **Secret**: 64 hexadecimal characters. The server stores only a one-way hash of it, which can't be reversed. Example: ```text PMIND...:... ``` Treat the full string, colon included, as one opaque secret. ## Creating, rotating, revoking You manage API keys on the **API Keys** page in the sidebar: - **Create**: a description, an expiry (30 days to 1 year), a rate limit and an optional spend cap. The secret is shown **once**, at creation. - **Rotate**: create a new key, swap it into your client, then revoke the old one. - **Revoke**: takes effect immediately. The next request with that key returns `401`. Org admins can also create, list and revoke members' keys from a script with the [key management API](https://docs.privatemind.com/key-management-api.html). ## What a key carries - **Which models you can call.** The API enforces your org's model access. A model your org can't use answers `404`, and an external provider model your org has no grant for answers `403`. - **How much you can spend.** Each request's tokens are priced and deducted. When spend reaches the cap, calls return `402` until the cap is raised. - **How fast you can call.** Each key has a requests-per-minute limit, enforced over a sliding window. Going over it returns `429`. ## Security Treat keys like passwords. Anyone with the full bearer string can spend up to your budget cap until you revoke it. - Don't commit keys to source control. Use environment variables or a secret manager. - Don't put keys in browser code. The API is for server-side use: if you need browser access, proxy requests through your own backend. - Rotate on a schedule, and at once if a key may be exposed: a committed secret, a departing teammate, a leaked log. > [!WARNING] > Every key expires on the date you picked when you created it. Rotate it before then. ## Verifying a key works ```bash curl -s -o /dev/null -D - "https://api.privatemind.com/v1/models" \ -H "Authorization: Bearer $PMIND_KEY" | grep -i -E '^HTTP|^x-privatemind-key' ``` `x-privatemind-key: valid` means the key is valid and active. `rejected`, or a `401`, means it isn't. The model list returns `200` even without a valid key, so read the header. See [Errors](https://docs.privatemind.com/errors.html) for other codes. ## Where next - [Quickstart](https://docs.privatemind.com/quickstart.html) for an end-to-end first request. - [Rate limits](https://docs.privatemind.com/rate-limits.html) for the budget and RPM ceilings your key enforces. - [Errors](https://docs.privatemind.com/errors.html) for the full status-code map.