Overview
The x402 protocol turns HTTP 402 (Payment Required) into a machine-readable payment flow. Every protected MemoClaw endpoint requires a signed payment proof in the request header. The payment amount depends on the endpoint, and the payer’s wallet address automatically becomes their user identity.The flow
Request without payment
Client sends a request to a protected endpoint (e.g.,
POST /v1/store) without any payment header.Server returns 402
Server responds with HTTP 402 and a JSON body containing payment requirements: the exact USDC amount, the receiving wallet address, the network (Base, chain ID 8453), and the payment scheme (
exact).Client signs payment
The client signs a USDC transfer using either EIP-3009 (
transferWithAuthorization) or Permit2, then base64-encodes the signed payload.Retry with payment header
Client retries the original request with the payment proof in the
X-PAYMENT or payment-signature header.Wallet identity extraction
The payer’s EVM address is extracted from the signed payment payload. For EIP-3009 transfers, it comes from
payload.authorization.from. For Permit2, from payload.permit2Authorization.from. This address becomes the user’s identity — all memories are scoped to it.Per-route pricing
Only endpoints that use OpenAI (embeddings or LLM) are charged. Everything else is free.| Endpoint | Price (USDC) |
|---|---|
POST /v1/store | $0.005 |
POST /v1/store/batch | $0.04 |
POST /v1/recall | $0.005 |
PATCH /v1/memories/:id | $0.005 |
PATCH /v1/memories/batch | $0.005 |
POST /v1/memories/extract | $0.01 |
POST /v1/memories/consolidate | $0.01 |
POST /v1/ingest | $0.01 |
POST /v1/context | $0.01 |
POST /v1/migrate | $0.01 |
| List, get, delete, search, suggested, relations, history, graph, export, namespaces, stats | Free |
GET /health | Free |
Client options
There are three approaches for handling x402 payments:1. @x402/fetch (recommended)
The JavaScript SDK handles the 402 → pay → retry flow automatically.2. @x402/cli
CLI tool for manual or shell usage. Useful for testing and scripting.3. Manual signing
Construct EIP-3009 or Permit2 payloads yourself. See x402.org/docs for the full specification.Learn more
x402 Protocol
Full protocol specification and reference implementations.
Authentication
Setup guide for configuring x402 payments in your agent.
Pricing
Complete pricing breakdown for all endpoints.