AgentOS
Integrate

Build on AgentOS

Every endpoint here speaks the x402 wire format, so any x402-capable client can pay for them. Settlement is USDG on Robinhood Chain via EIP-3009.

Four steps, one round trip

Why HTTP 402 finally does something

  1. 01
    Call unpaid

    The client requests the resource with no payment header. Free or already-entitled resources cost nothing — the payment path is never entered.

  2. 02
    Receive terms

    The server answers 402 with a JSON body listing what it accepts: scheme, network, asset, price in atomic units, recipient, and the asset's EIP-712 domain.

  3. 03
    Sign

    The agent signs a TransferWithAuthorization struct over USDG. This is a signature, not a transaction — no gas, no nonce, no broadcast.

  4. 04
    Retry & settle

    The client retries with X-PAYMENT set to the base64 envelope. The server verifies the signature, checks the nonce is unused on-chain and the payer is solvent, then a facilitator broadcasts transferWithAuthorization. The receipt rides back on X-PAYMENT-RESPONSE.

The 402 body

What an unpaid request gets back

json
{
  "x402Version": 1,
  "accepts": [{
    "scheme": "exact",
    "network": "robinhood-chain",
    "maxAmountRequired": "1000",
    "resource": "https://…/api/x402/quote",
    "description": "Live on-chain quote for one stock token",
    "mimeType": "application/json",
    "payTo": "0x…",
    "maxTimeoutSeconds": 120,
    "asset": "0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",
    "extra": {
      "name": "Global Dollar",
      "version": "1",
      "chainId": 4663,
      "decimals": 6
    }
  }],
  "error": "X-PAYMENT header is required"
}

maxAmountRequired is in atomic units — USDG has 6 decimals, so 1000 is 0.001 USDG. The extra block is the asset’s EIP-712 domain; a client needs it to reproduce the signature, and the version there was recovered by matching USDG’s on-chain DOMAIN_SEPARATOR.

The X-PAYMENT envelope

base64 of this JSON

json
{
  "x402Version": 1,
  "scheme": "exact",
  "network": "robinhood-chain",
  "payload": {
    "signature": "0x…",
    "authorization": {
      "from":        "0x…  the agent",
      "to":          "0x…  the receiver",
      "value":       "1000",
      "validAfter":  "1721600000",
      "validBefore": "1721600120",
      "nonce":       "0x…  32 random bytes"
    }
  }
}

Replay protection is on-chain: USDG records each nonce in authorizationState, so a captured envelope can never be settled twice.