Skip to Content
px402Devnet
How it works

Gateway and retries

What reaches a provider API, and what happens when it fails after payment.

What reaches your API

The request path is appended to your upstream’s base path: /weather/paris becomes https://api.acme.example/v1/weather/paris.

ForwardedNever forwarded
Path, query and bodyThe agent’s IP address and forwarding headers
content-type, accept, user-agent, and other non-reserved x- headersAuthorization and cookies
X-Px402-Proxy-SecretPAYMENT-SIGNATURE
X-Px402-Payment-Id, X-Px402-Route-Id, X-Px402-AttemptThe payer’s wallet address

On the way back, Location and Set-Cookie never reach the agent.

Your side of the contract

  • Refuse any request without the right X-Px402-Proxy-Secret. Otherwise anyone who finds your API can call it for free.
  • Dedupe on X-Px402-Payment-Id. Delivery is at least once. The earning is counted exactly once.
  • Send the first byte within 10 s and finish within 30 s, in at most 5 MiB.
  • Do not redirect. A redirect is a failed attempt.

The gateway only forwards to your admin-approved upstream: HTTPS on port 443, on your verified domain, resolving to a public address.

When your API fails after payment

The money has already moved, so the payment stays bound to its nonce and the agent retries with the same payment.

Upstream failure and retry
  1. 01
    Agent → px402 gatewayThe first verified claim binds the payment and opens a 300 s retry window.
  2. 02
    px402 gateway → Provider APIThe gateway takes a 45 s lease and forwards the call.
  3. 03
    Provider API → px402 gatewayA 5xx, a redirect, 401, 407, 408, 425, 429, a timeout or a network error.
  4. 04
    px402 gateway → AgentThe answer carries retry.until, the attempt number and the maximum of 5.
  5. 05
    Agent → px402 gatewayThe SDK resends the same PAYMENT-SIGNATURE. It does not pay again.
  6. 06
    px402 gateway → Provider APIA new attempt under a new lease.
  7. 07
    Provider API → px402 gatewayThe provider answers.
  8. 08
    px402 gateway → AgentServed, and the earning is counted once, for the attempt that held the live lease.
SituationAnswer
Another attempt is running409 CLAIM_IN_PROGRESS; retry
The upstream failed503 UPSTREAM_FAILED; retry until retry.until
5 attempts failed, or the window closed409 CLAIM_LAPSED. This is a refund case

Providers list refund cases with px402 provider refunds --provider <providerId>. Refunds are manual today.