Skip to main content

API keys

Settings › API keys. Keys are how your backend and your apps authenticate to the API; the format and rules are in API overview.

The API keys card

Columns: Label, Type (server = secret, public), Last 4 (last four characters — the only part stored in the clear), Scopes, Created, and Revoke.

Create a key

1 Click + Generate key.

The Generate key dialog

2 Choose:

FieldNotes
LabelWhere the key will live: "Backend (production)", "Data pipeline", "iOS app".
TypeServer (secret, sk_) for servers. Public (pk_) for anything that ships to users.
ScopesTick only what the holder needs.

3 Generate. The key appears once. Copy it, press I saved it, and it is gone — only the hint remains.

Scopes

ScopeAllowsTypical holder
subscriptions:writeregister/update/delete devices, login/logout, rotate endpoints, update that device's userpublic keys (SDKs)
subscriptions:readsegment previewbackend
events:write(tracking pings need no key; reserved)public keys
users:read / users:write/v1/users/* — read a person with devices, set tags before their first device, delete for GDPRbackend
notifications:sendPOST /v1/notificationsbackend, CI
campaigns:read/v1/campaigns/:id/statsbackend, monitoring
campaigns:writecreate, send, cancel campaigns, pick an A/B winnerbackend

A public key is always refused on server endpoints (403 forbidden) even if it somehow had the scope — the kind check comes first.

Revoke

Revoke marks the key revoked; requests with it fail with 401 unauthorized within API_KEY_CACHE_TTL (60 s by default — verified keys are cached to keep bcrypt off the hot path). The row stays in the list as cancelled so the audit trail is intact.

Rotation is create-then-revoke: mint the new key, deploy it, revoke the old one.

Where each key goes

# Secret key — server to server
curl https://push.example.com/v1/notifications \
-H "Authorization: Bearer sk_live_…"

# Public key — SDKs, or a raw subscribe call
curl https://push.example.com/v1/subscriptions \
-H "x-app-key: pk_live_…"