Authorization header of each call, and BillStack uses it to identify the business, enforce permissions, and scope the request to your account. This page explains how to find your keys, use them correctly, and keep them safe.
Get your API keys
Your API keys live in the BillStack dashboard, one pair per business. To access them:- Sign in to billstack.co.
- Open Developer (or Settings β API Keys) in the sidebar.
- Select the business you want keys for.
Public and secret keys
Each business has two keys:
Your secret key is what authenticates API requests. Your public key is used to initialise checkout and identify your business in client-facing contexts - it does not grant access to the API on its own.
Keys are scoped to a single business. If you operate multiple businesses under one BillStack account, each has its own public and secret key pair, and a key only ever acts on the business it belongs to.
Authenticate your requests
Pass your secret key in theAuthorization header of every request using the Bearer scheme:
curl:
A newly generated key is inactive until you enable it. If your requests are rejected right after creating a key, confirm the key is enabled in the dashboard.
Use environment variables
Never hardcode your secret key directly in your source code. Store it as an environment variable and read it at runtime. This keeps the key out of your codebase and makes it easy to swap keys without touching your code. Set the variable in your shell or CI environment:Keep your keys secret
Your secret key grants access to your BillStack business. Treat it the same way you would treat a password. Follow these practices to protect your keys:- Do not commit keys to source control. Add
.envand any secrets files to.gitignore. Use a secrets manager (such as AWS Secrets Manager, HashiCorp Vault, or your platformβs built-in secrets store) in production. - Do not share keys in plain text. Avoid sending keys over email, Slack, or other messaging tools.
- Restrict access. Limit which team members and services can view or use your secret key. In BillStack, generating, disabling, and revoking keys is restricted to admins on the business.
Handle authentication errors
If your key is missing, malformed, inactive, or invalid, BillStack returns a401 Unauthorized response. All BillStack errors share the same shape:
401 error:
Rotate your API keys
Rotate your keys immediately if you suspect they have been compromised or accidentally exposed. In BillStack, rotation is a revoke-then-generate flow: revoking permanently invalidates the current pair, after which you generate a fresh pair.1
Go to Developer / API Keys in the dashboard
Navigate to your businessβs Developer (or Settings β API Keys) screen in dashboard.billstack.co.
2
Revoke the current keys
Choose Revoke. For safety, you will be asked to type the businessβs public key to confirm. Revoking immediately invalidates both the current public and secret key.
3
Generate a new pair
Generate a fresh key pair. BillStack displays the new secret key - copy it straight away and store it securely in your secrets manager or environment configuration.
4
Enable and deploy the new key
Ensure the new key is enabled, update your environment variables or secrets store, and redeploy your application. Verify that your API calls are succeeding before you finish.
Revocation takes effect immediately. Any requests using the old key will fail as soon as it is revoked, so generate, enable, and deploy the new key promptly to avoid downtime.
