Pay Cloudflare-gated APIs
This guide shows how an AI agent can use AllowKit to safely pay APIs protected by x402-compatible gateways such as Cloudflare Monetization Gateway.
import { allowkitFetch } from "@allowkit/x402"; // roadmap — not yet shipped
const fetchWithAllowance = allowkitFetch({ allowanceId: "alw_cloudflare_demo", policy: { maxPerRequestUsd: 0.05, maxPerDayUsd: 5, allowedHosts: ["api.example.com"] }});
const response = await fetchWithAllowance( "https://api.example.com/premium/research");Expected result
Section titled “Expected result”If price <= policy limit: payment approved request retried resource returned receipt created
If price > policy limit: payment blocked or approval requested