Skip to main content
PERSONA 2 VARIANT - API PROVIDERS

Sell your API to AI agents.

AI agents cannot fill out a credit card form. They can pay you in USDC. Blockchain0x makes that one API call.

THE PAIN

Your API was designed for humans. Your callers are now agents.

The next decade of API revenue will not come from human signups. It will come from AI agents calling APIs on behalf of their users, often programmatically and without any human in the loop. Those agents cannot use your existing checkout. They cannot fill out a credit card form, cannot create an account, cannot click a confirmation email, cannot remember a password.

What they can do is read a 402 Payment Required HTTP response, parse a hosted payment URL out of the headers, pay in USDC, and continue. That is the entire shape of agent-driven API commerce. The cost model (per-call billing in stablecoin) also fits agent usage shape much better than card-based subscriptions: cards fail at sub-$1 transactions; USDC on Base costs cents in gas; chargebacks do not happen between machines.

Blockchain0x is the bridge. Wrap your API endpoint with a tiny middleware. When an unpaid call hits it, return a payment-required response with a hosted URL. The agent pays. The next call succeeds. You collect USDC and run your API as before. Nothing about your business logic changes; the billing layer rides alongside.

402 PAYMENT REQUIRED

The HTTP status code finally has a use.

HTTP 402 was reserved in the original spec for "future use" and never standardized. For thirty years it sat unused while the internet built per-account subscription billing on top of 200/401/403. With Coinbase's x402 protocol, 402 finally has a standard implementation: any API that needs payment-before-it-runs can return a structured 402, and any client that understands the spec can pay and retry.

YOUR API RETURNS THIS WHEN A CALL HAS NOT BEEN PAID
HTTP/1.1 402 Payment Required
X-Payment-Required: true
X-Payment-Network: base
X-Payment-Asset: USDC
X-Payment-Amount: 0.50
X-Payment-Recipient: 0xYourAgentWalletAddress
X-Payment-Facilitator: blockchain0x
Link: <https://wallet.blockchain0x.com/a/your-api/pay/pr_01J9...>; rel="payment"

{
  "error": "payment_required",
  "amount_usdc": "0.50",
  "hosted_url": "https://wallet.blockchain0x.com/a/your-api/pay/pr_01J9...",
  "expires_at": "2026-05-15T09:30:00Z"
}

What the headers mean

  • X-Payment-Required - signals to x402-aware clients that this 402 is payment-related, not a misuse of the status code for some other purpose.
  • X-Payment-Network / Asset / Amount - the chain, token, and amount the caller needs to pay. Allows clients to pre-authorize wallets for matching parameters.
  • X-Payment-Recipient - the wallet address that will receive the payment. The client can verify this matches the expected recipient before paying.
  • X-Payment-Facilitator - the platform processing the payment (us). Clients can validate the facilitator's reputation before paying.
  • Link rel="payment" - the hosted URL the caller follows to complete the payment. Standard HTTP Link header per RFC 8288.

For clients that do not yet understand x402 - which is most of them today - the JSON body provides a fallback. Any HTTP client can parse hosted_url and surface it to a human for one-click payment. As x402 adoption grows, more clients will pay programmatically without the human step.

DECORATOR PATTERN

One decorator. Three languages. Same shape.

The middleware wraps your existing route handler. Your code never knows whether the call was paid (the wrapper handles that); when your handler runs, payment has already cleared. The shape is identical across Python, TypeScript, and Go.

PYTHON (FLASK)
from flask import Flask
from blockchain0x.flask import requires_payment

app = Flask(__name__)

@app.route("/api/expensive-operation", methods=["POST"])
@requires_payment(amount_usdc="0.50", reason="expensive-operation")
def expensive_operation():
    return run_the_work()
TYPESCRIPT (EXPRESS)
import express from "express";
import { requiresPayment } from "@blockchain0x/express";

const app = express();

app.post(
  "/api/expensive-operation",
  requiresPayment({ amountUsdc: "0.50", reason: "expensive-operation" }),
  async (req, res) => {
    res.json(await runTheWork());
  },
);
GO (NET/HTTP)
import (
  "net/http"
  bcx "github.com/blockchain0x/go"
)

func main() {
  http.Handle("/api/expensive-operation",
    bcx.RequiresPayment(bcx.Config{
      AmountUSDC: "0.50",
      Reason:     "expensive-operation",
    })(http.HandlerFunc(expensiveOperation)))

  http.ListenAndServe(":8080", nil)
}

We ship official wrappers for Flask, FastAPI, Django, Express, Fastify, Hono, and Go's net/http. For other frameworks (Ruby on Rails, Phoenix, ASP.NET, Spring, etc.), the underlying API is plain HTTP - hand-write the middleware in your stack's idiom. The full source of all wrappers is open on GitHub as reference implementations.

