x402 pay-per-query

x402 Pay-Per-Query API for Agent Payment Decisions

A small, machine-readable paid response for agents that need a fresh point-in-time preflight and evidence receipt before routing money to another x402 service. Run the free verifier and can-pay check first; pay only when this live receipt is useful to the workflow.

Rehearse free in the sandbox Read the wallet-enabled client guide Run free preflight first
Endpoint/api/agent/pay/v2
Price0.002 USDC
Settlementx402 on Base

API Contract

MethodPOST
AuthPAYMENT-SIGNATURE or X-Payment x402 header
ChallengeWithout payment, the endpoint returns HTTP 402 with PAYMENT-REQUIRED.
Price2000 atomic USDC on Base.
Discovery/api/agent/pay/v2 uses x402 v2 CAIP-2 metadata and a Bazaar discovery extension. The legacy /api/agent/pay route remains available for v1 clients.

What the small payment adds

The free verifier and /api/agent/can-pay remain the default path. The paid v2 response performs a fresh live preflight after settlement, then binds the policy decision, current report, query ID, and bounded evidence receipt to that payment.

It does not guarantee endpoint safety, service quality, settlement success, or future behavior. Do not pay when the free evidence already answers the task.

Request

curl -i -X POST https://ontarioprotocol.com/api/agent/pay/v2 \
  -H "Content-Type: application/json" \
  -H "PAYMENT-SIGNATURE: <base64 x402 payment payload>" \
  -d '{
    "query": "Should my agent pay this endpoint?",
    "endpoint": "https://seller.example/api/task",
    "max_usdc": "0.05",
    "agent_policy": "strict"
  }'

Response

{
  "schema": "ontario.agent_pay_query.v1",
  "query_id": "aq_...",
      "answer": "Ontario payment policy returned deny for https://seller.example/api/task.",
      "evidence_receipt": {
        "schema": "ontario.agent_evidence_receipt.v1",
        "receipt_id": "aer_...",
        "digest": "sha256...",
        "evidence": {"report": {"report_id": "vrf_...", "integrity_ok": true}}
      },
      "data": {
    "decision": {"decision": "deny", "reason": "no_verification_report"},
    "can_pay_api": "https://ontarioprotocol.com/api/agent/can-pay"
  },
  "payment": {"txHash": "0x...", "amount_atomic": 2000}
}

Safe Rollout

Start with /sandbox/demo, then verify the 402 contract with python3 scripts/smoke_matrix.py --quiet and settlement accounting with python3 scripts/check_settle.py --quiet.