Authentication
Every request to the Stridge API carries a key in the Authorization header. You use two kinds: a secret key that stays on your server, and a publishable key your checkout uses in the browser.
| Property | Secret key | Publishable key |
|---|---|---|
| Held by | Secret key Your server | Publishable key The browser |
| Starts with | Secret keysk_live_ acts in live, with real moneysk_sbx_ acts in your sandbox, on simulated chains | Publishable keypk_live_ for livepk_sbx_ for your sandbox |
| Sent as | Authorization: Bearer <key> to https://api.stridge.com/v2, for both | |
| How many | Secret key Created in the dashboard, each for one environment | Publishable key Exactly one per environment |
| Secrecy | Secret key Secret. A live key's secret is shown only once, when you create it | Publishable key Public by design: it identifies the environment and nothing more |
| Reaches | Secret key The operations whose permission it holds. 59 operations take a secret key. | Publishable key 3 reference-data reads on its own, and deposit addresses only inside a session for one of your customers |
Sending a request
Put the key after Bearer in the Authorization header:
curl "https://api.stridge.com/v2/deposits" \
-H "Authorization: Bearer $STRIDGE_SECRET_KEY"A request that fails authentication is refused:
401: no key was sent, the key is not recognised, or the operation does not accept this kind of key.403: the key is valid but does not hold the operation's permission.
Every refusal returns the standard error object. When a key is refused lists each code.
Secret keys
A secret key is your server's credential, and it decides which environment each request acts in. Create one in the Stridge dashboard for the environment you want:
- A
sk_live_key acts in your live environment, with real money. - A
sk_sbx_key acts in your sandbox, on simulated chains.
Both call the same base URL, https://api.stridge.com/v2. Nothing else in the request selects the environment. If you also send X-Stridge-Environment, the request fails with 400 header_invalid (environment header not accepted). Every object you read back carries livemode, so a payload on its own still tells you which environment it came from. See Environments.
Treat every secret key like a password. A live key's secret is shown only once, when you create it, so store it then. You can reveal a sandbox key's secret again in the dashboard.
Live keys only
A key acts only in its own environment, and a few operations are available to live keys alone. Calling one with a sandbox key returns 404 operation_not_served (this operation is served to live keys only).
| Operation | Permission |
|---|---|
List webhook endpointsGET/webhook-endpointswebhook.read | webhook.read |
Create a webhook endpointPOST/webhook-endpointswebhook.write | webhook.write |
Get a webhook endpointGET/webhook-endpoints/{endpoint_id}webhook.read | webhook.read |
Update a webhook endpointPATCH/webhook-endpoints/{endpoint_id}webhook.write | webhook.write |
Delete a webhook endpointDELETE/webhook-endpoints/{endpoint_id}webhook.write | webhook.write |
Rotate a webhook endpoint's signing secretPOST/webhook-endpoints/{endpoint_id}/rotate-secretwebhook.write | webhook.write |
Permissions
Permissions limit what each key can do, so a leaked key can do only what you gave it. A key holds the permissions you chose when you created it, such as deposit.read, payout.create or webhook.read. Each operation needs one permission, named on its page beside its credential. Permissions describes them all.
A call from a key without the operation's permission returns 403 permission_denied. The error's message names the missing permission for whoever reads the log, for example insufficient permissions: the api key does not hold payout.create.
Some permissions come without being named:
- Every key reads the reference data: networks, prices, deposit quotes and the assets deposit addresses accept. A sandbox key also reads the sandbox's simulations and runs the test helpers that simulate deposits.
payout.createalso lets the key quote a payout, because a payout can name the quote it was priced at.
Others are held only when you name them:
uda.writechanges a deposit address. Only a key created with it holds it;uda.createdoes not include it.webhook.readandwebhook.writego on live keys only, because only live keys reach the operations that need them.webhook.deliver, which pings and re-enables an endpoint, works on a key of either environment.
Give each key only the permissions its service needs. A key that only reads deposits and settlements cannot move money, even if it leaks.
Publishable keys
A publishable key lets your checkout read what it needs straight from the browser, without exposing a secret. Each environment has exactly one, starting pk_live_ or pk_sbx_. It is public by design: it identifies the environment and nothing more.
On its own, it reads the reference data a checkout shows. Each of these operations also accepts a secret key, so your server calls them the same way:
| Operation |
|---|
Quote a deposit's routeGET/uda/quote |
List what deposit addresses acceptGET/uda/supported-assets |
Price one symbol, strictlyGET/prices/{asset_symbol} |
A publishable key works within tighter rules than a secret key:
- It may send only the parameters its operation declares for a browser. Any other parameter fails with
400parameter_unknown. - It gets back only the response fields declared for a browser. Other fields are left out.
- It has its own rate budget, separate from your secret keys'.
- Listing and creating deposit addresses accept it only inside a session for one of your customers. Send that session's credential in
X-Stridge-Client-Secretas well. Without it, the request fails with401client_secret_required. - Every other operation refuses it with
401publishable_key_not_accepted.
When a key is refused
Each refusal names its cause in error.code, so your code can tell a missing key from a missing permission. Errors describes every code.
| Status | error.code | Cause |
|---|---|---|
| 401 | authentication_required | No key was sent (missing authentication token). |
| 401 | token_invalid | The key is not recognised (invalid api key, invalid publishable key), or it is revoked, expired, or rolled and past its overlap (api key is not active). A secret key that reaches the other environment gets it too (sandbox api key reached the live api). Send the key unchanged to the same base URL: its prefix decides the environment. |
| 401 | api_key_not_accepted | The operation does not take a key, or the key was sent in X-API-Key. Send it as Authorization: Bearer. A key created with only the scopes of the /v1 API holds no /v2 permission and gets this code too. |
| 401 | publishable_key_not_accepted | A publishable key was sent to an operation a browser does not call. |
| 401 | secret_key_in_browser | A secret key was sent to an operation a browser calls, with a browser Origin or alongside X-Stridge-Client-Secret. Treat the key as exposed and roll it. |
| 400 | header_invalid | The request sent X-Stridge-Environment with a secret key. |
| 403 | permission_denied | The key does not hold the permission the operation needs. |
| 404 | operation_not_served | A sandbox key called an operation available to live keys only. |
| 404 | environment_not_sandbox | A live key called a sandbox-only operation, such as a test helper. |
| 409 | environment_resetting | The key's sandbox is being reset. Retry once the reset finishes. |
| 409 | environment_provisioning | The key's sandbox is still being set up. This clears on its own, so retry shortly. |
Operations a secret key calls
A secret key can call 59 operations, each gated by one permission. The table counts them by permission. Follow a permission to its entry on Permissions to see every operation it opens.
| Area | Permission and the operations it opens |
|---|---|
| Deposit addresses | uda.read8 operationsrouting_policy.read2 operationsuda.create1 operationuda.write1 operationuda.settlement_retry1 operation |
| Deposits and transactions | |
| Payouts | |
| Vaults and treasuries | |
| Webhooks and events | |
| Reference data | reference.read6 operations |
| Sandbox |
Keeping your key safe
A secret key can do everything its permissions allow, so where you keep it matters as much as what it holds.
Never ship a secret key in a browser bundle, a mobile app or any client a user can inspect. Call Stridge from your server and keep the key there.
- Server-side only. Make Stridge calls from your backend. Use the publishable key for what a browser does.
- Least privilege. Give each service its own key, with only the permissions it needs.
- Sandbox for development. Give local and CI environments a sandbox key. The base URL stays the same.
- Roll on exposure. If a key leaks, roll it or revoke it in the dashboard.
- The Try it console keeps your key in your browser. The console on each operation page stores your key in your browser's
localStorageand sends it straight to the Stridge API, never to the docs site's servers. Use a sandbox key there, and a live key only for the operations available to live keys alone.
In the Try it console, the quote, supported-asset and price reads use your publishable key. The API refuses a secret key sent to them from a browser (401 secret_key_in_browser). Listing and creating deposit addresses can be tried from your server only.