Documentation Index
Fetch the complete documentation index at: https://docs.monkepay.xyz/llms.txt
Use this file to discover all available pages before exploring further.
onError callback
Register anonError callback to receive SDK errors:
MonkePayErrorContext object:
Error codes
| Code | Recoverable | Description |
|---|---|---|
INVALID_CONFIG | No | SDK misconfigured — missing required params. Fix your config and redeploy. |
WALLET_RESOLVE_FAILED | Yes | Could not resolve payout wallet from API credentials. MonkePay API may be temporarily unavailable. Retried automatically on the next request. Agent receives a 502. |
UNLOCK_VERIFY_FAILED | Yes | Unlock token verification failed. Agent falls through to normal payment — they receive a standard 402 and can pay for a new token. |
PAYMENT_MIDDLEWARE_FAILED | No | x402 payment validation threw unexpectedly. Agent receives a 502. |
EVENT_RECORD_FAILED | Yes | Payment settled on-chain but MonkePay failed to log it. Agent still gets their 200. Revenue is not lost — the on-chain transaction exists. |
ON_PAYMENT_CALLBACK_FAILED | Yes | Your onPayment callback threw an error. Response is unaffected. Fix your callback. |
SDK_INTERNAL_ERROR | No | Unexpected internal error. Please report this. |
What agents see
Agents never see internal SDK error details. Error responses are always sanitized:onError.
Express error handler
For Express, register an error handler to catch any errors that reach the end of the middleware chain:Common issues
Agent receives 402 on every request even after payment- Check that your
apiKeyIdandapiKeySecretare correct - Verify your MonkePay account network matches your server network
- Check
onErrorforWALLET_RESOLVE_FAILEDerrors
WALLET_RESOLVE_FAILED in onError
- MonkePay API may be temporarily unavailable
- Check api.monkepay.xyz/health
- The error is recoverable — requests will retry wallet resolution automatically
EVENT_RECORD_FAILED in onError
- Payment happened on-chain and agent received their 200
- Revenue is safe — the transaction is on-chain
- The dashboard may not show this payment until the issue is resolved
- Usually transient — check if it persists