How requests work
What happens to a request between the client, AgentPay, and your backend.
Request lifecycle
- The client calls an AgentPay URL for a specific protocol, project, and endpoint.
- AgentPay loads your project configuration and checks that the endpoint is enabled.
- If the request has no payment, AgentPay returns HTTP 402 with instructions for paying.
- If the request includes payment, AgentPay verifies it against the channel configuration.
- AgentPay forwards the method, path, query string, body, and allowed headers to your backend.
- Your backend response is returned to the client along with a payment receipt.
When clients are charged
For x402 and MPP payments, AgentPay collects the payment before the request reaches your backend. If payment fails, your backend is never called.
With batch settlement, the order is reversed: the client is charged only after your backend responds successfully.
What your backend sees
Your backend stays focused on product logic
It receives a normal HTTP request after payment succeeds. You can keep your existing authentication, rate limiting, and business logic in place.