VS STRIPE CHECKOUT

When to reach for each tool.

Stripe is the right tool for human checkout. Blockchain0x is the right tool for agent checkout. They solve different problems and frequently sit side by side on the same API.

DimensionBlockchain0xStripe Checkout
BuyerAny HTTP client (human or AI agent)Human at a browser
Auth required before paymentNo - first call returns 402 with payment URLYes - email + card form
Settlement speed5 seconds (USDC on Base)2-7 days (card networks)
Chargeback riskNone (USDC is final)Up to 120 days of chargeback window
Per-transaction cost economicsWorks at $0.01-$0.10 per call (Base gas + our fee)Card fees make sub-$1 transactions uneconomical
RefundsManual - your code sends USDC back to the payer addressAutomated through Stripe dashboard
International supportSame wallet, any country, no extra configPer-country licensing, currency conversion, regional rules
Best forProgrammatic agent-driven API consumptionHuman-driven checkout (SaaS signup, e-commerce)

The pattern most API providers land on: keep Stripe for the human signup flow (your dashboard, your subscription product page); add Blockchain0x at the API edge for programmatic agent access. Authenticated human users (with API keys obtained through Stripe) skip the 402 path entirely - the middleware checks for an Authorization header first. Unauthenticated calls fall through to the 402 + USDC pattern. Both audiences are served by the same API code.

WHAT PLAN FITS

Pro for early traffic. Business when audit logs become a requirement.

API providers almost always start on Pro from day one (Free's read-only API does not support the middleware's payment-request creation). The volume crossover to Business arrives quickly for high-traffic APIs: an API doing 100,000 paid calls per month at $0.05 each hits $5,000 in monthly volume and crosses into Business-economical territory at the Pro-to-Business break-even point of $2,000.

  • Free: useful only for the dashboard and metadata exploration. Not viable for the middleware.
  • Pro ($9/agent/mo): default for live API monetization. Middleware, webhooks, exports, custom branding.
  • Business ($29/agent/mo): when you need audit logs for compliance, allowlist for institutional customers, or higher API rate limits.
See full pricing
FREQUENTLY ASKED

Five API-provider questions.

Can I run Stripe alongside Blockchain0x for the same API?

Yes, and many API providers do. The pattern: keep your existing Stripe-based human signup flow for human customers; add the Blockchain0x decorator to your API endpoints so AI agents can pay programmatically. Authenticated human users (with API keys obtained via Stripe signup) skip the 402 check entirely; unauthenticated callers get 402 + pay-with-USDC path. Both audiences get what they want without one path blocking the other.

What if an AI agent pays then exits before retrying the call?

The payment is still valid; it just goes unused for whatever cache window you set (default 60 seconds on the middleware). The agent's wallet shows a successful USDC transfer to your address. From the agent's perspective, it lost the USDC; from yours, you got paid for a call that never executed. This is rare in practice (the protocol-level retry happens immediately), but if you want to be defensive, you can implement an auto-refund for payments older than 24 hours with no matching authenticated call - we expose a refund API for this exact pattern.

How do I version my API and price changes?

The amount and reason passed to the decorator are per-route, so different routes can charge different prices. For versioning, the recommended pattern is to expose v2 endpoints alongside v1 with the new prices wired into the v2 decorator; clients see the new amount in their first 402 response and pay accordingly. Sudden price increases on stable routes are bad protocol citizenship; we recommend deprecating the old route and serving a 410 Gone with a Link header pointing to the new route at the new price.

What does observability look like - logs, metrics, alerts?

Every 402 emission, every successful payment unlock, and every cache hit shows up in the Blockchain0x dashboard with full request context (route, amount, payer wallet, timestamp). Pro and Business expose this via webhook events so you can stream into Datadog, Splunk, or your own logging stack. The middleware also exposes Prometheus metrics out of the box: blockchain0x_402_emitted_total, blockchain0x_payments_received_total, blockchain0x_cache_hits_total, blockchain0x_refunds_initiated_total. Wire alerts on the obvious ones (sudden spike in 402 emissions, drop in payment rate, refund rate above 5%).

What about regulatory questions - am I a money services business if I do this?

Probably not, but this is jurisdiction-specific and we are not your lawyers. The reason: you are receiving payment for services you provide, not transmitting money between third parties (which is the trigger for MSB status in the US). USDC is recognized as a payment-stablecoin in most jurisdictions. You do owe tax on the USD-equivalent revenue; we generate the records you need for that. If you operate in a high-volume B2B context or in a jurisdiction with strict crypto rules (Germany, Singapore for certain shapes), get specific legal advice before flipping on production traffic. We can refer you to firms that have done this work for previous customers.

Let agents pay for your API.

Drop the decorator on any route. Stripe stays for humans. Both audiences served.