Generate keys from the Dashboard. Secret keys are shown only once at creation.
REST
Send the key in theX-API-Key header on every request:
WebSocket
Browsers can’t send custom headers on WebSocket connections, so credentials are passed as query parameters:token parameter:
SDK
The TypeScript SDK accepts the same credentials. The sameapiKey field accepts secret and public keys; pass jwt (or a rotating getJwt) alongside pk_jwt_*.
Rotating keys
To rotate a secret key:- Generate a new
sk_live_*key in the dashboard. - Roll the new key out to your servers.
- Disable the old key in the dashboard.
kid.
JWT public keys
pk_jwt_* keys let your end users authenticate directly from a browser or mobile app using a JWT from your auth provider (Privy, Auth0, Clerk, Turnkey, Google, custom). The Struct API verifies the JWT signature against your configured public key and applies per-user rate limits keyed on the JWT sub claim.
See Frontend Auth (JWT) for the full flow, supported algorithms, and JWKS configuration. Manage keys at Dashboard › JWT Keys.
Error responses
On WebSocket, auth failures arrive as the
auth_failed event (SDK) or a close frame with code 1008. Reconnect attempts are not retried automatically on auth failures, since the credentials need to be fixed first.
Security checklist
- Use
sk_live_*only from servers you control. Never embed in frontend bundles, mobile apps, or public repos. - Use
pk_jwt_*for every browser-side or mobile call. Pair with a short-lived JWT (15 minutes or less) signed by your auth provider. - Scope work to multiple keys when you have distinct environments or services so you can rotate without coordinated downtime.
- Monitor key usage in the dashboard. A key that suddenly spikes is the first sign it’s been leaked.