Guides

How agents pay (x402)

Verivyx implements the x402 protocol (version 2). An agent that wants a protected resource receives a machine-readable 402 Payment Required, settles a USDC payment on Stellar, and retries — no human, no API key, no account. This page is the complete protocol reference; for the runnable narrative see the Playground.

The flow

  • The agent requests a protected URL and receives 402 Payment Required with a PAYMENT-REQUIRED header — a base64 payload describing exactly how to pay.
  • The agent picks one of the offered requirements, signs a USDC payment that satisfies it, and retries the request with a PAYMENT-SIGNATURE header.
  • Verivyx verifies the payment on Stellar, the paywall_core contract splits it between creator and platform, and the content is returned with 200 OK plus a PAYMENT-RESPONSE header.
http
# 1. Request the protected resource
GET https://your-domain.com/article
→ 402 Payment Required
  PAYMENT-REQUIRED: eyJ4NDAyVmVyc2lvbiI6Mi4u   # x402 requirements (base64)

# 2. Sign a USDC payment, then retry with the signature
GET https://your-domain.com/article
  PAYMENT-SIGNATURE: <signed x402 payload>     # base64
→ 200 OK                                       # content unlocked
  PAYMENT-RESPONSE: eyJzdWNjZXNzIjp0cnVlLi4u   # settlement result (base64)

HTTP headers

HeaderDirectionMeaning
PAYMENT-REQUIREDResponse (402)Base64 of the PaymentRequired body — how to pay.
X-Payment-RequiredResponse (402)Same payload; backward-compatible alias.
PAYMENT-SIGNATURERequest (retry)Base64 of the signed payment payload (x402 v2).
X-PAYMENTRequest (retry)Legacy alias for the signed payload; also accepted.
PAYMENT-RESPONSEResponse (200)Base64 of the settlement result (transaction hashes, split).

The 402 body (PaymentRequired)

The decoded PAYMENT-REQUIRED header is a JSON PaymentRequired object. It advertises one or more accepts[] options — pay any one of them.

FieldTypeDescription
x402VersionnumberProtocol version. Always 2.
errorstringHuman-readable reason the request was rejected.
resourceobjectThe resource being gated — { url, mimeType }.
accepts[]arrayThe payment options (see below). Satisfy one to unlock.
extensionsobjectVerivyx adds a facilitator hint: { scheme, url, version } pointing at the hydrate endpoint to retry against.

Each accepts[] entry

FieldDescription
schemePayment scheme. Verivyx uses exact (pay the exact amount).
networkCAIP-2 network id, e.g. stellar:testnet.
amountPrice in atomic USDC units (also mirrored as maxAmountRequired).
assetThe USDC asset: a Soroban contract id, or classic USDC:<issuer>.
payToDestination: the paywall contract (Soroban) or the creator account (classic).
maxTimeoutSecondsHow long the quote is valid before it must be re-fetched.
extraSplit details (distribution / splitPayments), areFeesSponsored, domain, and paywallContract.

Payment rails

Every 402 advertises two equivalent rails so any x402 client can pay:

Soroban USDCClassic USDC
AssetSoroban USDC contract (SAC)USDC:<issuer>
Pays topaywall_core contractCreator's Stellar account
SplitOn-chain by the contractTwo payment operations
Network gasSponsored by Verivyx — no XLM neededPaid by the agent

Amounts are always atomic, 7-decimal units: 1 USDC = 10,000,000. A 0.05 USDC price is 500000.

Status codes

CodeWhen
200Payment accepted (or already paid / verified human) — content returned.
402Payment required, or the supplied payment was invalid — body carries fresh requirements.
404Domain not registered with Verivyx.
502Fail-closed: the upstream content could not be fetched (content_unavailable) — never leaks partial content.

Standards & compatibility

  • Verivyx is x402 v2-compliant and interoperates with generic x402 clients — see the x402 specification and the reference implementation from Coinbase's x402 project.
  • Payments settle on Stellar in USDC; networks are identified with CAIP-2 ids (stellar:testnet, stellar:pubnet).
  • Both the standard header (PAYMENT-SIGNATURE) and the legacy alias (X-PAYMENT) are accepted, so older clients keep working.

What can pay today

Any spec-compliant x402 client can pay a Verivyx paywall right now. The fastest way to see a real end-to-end payment is the Playground, where a sandboxed agent pays both a demo paywall and a real protected post on testnet and shows every step on-chain. To wire an AI agent up directly, use the x402 MCP server.

Prefer code? The Payment & content API documents every endpoint with full request/response schemas.