Getting started
Authentication
Secret and public keys, test and live mode, rotating keys without downtime, and keeping them safe.
Every request carries a secret key in the Authorization header:
Authorization: Bearer sk_test_51Hc8f…
Your keys
Each business has one key pair per mode:
| Key | Prefix | Where it goes | What it can do |
|---|---|---|---|
| Secret key | sk_test_, sk_live_ | Your server only | Everything in this API reference |
| Public key | pk_test_, pk_live_ | Your web page, with the checkout widget | Nothing on its own: the widget also needs a session's client secret |
The key decides two things, so you never send them separately:
- The business. A key only ever sees its own business's data. Another business's id returns
404. - The mode.
sk_test_keys see test data only;sk_live_keys see live data only. The two never mix.
A public key on a server route, or a dashboard sign-in token on a key-only route, is refused with 401 CREDENTIAL_NOT_ACCEPTED.
Permissions
Secret keys can call every endpoint in this reference. Each endpoint lists the permission it needs (for example orders:read), so you can see at a glance what an integration touches. Keys can't call dashboard-only routes such as team management or bank account changes.
Keep secret keys secret
- Store them in environment variables or a secrets manager, never in source control.
- Never put a secret key in a browser, mobile app or anything a customer can download.
- Never log them. Cartirra shows a secret key in full only once, when it's created or regenerated; after that the dashboard shows its last four characters.
- Developers → API keys shows when each key was last used (to the minute), so you can spot a key that's in use somewhere you didn't expect.
Rotate keys without downtime
Regenerate a pair from Developers → API keys (it asks for a confirmation code). Choose an overlap of 0–72 hours:
- The new pair works immediately.
- The old pair keeps working until the overlap ends, and the dashboard lists it as expiring with the exact time.
- Deploy the new key everywhere, check the old key's last used time stops moving, then let the overlap run out.
An overlap of 0 cuts the old keys off at once. Use it when a key has leaked.
Errors you may see
| Status | Code | Meaning |
|---|---|---|
| 401 | unauthenticated | No key, a malformed key, or a revoked or expired key |
| 401 | credential_not_accepted | A public key or sign-in token where a secret key is required |
| 403 | permission_denied | The key can't call this route |
| 403 | live_mode_not_enabled | A live key before your business can go live |
| 403 | merchant_suspended | The business is suspended; contact support |