Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.httpayer.com/llms.txt

Use this file to discover all available pages before exploring further.

Request Lifecycle Overview

Every HTTPayer request progresses through a defined lifecycle, especially when payments or refunds are involved. The lifecycle is divided into five phases:
  1. Discovery
  2. Payment Processing
  3. Upstream Execution
  4. Completion
  5. Refund Handling (if applicable)

Status Reference

HTTPayer uses two layers of status values. See the Status System reference for a full explanation of the mapping between them.

Sync-Response Statuses

These appear in the X-HTTPayer-Status response header and httpayerStatus field on synchronous responses. They are not stored in the webhooks database.
StatusDescription
payment_requiredClient must submit a valid x402 payment (402)
payment_validatingOn-chain confirmation in progress
processingUpstream API call in flight

Async / Webhook Statuses

These are stored in the database and returned by GET /webhooks/:id. An initial async_processing record is created when background polling is launched (e.g., after a proxy 502 with webhook_id); it transitions to one of the terminal states below.

In-Flight

StatusWebhook responseDescription
async_processingpendingBackground polling active; monitoring payment on-chain

Terminal — Success

StatusWebhook responseDescription
successsuccessRequest completed, upstream responded 2xx
success_refundedsuccess_refundedRequest succeeded; refund issued (target did not charge)
refund_confirmedrefund_confirmedRefund transaction confirmed on-chain
no_refund_neededno_refund_neededTarget charged HTTPayer within the auth window — refund skipped

Terminal — Failure

StatusWebhook responseDescription
payment_failedfailedUser payment never settled on-chain
upstream_errorfailedTarget API returned a 5xx error
internal_errorfailedHTTPayer-side error
rate_limitedfailedAccount daily_limit exceeded
validation_failedfailedInvalid request parameters
refund_failedfailedRefund attempt failed (manual intervention needed)

Upstream Execution

Proxy: upstream payment refused (502)

When the target API returns 402 after all sync retries, HTTPayer returns 502 Bad Gateway with message: "Upstream API refused payment after N attempts". If blockchain polling is active, a webhook_id field is included in the response body — use GET /webhooks/:id to track whether the payment eventually confirmed on-chain. If confirmed, credits are charged; if not, reserved credits are automatically refunded.

SSRF protection (400)

The api_url field is validated before any outbound request is made. Requests targeting private, loopback, or link-local addresses are rejected with 400 Bad Request. Blocked ranges include:
  • Loopback: 127.0.0.0/8, ::1
  • Link-local / cloud metadata: 169.254.0.0/16
  • Private: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16
  • Unspecified: 0.0.0.0, ::
Non-http/https schemes (e.g. file://, ftp://) are also rejected.

Refund deduplication

If a refund has already been issued for a relay transaction (status confirmed or pending), any subsequent refund attempt for the same transaction is a no-op — the original refund hash is returned immediately without executing a new blockchain transaction. This prevents double-refunds from retries or concurrent error paths.

Where Statuses Appear

SurfaceStatus typeField / Header
Synchronous 2xx/4xx/5xx responseSync-response statusX-HTTPayer-Status header
Synchronous JSON response bodySync-response statushttpayerStatus field
GET /webhooks/:id (202)pendingstatus field
GET /webhooks/:id (200)success variantstatus field
GET /webhooks/:id (500)failedstatus field
For async flows and refunds, see the Webhooks documentation.