Key types
A key works only in its own environment. A Sandbox key can’t read or change Live data, and the reverse.
Create a key
1
Open API keys
In the dashboard, choose the environment with the switch at the top of the sidebar, then open Settings › API keys.
2
Name it after what will use it
Choose Create key and name the service or deployment that will hold it, such as “Production backend”. Names are unique per environment.
3
Choose its permissions
Leave Restricted mode off for full access, or turn it on and choose None, Read or Write for each group below.
4
Copy it once
Ledger shows the key once and stores only a hash of it. Put it in your secret manager or environment, such as
LEDGER_API_KEY.Authenticate requests
Send the key as a bearer token:401:
Response (401)
Permissions
A restricted key has a level for each of four groups. Read grants the read scope; Write grants both.
A request that the key isn’t allowed to make returns the same
401 unauthorized as an invalid key.
Suggested keys
Keep keys safe
- Server only. Never put a key in a browser, mobile app or public repository. Anyone with it can spend your customers’ credits.
- One key per service. If one leaks, you revoke one key, not your whole integration.
- Restrict by default. Give each service only the groups it calls.
- Rotate on suspicion. Create a replacement, deploy it, then revoke the old key in Settings › API keys.
Next steps
Errors
The error shape and every code.
Sandbox and Live
What each environment holds.