Skip to main content

Overview

The Zuba API authenticates every request with an API key: one secret you send as a bearer token in the Authorization header of every request.

Get your API key

  1. Log in to your Zuba Dashboard (see the Environments table for the Sandbox and production dashboards)
  2. Navigate to Developers → API Keys and click Generate key
  3. Name the key, choose Full access or Read-only (see Scopes), and click Generate
  4. Copy the key immediately. It is shown once and cannot be retrieved again.
A key starts with zk_live_ in production and zk_test_ in Sandbox, so you can tell at a glance which environment it belongs to.
Keep your API key secret. Never share it publicly, put it in client-side code or commit it to version control. Treat it like a password. If it is exposed, rotate it in the dashboard at once.

Use your API key

Send the key in the Authorization header of every request:
A key works until you rotate or delete it, or until the expiry you set on it passes. A rotation or deletion takes effect on the next request. See Restricting a key to limit a key to your own IP addresses or give it an end date. The key is accepted only in the 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 only read:* 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:
If an integration receives 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.10 or 198.51.100.0/24. A request from any other address is rejected with 403 and an ip_not_allowed body 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 401 and the message API 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.
If your integration runs from servers with fixed outbound addresses, list them. An allowlist means a key that leaks cannot be used from anywhere else.

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

The token exchange is deprecated. It still works, and there is no date yet for removing it. New integrations should send an API key directly, as described above. We will contact you before the token exchange stops.
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.
While it remains, the token exchange works like this:
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

Never hardcode your API key in application code. Read it from an environment variable or a secrets manager:
.env
Always use HTTPS. Never send an API key over HTTP.
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.
If your key came with a Client ID, a newly generated key has no Client ID and does not work with the token exchange. Rotate in place to keep the token exchange, or remove the token request before you switch keys. See Keys issued with a Client ID.
  • Keep the key in a secrets manager or environment variable, never in source control
  • Never log the key or the Authorization header
  • Use a different key for each service, so you can rotate or delete one without touching the others
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:
A successful test returns your account balances, or an empty array if there are none yet.

Next Steps

Quickstart Guide

Start making your first API calls

API Reference

Explore all available endpoints