Actors
Three roles participate in every x402 flow:- Client: the agent or application requesting the protected resource. The client signs the payment and retries the request.
- Resource server: the server protecting the resource. It issues the 402, checks the payment, and returns the response only after the check passes.
- Facilitator: a trusted third party that validates payment payloads and submits settlements on the resource server’s behalf. The resource server configures which facilitator to use. The client never contacts the facilitator directly.
The 402 response
When the resource server requires payment, it returns a 402 status with aPaymentRequirements payload. In x402 version 1, this arrives as a JSON body. In version 2, it comes as a base64-encoded payment-required response header.
The payload contains an accepts array listing the payment options the server accepts. The client picks the option that matches its configured scheme and network, then constructs a signed payment from those terms.
Payment requirements fields
tokens are identified by their contract address in theasset field.
identifies the blockchain network in the network field.
| Field | Type | Description |
|---|---|---|
scheme | string | Payment scheme. 4mica-credit for 4Mica guarantee flow; exact for direct transfer. |
network | string | CAIP-2 chain identifier. eip155:8453 for Base mainnet. |
maxAmountRequired | string | Maximum amount charged, in token base units. |
asset | string | ERC-20 token contract address for the settlement asset. |
payTo | string | Recipient wallet address. |
resource | string | URL of the protected resource. |
description | string | Human-readable description of what the resource provides. |
mimeType | string | MIME type of the response the client receives after paying. |
maxTimeoutSeconds | number | Maximum seconds allowed between the client signing and settlement completing. |
extra | object | Optional scheme-specific data, including V2 validation policy fields. |
accepts array lists options; neither side is locked into a single payment method.
The general flow
If the client has payment requirements cached from a previous call to this resource, it can skip the initial 402 exchange and attach the signed payment to the first request directly.The 4Mica credit flow
When the scheme is4mica-credit, the payment is a signed guarantee backed by collateral held in 4Mica Core, not a direct on-chain token transfer.
The guarantee
The guarantee is a signed claim: the payer commits to a specific amount, recipient, asset, and request identifier. The resource server submits that claim to the facilitator at/settle. The facilitator passes it to Core, which locks the corresponding collateral and returns a BLS certificate.
Each guarantee carries a unique reqId. Reusing the same signed identity is rejected, which ties every guarantee to one request and prevents replay.
The BLS certificate is the payment authorization and settlement evidence. Payable guarantees enter clearing cycles, where obligations are netted before on-chain settlement.
Why not settle on-chain per request
The standardexact scheme settles every request with an individual on-chain transaction. That works at low volume. At the request rates agents generate, per-request chain writes exhaust block space and add settlement latency to every call.
The 4mica-credit scheme separates authorization from settlement. The guarantee is an off-chain cryptographic commitment that signs and verifies in milliseconds, with no chain write required per request. Obligations accumulate across all participants and net in a clearing cycle. Only the net amounts settle on-chain.
Payment headers
| Header | Direction | Contents |
|---|---|---|
payment-required | Server → Client | Base64-encoded JSON with x402Version, error, and accepts array (v2). |
X-PAYMENT | Client → Server | Base64-encoded PaymentPayload with signed guarantee (v1). |
PAYMENT-SIGNATURE | Client → Server | Signed payment for v2 flows. |
payment-response | Server → Client | Base64-encoded settlement receipt on a successful 200 response. |
Verify vs settle
POST /verify checks the payment payload without issuing a guarantee or contacting Core. Use it as a preflight before doing expensive work. If it fails, return a new 402 with the reason rather than a 400.
POST /settle validates and submits the guarantee to Core. The facilitator returns the BLS certificate on success. Call this once you are ready to accept the guarantee as payment.
For inexpensive resources, skip /verify and call /settle directly. For compute-heavy or high-value responses, verify first to avoid doing work for a payment that fails.
Builder guidance
As a resource server:- Return the 402 response before doing any work. Never serve content before the payment is verified.
- Set
maxAmountRequiredin token base units: for USDC (6 decimals), $1.00 is"1000000". - Set
maxTimeoutSecondsto the time you are willing to wait between the client signing and your/settlecall. 300 seconds is a reasonable starting point. - Persist the BLS certificate from
/settleand connect it to the request and delivery record.
- Generate a unique
reqIdfor every guarantee. Never reuse a signed request identity. - If the server returns a new 402 on the retry, read
invalidReasonbefore signing again.