Skip to content
Back to field notes
x4027 min read

HTTP 402 as a machine-readable buying interface

How an agent can discover a protected resource, evaluate its payment terms, and request access without turning policy over to the model.

DR

DigiRobotics Protocol Lab

Most online checkout flows assume a person is present to read a page, compare a price, and click a button. An autonomous buyer needs a different interface: explicit terms that software can inspect before it decides whether to continue.

The x402 pattern uses the HTTP 402 Payment Required status as that interface. A protected endpoint can respond with structured payment requirements, allowing a client to validate the request before authorizing a payment and retrying for access.

Keep the model away from the spending boundary

An AI model may help discover or rank resources. It should not get unlimited authority to choose recipients, assets, networks, or amounts.

A safer agent separates flexible discovery from deterministic policy. Before signing anything, code should compare the payment request against an allowlist and a bounded budget.

  1. Request the resource without a payment authorization.
  2. Parse the 402 requirements.
  3. Validate the network, asset, recipient, amount, host, and expiry.
  4. Ask the authorized wallet layer to sign only if every check passes.
  5. Retry the request and verify settlement evidence before granting access.

A challenge is not a receipt

Receiving payment requirements does not prove that a payment occurred. Producing a signature does not prove settlement either.

The seller should release protected data only after the configured verification and settlement path succeeds. The buyer should retain enough non-secret evidence to reconcile the purchase without logging private keys or reusable payment signatures.

Failure should be boring

Agentic purchasing becomes easier to reason about when uncertain outcomes fail closed. Timeouts, stale requirements, unsupported networks, or a recipient mismatch should stop the run.

Idempotency is equally important. A retry after a network interruption must not create a second payment for the same intended purchase.

The DigiRobotics boundary

DigiRobotics is developing this flow around its configured USDG-compatible test assets on Arbitrum Sepolia and Robinhood Chain Testnet. Exact asset labels and capabilities come from the runtime configuration; test assets must not be presented as production Paxos USDG.

The broader design principle is independent of any one dataset: discovery may be intelligent, but authorization must remain explicit, constrained, and auditable.