Pay x402 resources with AllowKit
AllowKit wraps paid x402 requests with spending controls. When a resource returns
402 Payment Required, AllowKit:
- parses the payment requirement
- checks the active allowance policy
- approves, blocks, or requests human confirmation
- submits payment if allowed
- retries the request with payment proof
- records a receipt
Target flow
Section titled “Target flow”Agent │ │ GET paid resource ▼Resource │ │ 402 Payment Required ▼AllowKit │ │ check policy + allowance │ pay if approved ▼Resource │ │ retry with payment proof ▼Agent receives responseTarget API shape
Section titled “Target API shape”import { allowkitFetch } from "@allowkit/x402"; // roadmap — not yet shipped
const fetchWithPayment = allowkitFetch({ allowanceId: "alw_research_agent", policy: { maxPerRequestUsd: 0.10, maxPerDayUsd: 10, allowedHosts: ["*.paid-api.com"], requireApprovalAboveUsd: 1 }});
const response = await fetchWithPayment("https://data.paid-api.com/report");