API Reference
The AgentPay API is a RESTful service that handles API key creation, wallet lifecycle, payment execution for 402 flows, and spend history. The base URL for the hosted service is https://api.agentpay.solutions; for self-hosted deployments use your own API URL. Authentication is via the X-Api-Key header for all endpoints except health and API key creation.
Authentication
Include your API key on every request that requires authentication: X-Api-Key: pk_.... The key is created once via POST /api-keys or from the dashboard. See API Keys for creation and security practices.
Endpoints
| Method | Path | Auth | Description |
|---|---|---|---|
| GET | / | — | Simple health: { "ok": true, "service": "agentpay-api" } |
| GET | /health | — | Detailed status: database, facilitator, RPC configuration |
| POST | /api-keys | — | Create API key. Body: label (optional), key (optional). With X-Internal-Secret, body may include organization_id and plan for payment limits. Returns id, label, key (plaintext once). |
| GET | /wallets/me | X-Api-Key | List wallets for the authenticated key. Returns { "wallets": [...] }. |
| POST | /wallets | X-Api-Key | Create wallet. Body: { "network": "base" }. Returns id, wallet_id, network, address (when CDP configured). |
| DELETE | /wallets/:id | X-Api-Key | Delete a wallet by id. Returns 204 or 404 if not found. |
| POST | /v1/pay | X-Api-Key | Execute payment for 402. Body: paymentRequiredHeader (required), requestUrl, idempotencyKey. Returns paymentSignature, settled, transaction. |
| GET | /v1/spend | X-Api-Key | List spend events. Query: limit (optional, default 100, max 500). Returns { "events": [...] }. |
Errors
Failed requests return an appropriate HTTP status and a JSON body with an error string. 402 responses may include a facilitator object with details from the x402 facilitator. 429 is returned when the monthly payment limit for the key's plan is reached (body includes upgradeUrl). For a full list of status codes and troubleshooting, see Errors & troubleshooting.
Related
- API Keys — Creation and usage
- Wallets — Create and list
- 402 Flow — Payment sequence and
/v1/pay - Spend — Event fields and use cases
- Environment variables — API and dashboard configuration