API reference / About the API
Authentication
How to send your Maxy API key, which key to use where, and what the API answers when a key is missing or wrong. Read it before you write your first call, and again before you put a key in a web page.
Send the key
Every call takes your key in a header, in either of two forms. Both reach the same check.
curl -s -H "x-maxy-key: $MAXY_API_KEY" "$BASE/key" curl -s -H "Authorization: Bearer $MAXY_API_KEY" "$BASE/key"
{ "key": "mxk_test_sJAL2u…", "kind": "secret", "scopes": ["read", "quote", "place", "orders", "webhooks", "account"], "origins": [], "orderCapUsd": 100, "sandbox": true }
A key never goes in a URL. A query value that is a secret key answers 400 invalid_input and nothing is done, because a URL lands in logs and browser history. A browser opening a stream sends a ticket instead: see Quote routes.
Keys
Maxy issues every key and keeps only a hash of it, so it is shown once. Each is a prefix and 32 letters and digits.
| Prefix | Kind | Where it runs |
|---|---|---|
mxk_live_ | Secret, live | Your server |
mxk_test_ | Secret, test: the sandbox | Your server, your laptop |
mxk_pk_live_ | Publishable, live | Your web page, on its origins |
mxk_pk_test_ | Publishable, test | Your web page, on its origins |
The key alone picks the environment. The base URL and the routes are the same; a test key's answers carry "sandbox": true and the header X-Maxy-Sandbox: true.
Secret and publishable keys
A secret key can do everything your integration needs. A publishable key reads, quotes and places the user's own signed order, so a page can run a whole buy, and nothing more. Each order still needs the user's wallet to sign it.
| Scope | What it covers | Secret | Publishable |
|---|---|---|---|
read | Chains, tokens, pairs, address checks, limits, an order's status | yes | yes |
quote | Prices, quotes, batches, price streams | yes | yes |
place | POST /orders, /orders/submit, an order's signature, steps and cancel | yes | yes |
orders | GET /orders, POST /orders/watch, GET /orders/{id}/events | yes | no |
webhooks | Every webhook route | yes | no |
account | Keys, usage, statements, cap requests | yes | no |
GET /key and GET /limits list a key's scopes. A publishable key outside its scopes answers 403 scope_denied. The SDK refuses to start in a browser page with a secret key.
Allowed origins
A publishable key is bound to the browser origins Maxy issued it for, such as https://app.example.com. The browser sends the page's origin with each call, and a call from any other origin answers 403 origin_not_allowed. So does a call from a server, which sends no origin: from a server, use the secret key.
An origin check stops another site from using your key in a browser. It cannot stop a server that claims to be your site, so a publishable key is worth no more than its rate limit. Change the origins with POST /keys/{prefix}/origins: see Key security.
Routes without a key
These answer with no key, because they hold no data of yours or must work before you have a key. The list is the OpenAPI document's own (security: []):
| Route | What it is |
|---|---|
GET / | Every route, and the command that gets a test key |
POST /sandbox/keys | A test key and a test publishable key, with no sign-up |
GET /checkout/verify | Hosted checkout: is this signed URL what the partner signed |
POST /feedback | Docs feedback |
POST /security-reports | Report a security issue |
GET /system/status | Every component now, open incidents, upcoming maintenance |
GET /system/history | Each component per day |
GET /system/incidents | Incidents with their notes and postmortems |
GET /system/maintenance | The maintenance calendar |
GET /system/verified | The last end-to-end run through every failure branch on the sandbox |
GET /system/feed.xml | Incidents as RSS |
POST /system/subscribe | Status notices by webhook or email |
GET /system/confirm | Confirm an email subscription |
GET /system/unsubscribe | Stop status notices |
GET /openapi.json | This API as OpenAPI 3.1 |
GET /ping | Liveness only: answers at once and reads nothing |
GET /config | What a router's intake asks for, in one answer |
GET /health | The solver, Bitcoin and each chain's verifier, with a degraded flag |
Sending a key to these is allowed; it is checked and counted.
When the key is wrong
| You sent | HTTP | code |
|---|---|---|
| No key | 401 | auth_required |
| A malformed or cut-off key, or one Maxy did not issue | 401 | invalid_api_key |
| A revoked key | 403 | key_revoked |
| A publishable key outside its scopes | 403 | scope_denied |
| A publishable key from another origin, or from a server | 403 | origin_not_allowed |
| A secret key in a URL | 400 | invalid_input |
curl -s "$BASE/key"
{ "error": { "code": "auth_required", "message": "GET /key takes your Maxy API key in the x-maxy-key header (or Authorization: Bearer mxk_live_…). Every route does, apart from /health, the status page and getting a test key, which needs no sign-up: curl -X POST https://openapi.maxy.co/v1/sandbox/keys", "retryable": false, "docs": "https://maxy.co/docs/error-codes#auth_required" }, "requestId": "…" }
None of these is retryable: fix the key, then call again. Every code is on Error codes. The samples use BASE and MAXY_API_KEY from Get a price. To keep keys safe, rotate them and revoke a leaked one, read Key security.