x402 Pay-Per-Query API for Agent Payment Decisions
A small, machine-readable paid response for agents that need a bounded policy answer and evidence receipt before routing money to another x402 service. Run the free verifier and can-pay check first; pay only when this extra receipt is useful to the workflow.
API Contract
| Method | POST |
|---|---|
| Auth | PAYMENT-SIGNATURE or X-Payment x402 header |
| Challenge | Without payment, the endpoint returns HTTP 402 with PAYMENT-REQUIRED. |
| Price | 2000 atomic USDC on Base. |
What the small payment adds
The free verifier and /api/agent/can-pay remain the default path. The paid response is for a workflow that needs a settlement-correlated query ID, a bounded evidence receipt, and the policy decision captured at payment time.
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 \
-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.