Route and Pay a Request
Hand the Router the request you want made to an upstream x402 agent; it probes, pays any 402
with your Delegation (same engine as POST /router/payments), and relays the agent’s response in ONE
call — you never see the 402 or handle the credential yourself.
Prerequisite: a Delegation id (POST /api/v1/delegation/create, provider erc4337).
Provide the target url (+ optional method, headers, body). A free (non-402) upstream is
relayed unchanged with paid=false and no payment. requestId is REQUIRED (the Router pays automatically, so a retry must be idempotency-keyed); a duplicate returns 409 with the original paymentId.
For LARGE or STREAMED responses, a transparent streaming variant exists at ALL /api/v1/router/proxy:
point your HTTP client at it with headers X-Router-Target-Url and X-Router-Delegation-Id
(optional X-Router-Upstream-Authorization for the agent’s own auth). Method/body/headers pass
through and the response streams back, with payment metadata in X-Router-Payment-Id,
X-Router-Payment-Status, and X-Router-Tx-Hash response headers. Use this JSON endpoint when
you want a single structured result instead.
Authorizations
Your Nevermined API Key (starts with 'nvm:'). Get one at nevermined.app under Settings > API Keys.
Body
The caller's erc4337 delegation to spend against (as in POST /router/payments).
Absolute upstream URL to route to (http/https only).
"https://agent.example/api/resource"
Idempotency key — REQUIRED for routed payments (mode B). The Router makes the upstream call and pays automatically, so a retry after a dropped connection must not double-spend. At most one payment is minted per (caller, requestId); a duplicate returns 409 (BCK.ROUTER.0002) carrying the original paymentId, rather than paying again.
"order-1234"
HTTP method to use for the upstream request.
GET, POST, PUT, PATCH, DELETE Headers to forward to the upstream (e.g. the agent’s own auth). Optional.
Request body to forward (JSON). Optional.
Payment protocol. On the mode-B proxy (/route, /proxy) this is ADVISORY: the Router AUTO-DETECTS the protocol from the upstream 402 — WWW-Authenticate: Payment → mpp; accepts / PAYMENT-REQUIRED → x402 — and the DETECTED protocol is authoritative for the mint (a mismatching hint here does not change what gets paid).
x402, mpp Response
The relayed upstream response (status + body) plus the payment that was made.
The upstream HTTP status code that was relayed.
200
The upstream response body (parsed JSON when the upstream returned JSON, else a string).
Whether a payment was made (false = the upstream was free).
true
The payment made, when paid is true.
Related topics
Fiat PaymentsHow the Router worksNevermined Router OverviewRouter quickstartNevermined x402