X402 Payments

Neura uses the Coinbase X402 protocol to protect every monetized endpoint. Requests are served once the client proves payment by presenting the signed headers defined in the Coinbase X402 welcome guide. This page explains how the middleware behaves and provides sample client implementations.

High level flow

  1. Discovery request Call any monetized endpoint without payment headers. The middleware replies with HTTP 402 Payment Required.

  2. Inspect invoice The 402 response includes headers such as:

    • X-402-Invoice – base64 encoded invoice payload.

    • X-402-Network – settlement network (solana or base).

    • X-402-Amount – required amount in the target network’s currency units.

    • X-402-Facilitator – facilitator URL (https://facilitator.payai.network in Neura’s default configuration).

  3. Pay the invoice Use an X402 compatible wallet or SDK to settle the invoice on the declared network. The invoice memo ties the payment to the HTTP request.

  4. Replay with proof Resend the HTTP request with the headers described in the Coinbase guide (for example X-402-Payment-Proof, X-402-Invoice, X-402-Version). The middleware verifies the payment and forwards the request to the handler.

  5. Receive response A successful request returns HTTP 200 with the Neura JSON envelope.

Network routing

Prefix
Network
Notes

/

Solana

Default behavior if no prefix is present. Uses SOLANA_ADDRESS.

/solana

Solana

Explicit Solana routing for clients that separate their integration.

/base

Base

Uses BASE_ADDRESS. Prices are identical to Solana.

The middleware automatically selects the appropriate pay-to address based on the prefix.

Price sheet (per request)

Resource
Price
Applies to

Tokens, Balances, Networks, Bars, Launchpads

0.0004 USD

Every monetized route under /, /solana, /base.

Health, Resilience

Free

/health, /health/resilience.

Client examples

The snippets below mirror patterns from the Coinbase documentation and demonstrate the complete 402 round trip.

TypeScript with @coinbase/x402

Python with coinbase_x402

Both examples rely on helper methods described in the Coinbase documentation. If you are not using the official SDKs, follow the signing rules in the guide to generate the required headers manually.

Common troubleshooting tips

Symptom
Checklist

Receiving repeated 402 responses

Ensure the payment was committed on the correct network, confirm the memo matches the invoice, and verify you are replaying the exact same HTTP method, URL, and body.

429 after payment

The Neura API enforces rate limits even after successful payment. Retry after the number of seconds specified in the retry-after field.

400 level errors

Review the endpoint specific validation guidance in the Endpoint Catalog. Payment proof was accepted; the issue lies with the payload.

Facilitator rejection

Validate CDP_API_KEY_ID and CDP_API_KEY_SECRET, and confirm the facilitator URL from the invoice matches the one hitting your SDK.

Additional resources

Last updated