Skip to main content
Every request to the Modem Pay API needs a secret key. You create and manage keys in the dashboard under Developers → API keys.

Your two kinds of key

test keys only touch test data. live keys move real money. A test key can’t see live data, and a live key can’t see test data.
Never put a secret key in a website, mobile app or public repository. Anyone with it can act on your account. If one leaks, roll it straight away.
Modem Pay stores only a hash of each secret key. You see the full key once, when you create it. Save it somewhere safe, like your server’s environment variables. If you lose it, roll the key to get a new one.

Make a request

Send the secret key as a bearer token:

Full-access and restricted keys

A full-access key can call every endpoint. That’s convenient, but risky: if it leaks, someone could send payouts from your balance. A restricted key can only do what you allow. Give each system its own restricted key with just the permissions it needs. For example, your website’s checkout only needs to create payments. It never needs to send money. When you create a restricted key in the dashboard you can set:

Permissions

Pick exactly which resources it can read or change.

Expiry

1 day, 7 days, 30 days, 90 days, 1 year, never, or a date you choose.

Allowed IP addresses

Up to 20 IP addresses or ranges. Requests from anywhere else are refused.

Payout limits

A maximum per payout and per day, for keys that can send money.
You can have up to 5 active full-access keys and 20 active restricted keys per account and mode.

Permissions

Each permission is a resource and an access level, like payments:write. A write permission includes read for the same resource.

Ready-made sets

The dashboard offers three starting points:

Payout limits

On a key that can send money, you can set:
  • per_transfer: the most a single payout can be.
  • daily: the most the key can send in total each day.
For bulk payouts, every item counts. If a request would go over a limit, it’s refused with per_transfer_limit_exceeded or daily_transfer_limit_exceeded, and nothing is sent.

IP allowlists

There are two levels:
  • Per key: set when you create the key. Applies to that key only.
  • Per account: set in the dashboard. Applies to every key on that account and mode.
A request must pass both. Ranges use CIDR, like 203.0.113.0/24.

Roll a key

Rolling replaces a key with a new one. You choose how long the old key keeps working, from 0 hours up to 7 days (24 hours by default), so you can update your servers without downtime. The new key keeps the old key’s permissions. Roll a key straight away if:
  • it was committed to a code repository or shared in chat;
  • someone who had it leaves your team;
  • you see requests you don’t recognise in the audit log.
To stop a key immediately, revoke it instead.

When a key is refused

Errors from key checks include a code you can act on:
Keys with an expiry date send an X-Key-Expires-At header on every response. Alert on it so a key never expires by surprise.