xtopaydocs

Authentication

Every request carries a secret key. Test keys try things out; live keys take real payments. Lock keys to your servers' addresses.

Send your secret key as a bearer token on every request:

curl https://api.xtopay.co/v1/payments \
  -H "Authorization: Bearer sk_test_…"

Keys

Each business has two pairs of keys, in the dashboard's Developers page:

KeyStarts withWhere it goes
Test secret keysk_test_Your server, while you build. No money moves
Live secret keysk_live_Your server, to take real payments
Publishable keyspk_test_, pk_live_Safe in a browser or app. They identify your business, and can't read or change anything

A secret key is shown in full once, when it's made (Create) or rolled. After that the dashboard shows only its last characters, and Xtopay keeps only a hash of it.

Which business a key is for

Every business has a business ID: 8 digits, like 48271935, that never changes. It's in the dashboard (Settings → Business), and on every payment, payout and webhook as business_id. To check a key works, and is the one you meant:

GET/v1/business
curl https://api.xtopay.co/v1/business \
  -H "Authorization: Bearer sk_test_…"
{
  "success": true,
  "data": {
    "business_id": "48271935",
    "name": "Nana's Kitchen",
    "username": "nanaskitchen",
    "pay_url": "https://xtopay.me/nanaskitchen",
    "verified": true,
    "mode": "test"
  }
}

The last digit of a business ID is a check digit (the Luhn algorithm, as on card numbers), so you can catch a mistyped one before you use it.

Keeping keys secret

  • Keep secret keys on your server, in environment variables. Never put them in a website, a mobile app or a code repository.
  • Roll a key from Developers if it might have leaked. The old key stops working straight away.
  • The owner, admins and developers can see and roll keys. Viewers can't.
  • Making or rolling a live secret key, and changing any key's IP allowlist, needs two-step sign-in on, and asks for a code from the authenticator app if one wasn't entered in the last 10 minutes.

A request with a missing, wrong or rolled key gets 401 with the code unauthorized.

IP allowlists

Each secret key can have a list of the addresses requests with it may come from: your servers' public IPs, or ranges like 41.66.12.0/24 (up to 20). Set it from the key's Allowed IPs in Developers.

  • With a list, a request from anywhere else is refused with 403 forbidden, and the message names the address it came from.
  • With no list, the key works from any address. Live direct charges and transfers need a list.
  • Ranges can't be wider than /8 (IPv4) or /32 (IPv6).

If your server is behind a proxy or NAT, list the address the internet sees, not its private one.

Rate limits

Each key can make 120 requests a minute, and direct charges have their own limits (see Direct charges). Past a limit you get 429 rate_limited, with a Retry-After header saying how many seconds to wait.

Watching your keys

  • The request log: every request made with your keys in the last 30 days, refused ones too, with its answer, the address it came from and how long it took. It's at the bottom of Developers; switch on Refused and failed only to see what's being turned away.
  • Owner emails: the business's owner gets an email whenever a live secret key is made or rolled, or a key's IP allowlist changes, with who did it. If it wasn't you, roll the key.

On this page