SPECIFICATION // REV: 2024.02

Protocol
Architecture

The x402 protocol facilitates autonomous machine-to-machine value exchange without the need for pre-negotiated API keys or session management. It uses the HTTP 402 status code as a native flow control mechanism, enabling agents to discover payment requirements at runtime.

DOC_NAV
LOGIC_FLOW // SEQUENCE_DIAGRAM
Autonomous Agent
POST /api/crawl
Scraper Edge
402 REQUIRED
Agent Wallet
SIGN & DEBIT
Data Response
HEADER_DEFINITIONS
Field Type Description
X-PAYMENT Base64 EIP-712 signed transferWithAuthorization payload. Required on all POST /api/crawl requests.
X-PAYMENT-RESPONSE Base64 Returned by server after successful payment verification. Contains transaction hash and settlement details.
scheme String Payment scheme in 402 body. Currently exact for fixed USDC amounts.
maxAmountRequired String Amount in atomic units (6 decimals). 100000 = $0.10 USDC on Base Sepolia.
payTo Address Settlement wallet address. Receives USDC via transferWithAuthorization on Base Sepolia.
STATUS_CODES
Code Identity Cause
402 PAYMENT_REQUIRED No X-PAYMENT header or payment verification failed. Returns x402 discovery body with accepts[].
202 JOB_ACCEPTED Payment verified. Returns jobId, pollUrl, and initial status: queued.
404 JOB_NOT_FOUND Expected during 30-60s after POST due to D1 eventual consistency. Retry with exponential backoff.
409 ALREADY_TERMINAL DELETE called on a job already in completed, failed, or cancelled state.
TECHNICAL_DEEP_DIVE // RESPONSE_FIELDS
x402Version
Protocol version string returned in the 402 response body. Used by agent wallets to select compatible payment scheme.
jobId
UUID assigned to the crawl job. Used for polling GET /api/crawl/:jobId and cancellation via DELETE.
pollUrl
Full URL for polling job status. Includes base URL and jobId path. Returned in the 202 accepted response body.
status / transaction
Polling response includes status (running | completed | failed | cancelled), transaction hash, network, and payer address.