Introduction
The base URL, how requests and responses are shaped, and every endpoint.
The 402pay API is organized around resources, with predictable URLs, JSON bodies and standard HTTP status codes. Requests use your secret key, except the public checkout, exchange rate, event type and health endpoints, and the ones only the dashboard can call, such as sending from your wallet and changing your business's profile.
Base URL
GET /health answers without a key, so it's a quick way to check that your server can reach the API.
Conventions
- Send and receive JSON. A request with a body needs
Content-Type: application/json, or it returns 415unsupported_media_type. Fields and query parameters are snake_case. - Every object has a
kind, such aspaymentorcheckout, and an ID whose prefix says what it is. - Timestamps are ISO 8601 in UTC.
- Money is an integer in minor units with its
currency:4900withUSDis $49.00. USD totals for reporting live underreporting. - Coin amounts are decimal strings, such as
"49.00", so no precision is lost. - A single object comes back as
{ data }, a create returns 201, and a delete returns the object'sidandkindwithdeleted: true. - A path that doesn't exist returns 404
not_foundin the same error envelope as every other error. A method a path doesn't take, such asDELETE /payments/{id}, returns a bare 405 instead, with no body. - Every response except a 405 has a
402pay-Request-Idheader, and every error repeats it asrequest_id. Include it when you contact support.
ID prefixes
| Prefix | Object |
|---|---|
biz_ | Business, as in the 402pay-Business header |
pmt_ | Payment |
chk_ | Checkout |
lnk_ | Payment link |
cst_ | Customer |
evt_ | Event |
whk_ | Webhook endpoint |
dlv_ | Webhook delivery |
wal_ | Wallet |
wtx_ | Wallet transaction |
key_ | API key, and an event's actor.id when a key made the change |
usr_ | A person on your team, as an event's actor.id |
req_ | Request, in errors and the request ID header |
Versioning
- The version is part of the base URL,
/api/v1. There's no version header, and nothing to pin per request. - Every event carries
api_version,v1today: the version of its shape, so a webhook handler knows which fields to expect. - New fields and event types can appear within a version, so ignore the ones your code doesn't know rather than refusing them.
- Every change is in the changelog.
Endpoints
Payments
Checkouts
Webhooks
Wallet
Businesses
Metrics
Search
Exchange rates