Skip to content

docs(x402): note v2 Payment-Signature header + payment-on-failure caveats#1103

Open
PaulieB14 wants to merge 2 commits into
graphprotocol:mainfrom
PaulieB14:docs/x402-v2-header-and-allocations-caveat
Open

docs(x402): note v2 Payment-Signature header + payment-on-failure caveats#1103
PaulieB14 wants to merge 2 commits into
graphprotocol:mainfrom
PaulieB14:docs/x402-v2-header-and-allocations-caveat

Conversation

@PaulieB14
Copy link
Copy Markdown

Summary

Two real footguns hitting agent integrators of the /api/x402/... endpoints that aren't covered in the current guide:

1. Protocol version (v2 header)

The gateway implements x402 v2 — payments must be sent in a Payment-Signature header, not v1's X-PAYMENT. Verified live against gateway.thegraph.com/api/x402/subgraphs/id/5zvR82QoaXYFyDEKLZ9t6v9adgnptxYpKpSbxtgVENFV:

  • X-PAYMENT: <base64>402 Payment-Signature header is required
  • Payment-Signature: <base64>200 OK with data

The current line "Any x402 tooling that supports exact scheme will work with the gateway's x402 endpoints" is misleading for v1 SDKs, which sign correctly but still get 402'd. The added callout under How It Works points v1 users at @graphprotocol/client-x402 or a v2-aware upgrade.

2. Payment-on-failure cases

USDC settles even when the gateway returns no usable data:

  • Zero active allocations. Valid subgraph_id whose deployment has no indexer allocations returns {"errors":[{"message":"subgraph not found: no allocations"}]} with payment settled.
  • GraphQL errors. Any response with errors (bad query shape, schema mismatch, etc.) is also settled.

Added a ## Caveats section so agent integrators know to pre-check active allocations against the Graph Network Subgraph, and to validate query shape against get_schema_by_subgraph_id before paying. Both can be done cheaply / for free and avoid burning real USDC.

Test plan

  • Live-tested Payment-Signature against four deployments (Uniswap V3 on ETH/Polygon/Arbitrum/Base) — all returned 200 + data after settlement; one returned errors after settlement (different schema variant), confirming the "errors still cost" point.
  • Reproduced "no allocations" against QmWFi6uciaQPQmo1xRrahNwfiWLGeN9GTDJMuCfV8iVXSe (Substreams Uniswap v3 Ethereum) — valid registry ID, no active indexers, $0.01 settled with no data.
  • Reviewer to confirm wording matches Graph docs style.

Two costly footguns for new x402 integrators that aren't covered today:

1. Protocol version. The gateway is x402 v2, so payments must be sent in
   `Payment-Signature` (not v1's `X-PAYMENT`). v1 SDKs that sign correctly
   still receive 402 "Payment-Signature header is required". The current
   "any x402 tooling that supports exact scheme will work" line implies
   v1 compatibility — adding an explicit callout pointing v1 users at
   `@graphprotocol/client-x402` (or a v2-aware upgrade).

2. Payment-on-failure. Two real cases where USDC is charged but the caller
   gets no usable data:
   - Valid subgraph_id with zero active indexer allocations → returns
     `{"errors":[{"message":"subgraph not found: no allocations"}]}` with
     payment settled.
   - Any errors-shaped GraphQL response (bad shape, schema mismatch, etc.)
     is still settled.

   Both surprise first-time agent integrators. Added a `## Caveats` section
   with a Graph Network Subgraph query agents can use to pre-check active
   allocations before paying.
@PaulieB14 PaulieB14 requested a review from a team as a code owner May 16, 2026 02:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant