Traditional API billing assumes a customer account exists before the first request. An agent may discover a service in the middle of a task, need one result and never return. Machine payments shorten that distance, but payment only works when it is attached to a precise unit of value and a recoverable transaction.
The commercial design comes first. The payment protocol is the delivery mechanism for terms the merchant has already made clear.
Price the result, not the protocol
“API access” is difficult for an autonomous buyer to evaluate. “Verify this registration for $0.08” gives the agent a bounded purchase with a known result. A compute product might charge per completed job; a travel service might quote a reservation; a data provider might charge per enriched record.
Fixed prices work when cost and value are predictable. Variable work should return a quote with a currency, an expiry and the exact operation it covers. The buyer should see those terms before anything billable runs.
Put payment in the request path
With x402, an HTTP resource can answer an unpaid request with machine-readable payment requirements. The client authorizes payment and repeats or continues the request with proof. MPP takes a different protocol shape, but the service still needs the same surrounding rule: bind payment to a specific resource, amount and request.
- 01RequestAgent → GatewayCapability + stable request ID
- 02RequirementGateway → AgentPrice + payment challenge
- 03ProofAgent → GatewayBound payment authorization
- 04ExecuteGateway → BackendValidated business request
- 05ResultBackend → GatewayBusiness response
- 06ReceiptGateway → AgentPayment + delivery outcome
Support for a payment rail should not leak into every endpoint. A shared commerce layer can issue requirements, verify proof, record the selected rail and call the API only after the required state is reached.
Make the payment requirement specific
A reusable or vague challenge invites replay. The requirement should be short-lived and tied to the capability, price and request identity. The resulting record should make clear what was authorized and where value is meant to settle.
{
"request_id": "req_01JY8M1Q",
"resource": "company.verify",
"amount": "0.08",
"currency": "USDC",
"network": "base",
"pay_to": "0xMerchantDestination",
"expires_at": "2026-09-20T14:05:00Z"
}Separate payment from delivery
Money moving does not prove the business result arrived. The API can time out after settlement, or the backend can finish while its response is lost. A transaction model should therefore record payment, execution and delivery as separate facts.
If a provider may have processed the payment, hold the transaction in an uncertain state and reconcile it. Trying a second rail immediately can charge the buyer twice.
Protect both money and execution
Replay protection keeps one proof from becoming multiple purchases. Merchant-side idempotency keeps a state-changing operation from running twice after a lost response. These mechanisms solve related but different problems, so a production flow needs both.
Use a stable request ID across payment and execution. Store the payment attempt and reserve the replay key before invoking the backend. Pass the same operation key into the merchant API on every retry.
Choose the first product carefully
Begin with a low-risk capability whose value and cost are easy to explain. Measure completed deliveries rather than payment attempts. Preserve subscriptions and API keys for repeat customers; machine payment can serve one-off buyers without forcing every customer into the same model.
The strongest launch is modest: one resource, one price policy, one payment rail and a receipt that makes failures visible. Additional rails and channels can then reuse the same transaction path.
Frequently asked questions
Can an AI agent pay an API without creating an account?
Yes. Protocols such as x402 are designed for request-level machine payments. The exact onboarding requirements still depend on the payment method and provider.
Is x402 only for AI agents?
No. x402 is a general internet payment standard. Agentic payments are a major use case because the flow fits machine-to-machine HTTP requests.
What is the difference between x402 and MPP?
Both address machine payments. x402 uses an HTTP 402 based payment flow. MPP defines a programmatic payment protocol for agents and services and is co-authored by Tempo and Stripe. Their supported payment methods and integration models differ.
Should I charge per API request?
Only if one request maps cleanly to cost or value. Per-result and quoted pricing may fit better for variable workloads.
What happens if the agent pays but the API call fails?
Store the payment and execution states separately. The transaction may need retry or operator reconciliation. Do not label the payment failed if the money already moved.
Sources and further reading
- x402 Foundationx402.org
- x402 documentationdocs.x402.org
- Stripe, Machine Payments Protocolstripe.com
- MPPmpp.dev
- Agent Payments Protocolgithub.com