# x402: How to Accept Payments from AI Agents on Your API | CoinCircuit Blog

> A developer guide to x402 gasless payments: EIP-3009, Permit2, and Solana signing schemes, resource server integration, and settlement via the CoinCircuit API.

Source: https://coincircuit.io/blog/x402-machine-to-machine-payments/

[Back to Blog](https://coincircuit.io/blog/)

Machine Economy

# x402: How to Accept Payments from AI Agents on Your API

Chidubem Ogbuefi

Mar 18, 2026

Less than 1 min read

*x402: How to Accept Payments from AI Agents on Your API*

## x402: The Payment Protocol That Took 35 Years

The original 1991 HTTP spec reserved status code 402 for digital payments. Credit cards need minimum transaction floors. SWIFT needs human sign-off at every hop. Neither works when a machine needs to pay $0.002 for an API call and retry in milliseconds.

x402 builds on that status code. It pairs the 402 response with gasless stablecoin transfers, letting AI agents pay for resources programmatically. Three signing schemes cover the major chains and assets: EIP-3009 for USDC on Base and Arbitrum, Permit2 for USDC and USDT on all EVM chains, and native fee payer abstraction for Solana.

## Key Concepts

**EIP-3009 (TransferWithAuthorization):** A standard built into USDC that lets a wallet holder sign a transfer off-chain. The signed authorization can be submitted by anyone. The signer never pays gas. Supported on Base and Arbitrum only.

**Permit2:** Uniswap's universal approval contract. Works with any ERC-20 token, including USDC, USDT, and tokens without built-in gasless transfer support. The token holder approves the Permit2 contract once on-chain, then signs individual transfer permits off-chain for each payment. CoinCircuit submits the permit and covers gas. Supported on Base, Arbitrum, and BSC.

**Solana fee payer abstraction:** Solana transactions natively support separate fee payers. The agent builds a transfer, designates CoinCircuit's wallet as the fee payer, and partially signs. CoinCircuit adds its fee payer signature and submits. Works with SOL, USDC, and USDT on Solana.

**Gasless payment:** The agent signs an authorization to move tokens from their wallet to a deposit address. The resource server (your backend) submits this signed payload to CoinCircuit, which settles it on-chain and covers gas. The agent only needs a wallet and a signing key.

**Resource server:** Your API backend. You create the payment session, return the 402 response to the agent, receive the signed payload back, and call CoinCircuit to settle it.

## How the x402 Flow Works

Your server creates a payment session. The agent signs a payment authorization using the appropriate scheme for their blockchain and asset. Your server submits the signed payload to CoinCircuit for on-chain settlement.

For a step-by-step guide on building signed payloads for each scheme, see [How to Sign a Gasless Stablecoin Payment](https://coincircuit.io/blog/how-to-sign-gasless-payment/).

### Step-by-Step

**1\. Agent requests your resource**

The agent sends a request to your API:

```
GET /api/premium-data
```

**2\. Your server creates a payment session**

Your backend calls CoinCircuit to create a checkout session:

```
POST https://api.coincircuit.io/api/v1/payments
x-api-key: sk_live_your_key

{
  "amount": "1.00",
  "currency": "USD",
  "asset": "USDC",
  "chain": "base",
  "customer": {
    "email": "agent@example.com"
  }
}
```

The response includes a deposit address, the required USDC amount, and a session reference.

**3\. Your server responds with 402**

Return the payment details to the agent:

```
HTTP/1.1 402 Payment Required

{
  "paymentRequired": {
    "chain": "base",
    "asset": "USDC",
    "amount": "1000000",
    "depositAddress": "0xabc...def"
  }
}
```

Your server keeps the session reference internally for settlement.

**4\. Agent signs the payment**

The agent signs a gasless payment authorization using the scheme that matches its blockchain and asset. Every scheme produces a flat payload with `from`, `to`, `value`, and scheme-specific fields.

The agent sends the signed payload back to your server:

```
POST /api/premium-data/pay

{
  "scheme": "eip3009",
  "payload": {
    "from": "0xAgentWallet...",
    "to": "0xabc...def",
    "value": "1000000",
    "validAfter": "0",
    "validBefore": "1774055094",
    "nonce": "0xrandom32bytes...",
    "signature": "0xabcd...1234"
  }
}
```

**5\. Your server settles via CoinCircuit**

Your backend submits the signed payload to CoinCircuit for on-chain settlement:

```
POST https://api.coincircuit.io/api/v1/payments/agent/settle
x-api-key: sk_live_your_key

{
  "sessionReference": "cs_ref_abc123",
  "scheme": "eip3009",
  "chain": "base",
  "asset": "USDC",
  "payload": {
    "from": "0xAgentWallet...",
    "to": "0xabc...def",
    "value": "1000000",
    "validAfter": "0",
    "validBefore": "1774055094",
    "nonce": "0xrandom32bytes...",
    "signature": "0xabcd...1234"
  }
}
```

CoinCircuit validates the session requirements, submits the transaction on-chain, and covers gas. The response includes the transaction hash and block confirmation.

**6\. Your server releases the resource**

Once you receive a successful settlement response, deliver the resource to the agent.

### Integration Flow

```
Agent -> GET /api/premium-data
Server -> CoinCircuit: POST /payments (creates session)
Server -> Agent: 402 (deposit address, amount)
Agent -> Signs payment (eip3009 / permit2 / solana)
Agent -> Server: POST /pay (signed payload)
Server -> CoinCircuit: POST /payments/agent/settle
Server -> Agent: 200 (resource delivered)
```

## Pre-Validating Payments

Before settling, you can dry-run the payment to catch problems early. Call the verify endpoint with the same payload:

```
POST https://api.coincircuit.io/api/v1/payments/agent/verify
x-api-key: sk_live_your_key
```

This runs scheme-specific checks without touching the blockchain. For EIP-3009: authorization timestamps, nonce replay, and sender balance. For Permit2: deadline and sender balance. Returns 200 if the payment will succeed, or 400 with per-check pass/fail results.

## Supported Chains and Assets

Scheme

Asset

Chains

eip3009

USDC

Base, Arbitrum

permit2

USDC, USDT

Base, Arbitrum, BSC

solana

SOL, USDC, USDT

Solana

All EVM networks offer sub-second block times and gas costs under a cent. Solana settles in under a second with fees below $0.001.

## Why the Resource Server Submits

The agent signs the authorization, but your server submits it. Two reasons:

You control the session lifecycle. By submitting through your backend, you tie the settlement to your checkout session, validate the amount, and confirm payment before releasing the resource.

The agent stays simple. The agent only needs a wallet and signing capability. No CoinCircuit API key, no gas tokens, no blockchain node. Sign and hand off.

### Start accepting crypto today

Developer friendly API. Instant settlements. No hidden fees.

[Get Started Now](https://coincircuit.io/docs/)
