Skip to main content
All errors from l402-kit follow a structured JSON format so agents can parse and act on them programmatically.

Error codes

PAYMENT_FAILED

Wallet could not pay the invoice. Check balance and budgetSats limit.

TOKEN_EXPIRED

The L402 token was generated but not used before its TTL (default: 1 hour). Retry the request to get a fresh invoice.

BUDGET_EXCEEDED

Agent has spent more than budgetSats in the current session. Raise the budget or end the session.

INVALID_MACAROON

The macaroon could not be decoded. Usually caused by a corrupted token. Retry from scratch.

TOKEN_ALREADY_USED

Replay protection triggered. Each preimage can only be used once. Never reuse tokens.

NODE_UNREACHABLE

The Lightning provider is unreachable. Retry with exponential backoff.

INVOICE_EXPIRED

BOLT11 invoices expire (default: 600 seconds). Retry the original request to receive a fresh invoice.

WRONG_PREIMAGE

Cryptographic verification failed. The preimage does not prove payment of this invoice.

Handling errors in agents