Overview
The Zuba API authenticates every request with an API key: one secret you send as a bearer token in theAuthorization header of every request.
Get your API key
- Log in to your Zuba Dashboard (see the Environments table for the Sandbox and production dashboards)
- Navigate to Developers → API Keys and click Generate key
- Name the key, choose Full access or Read-only (see Scopes), and click Generate
- Copy the key immediately. It is shown once and cannot be retrieved again.
zk_live_ in production and zk_test_ in Sandbox, so you can tell at a glance which environment it belongs to.
Use your API key
Send the key in theAuthorization header of every request:
Authorization header, never as a query parameter.
Scopes
Every API key carries a set of scopes, chosen when the key is created in the dashboard (Developers → API Keys). A Read-only key carries onlyread:* scopes; a Full access key carries every scope in the table below. The table lists the operations in this reference that check a scope. Other operations in this reference are authorized by the key’s workspace alone, except the API key management operations, which accept only a dashboard session. Any 403 insufficient_scope response names the scope to add, whether or not the operation appears here.
A request whose key lacks the scope for that endpoint is rejected with
403 and an insufficient_scope body naming the missing scope:
insufficient_scope on an endpoint it needs, create a new key in the dashboard (Developers → API Keys) at the access level the integration needs, Full access or Read-only, switch the integration to it, and delete the old key.
Restricting a key
When you create a key in the dashboard (Developers → API Keys), you can limit it in two ways. Both are optional, and a key without them works from any address and never expires.- Allowed IP addresses. Up to 20 IPv4 or IPv6 addresses or CIDR ranges, such as
203.0.113.10or198.51.100.0/24. A request from any other address is rejected with403and anip_not_allowedbody that names the address the request came from. You can change the list or remove it later from the key’s Edit restrictions menu, and the change applies to the key’s next request. - Expiry. A date and time after which the key stops working, and requests with it are rejected with
401and the messageAPI key has expired. You can add an expiry to a key later, or bring an existing one earlier, but not remove it or move it later. An expired key cannot be rotated: create a new key and switch your integration to it.
Environments
Zuba provides separate environments for development and production:Always test in Sandbox before moving to production. Each environment has its own keys: a Sandbox key sent to the production API, or a production key sent to Sandbox, is rejected with
401.Authentication Errors
Branch on the status code, not the message: in production a
401 carries the same body whatever its cause, except an expired key, whose message is API key has expired. Sandbox may return a more specific message.
Keys issued with a Client ID
Some keys were issued with a Client ID, a Client Secret, a token URL and an audience, for exchanging the Client ID and Client Secret for a 24-hour access token. These keys work through the token exchange, and their Client Secret also works sent directly as the bearer. Because the exchange is deprecated, move your integration to sending the Client Secret directly: it needs no new key, only removing the token request.- Rotating such a key in the dashboard keeps it the same kind of key: put the new secret where the old one was and your token exchange keeps working. Access tokens issued before the rotation stay valid until they expire.
- New keys generated in the dashboard have no Client ID and are sent directly, as above. They do not work with the token exchange, so an integration that makes the token request should keep using its existing key, or drop the token request and send the new key directly.
- Dropping the token exchange needs no new key: the Client Secret you already hold works sent directly as the bearer, so moving is a matter of deleting the token request.
- Restrictions apply to these keys too: an allowlist or an expiry set on the key is checked when an access token from the exchange is used, as it is for a key sent directly. See Restricting a key.
curl
The response’s
access_token is sent as Authorization: Bearer <access_token> and is valid for 24 hours (expires_in is 86400). Cache it rather than requesting one per call. A token carries the scopes its key held when the token was issued, so request a new token after changing a key’s access.
Security Best Practices
Environment Variables
Environment Variables
Never hardcode your API key in application code. Read it from an environment variable or a secrets manager:
.env
HTTPS Only
HTTPS Only
Always use HTTPS. Never send an API key over HTTP.
Key Rotation
Key Rotation
Rotate your keys regularly. Two paths:
- Rotate in place: in the dashboard, Developers → API Keys → Rotate. You get a new key with the same name, and the old key stops working at once, so update your deployment right away.
- Zero-downtime rotation: generate a new key, update your environment variables, deploy, then delete the old key in the dashboard.
Key Storage
Key Storage
- Keep the key in a secrets manager or environment variable, never in source control
- Never log the key or the
Authorizationheader - Use a different key for each service, so you can rotate or delete one without touching the others
Least Privilege
Least Privilege
Generate a Read-only key for anything that only reads data, and keep Full access keys for the services that create payouts. See Scopes for what each scope gates.
Testing Authentication
Check your key with a read-only request before making other calls:Next Steps
Quickstart Guide
Start making your first API calls
API Reference
Explore all available endpoints