Transaction flow

How Agent Commerce Gateway works

Agent Commerce Gateway gives an existing API one controlled edge for agent traffic. The backend continues to own the useful work; the Gateway makes each request legible as a commercial transaction before that work begins.

This separation matters because an agent request is more than a new transport. It can carry a price, an authorization, a payment proof and retry risk. Putting those concerns in one boundary keeps protocol changes out of the application and gives operators a durable account of what happened.

One boundary for agent channels

Native HTTP and MCP are current entry points. A2A and ACP are experimental profiles, AP2 is an experimental authorization profile, MPP is an experimental payment rail, and UCP remains planned. Those labels are deliberate: the standards are evolving, while the merchant integration should remain stable.

Each adapter translates its protocol into a canonical capability request. From that point on, the same validation, pricing, payment and receipt rules apply. Adding a channel therefore means adding an adapter, not teaching the backend another protocol.

One integration boundary
Native HTTPstable
MCPstable
A2A · ACPexperimental
Agent-facing edgeAgent Commerce Gatewayvalidate · price · protect · receipt
Your systemExisting backend APIbusiness logic · fulfilment · data
Protocols terminate at the Gateway. The merchant backend keeps one stable contract.

A capability becomes a contract

Integration starts with something the business already does: verify a document, enrich a company, calculate a quote, reserve inventory or run a bounded compute job. The merchant defines the accepted input, the backend call, the price and the channels that expose it. That contract is what every adapter exposes.

Validation happens at the edge, before protocol input reaches business logic. Invalid types, missing fields and resource limits fail in the same way regardless of the channel. A valid request is mapped to the HTTP shape the existing service already understands.

Capability definitionyaml
resources:
  company.verify:
    name: Company verification
    input:
      type: object
      properties:
        company_id: { type: string }
      required: [company_id]
      additionalProperties: false
    backend:
      type: http
      method: POST
      url: ${MERCHANT_API_BASE_URL}/v1/companies/verify
      timeoutMs: 10000
    pricing:
      type: fixed
      amount: "0.08"
      currency: USDC
    expose: [http, mcp]
    payments: [x402]

One canonical transaction path

After mapping, the request enters a shared pipeline. A free lookup can skip payment; a paid and state-changing operation takes the longer route. The order stays explicit so payment cannot accidentally become a substitute for authorization, or a successful settlement be mistaken for successful delivery.

Canonical transaction path
01ValidateKnown input
02PriceKnown terms
03VerifyPayment proof
04ProtectReplay reserved
05Execute · settleOrder set by flow
06ReceiptDurable outcome
Free resources can skip payment stages. By default, x402 settles after the backend responds and MPP before the call. Payment, execution and delivery are recorded separately.

Pricing stays attached to the capability, not to the protocol. The agent can see the commercial terms before the merchant operation runs, while the backend remains unaware of how MCP or a payment rail expressed them.

How a paid request moves

x402 and experimental MPP both settle through an x402 facilitator. The first request can return a machine-readable payment requirement. The agent authorizes payment and submits proof; the Gateway verifies it and reserves it against replay. Under the authorization flow, the x402 default, it calls the merchant backend before settling. With paymentFlow: upfront, the MPP default, it settles first. A failed backend call under the authorization flow leaves the payment unsettled; a refused or uncertain settlement withholds the backend response.

Paid request sequence
  1. 01RequestAgent → GatewayCapability + input
  2. 02RequirementGateway → AgentPrice + payment challenge
  3. 03ProofAgent → GatewayBound payment authorization
  4. 04ExecuteGateway → BackendValidated business request
  5. 05ResultBackend → GatewayBusiness response
  6. 06ReceiptGateway → AgentPayment + delivery outcome
The payment exchange surrounds the business call; it does not replace it.
The backend still needs idempotency

Replay protection prevents the same payment path from becoming a new transaction. A state-changing backend should also accept a stable operation key. If the action completes but its response is lost, a retry can then return the original result instead of repeating the side effect.

Payment and delivery are separate facts

With upfront settlement, payment can succeed while the backend is unavailable. With the authorization flow, the backend can finish while settlement is refused or uncertain, withholding its response. In either flow, the response can be lost in transit. Recording these outcomes separately gives operators the information needed to recover.

PaymentsettledSettled before the call
ExecutionfailedBackend returned 503
Deliverynot deliveredNeeds operator review
MPP's default upfront flow settles before the backend call, which can still fail. Separate payment and delivery records support recovery.

The Gateway records payment, execution and delivery separately. Each paid resource uses its first enabled rail, without switching rails after an uncertain result. Operators can inspect the records, use agent-commerce reconcile to resolve outcomes from chain evidence, or record a verdict with agent-commerce resolve when that evidence is inconclusive.

Durable state makes recovery possible

One SQLite receipt database preserves receipts, events, payment attempts, replay reservations, journal entries, AP2 holds, ACP claims and unpaid A2A tasks across restarts. The journal links payment, backend execution and receipts. Run one gateway per database; PostgreSQL support is planned for deployments needing a different persistence model.

A receipt gives buyer and merchant one safe reference for the whole operation. It can state the capability, settlement reference, backend outcome and delivery status without exposing credentials or raw payment material.

Receiptjson
{
  "id": "receipt_3f6c…",
  "requestId": "req_9b1e…",
  "resourceId": "company.verify",
  "protocol": "http",
  "payment": {
    "status": "settled",
    "provider": "x402",
    "externalReference": "0x91e…42c",
    "amount": "0.08",
    "currency": "USDC",
    "network": "eip155:84532"
  },
  "deliveredAt": "2026-09-16T14:31:56.720Z",
  "backendStatus": 200,
  "durationMs": 239
}

What stays under merchant control

The merchant keeps the backend, capability definitions, pricing, settlement destination, deployment environment and customer relationships. Agent Commerce Gateway is neither a marketplace nor a payment processor. It is the transaction layer around resources the business already owns.

Before accepting traffic, the operator can run agent-commerce doctor. It checks the active configuration as a working system: Gateway readiness, backend reachability, exposed protocols, payment configuration, storage and relevant external dependencies. The goal is to find a broken link before an agent reaches it with a paid request.

bash
agent-commerce doctor --json

Frequently asked questions

What does Agent Commerce Gateway do?

Agent Commerce Gateway sits between AI agents and an existing merchant API. It handles protocol input, pricing, payment, replay protection, transaction state and receipts before the merchant backend performs the business operation.

Do I need to rebuild my API to use Agent Commerce Gateway?

No. Protocol adapters map agent requests into the backend contract the business already uses.

Which agent protocols does the Gateway support?

The current implementation includes native HTTP and MCP. A2A and ACP are experimental profiles, AP2 is an experimental authorization profile, MPP is an experimental payment rail, and UCP is planned.

How are paid API requests handled?

For x402 and experimental MPP, the Gateway verifies the proof, reserves it against replay and records payment and delivery outcomes. By default, x402 calls the backend before settling; MPP settles first. paymentFlow sets the order.

What happens if payment succeeds but delivery fails?

Payment and delivery remain separate facts. A transaction can be recorded as paid but not delivered, which gives the operator a precise state to recover from.

How does the Gateway prevent duplicate execution?

The Gateway keeps durable replay state for paid requests. State-changing merchant operations should also accept a stable idempotency key so a retry can return the first result.

Can Agent Commerce Gateway be self-hosted?

Yes. The Gateway can run in the merchant's environment. DEVLAB can also operate a managed deployment.