---
title: "Authentication"
description: "API keys, access tokens and scopes."
---

<Info>
  API keys work for the new routes and for the September v1 API. Sandbox keys come with the Enterprise plan.
</Info>

## New routes: OAuth 2.0 client credentials

1. Create an API key in **Developers → API keys**. You get a **client ID** and a **client secret**. The secret is shown once; download or copy it then. We store only a hash and the last 4 characters.
2. Exchange it for an access token:

```bash
curl -X POST https://api.sandbox.storspay.com/v1/oauth/token \
  -u "$STORSPAY_CLIENT_ID:$STORSPAY_CLIENT_SECRET" \
  -d grant_type=client_credentials
```

```json
{ "accessToken": "eyJ…", "tokenType": "Bearer", "expiresIn": 86400, "scope": "create:payouts read:payouts" }
```

3. Send `Authorization: Bearer <accessToken>` on every call. Tokens last 24 hours; get a new one before it expires.

| Environment | Client ID | Client secret |
|---|---|---|
| Sandbox | `spc_test_…` | `sp_test_…` |
| Live | `spc_live_…` | `sp_live_…` |

- **Rotate** a key in the dashboard: the old secret stops working at once, and tokens made with it stop within 30 s.
- **Revoke** works the same way.
- Creating or rotating a live key that can move money needs a person with the Owner or Admin role, two-step sign-in, and an email confirmation code.
- A token from one environment is refused by the other (`401 WRONG_ENVIRONMENT`).
- The token endpoint allows 10 requests per minute per client ID.

<Warning>
  Never put a secret in a browser, a mobile app or a repository. Call the API from your server only.
</Warning>

## Scopes

A key carries only the scopes it was created with; a call outside them returns `403 INSUFFICIENT_SCOPE`.

| Scope | Allows |
|---|---|
| `read:accounts` / `update:accounts` | workspace, account holders, Storspay Accounts (account details) |
| `manage:applications` | verification applications, persons, documents, verification links, information requests |
| `read:ledger` | balances, closing balances, transactions, statements |
| `create:quotes` | quotes (moves no money) |
| `create:payouts` / `read:payouts` | payouts, batches, cancel |
| `create:transfers` / `read:transfers` | transfers between Storspay accounts, escrow release and cancel, cash-outs |
| `create:conversions` | conversions |
| `read:collections` / `create:collections` | deposits, collections (get paid) |
| `manage:beneficiaries` / `read:beneficiaries` | recipients, bank lists, requirements |
| `manage:platform_fees` | platform fee rules and earnings |
| `manage:webhooks` | webhook endpoints, deliveries, events |

## September v1 API: `sk_` keys (deprecated)

The September v1 API at `https://app.storspay.com/api/v1/` uses bearer keys:

```bash
curl https://app.storspay.com/api/v1/balance \
  -H "Authorization: Bearer $STORSPAY_SK_KEY"
```

- Keys are `sk_test_…` (test) and `sk_live_…` (live), shown once; we store only a hash.
- On rotation the old key keeps working for 24 hours.
- These keys work on the September v1 routes only. The new routes need an OAuth access token.

See [September v1 API](/api-reference/september-v1).
