Skip to content

Receiver API

Reference for x402-paysdk/receive PaymentRef creation, lookup, listing, revocation, validation, and return types.

TypeScript
import { createPaymentRef } from 'x402-paysdk/receive';

The receiver entry point manages payment references. It does not sign payer payments, hold merchant order state, or verify fulfillment.

Functions

FunctionSignatureGateway route
createPaymentRef(options: CreatePaymentRefOptions) => Promise<PaymentRef>POST /ref
getRef(gateway: string, refId: string) => Promise<PaymentRefSnapshot>GET /ref/:refId
listPaymentRefs(options: ListPaymentRefsOptions) => Promise<PaymentRefList>GET /ref
revokePaymentRef(options: RevokePaymentRefOptions) => Promise<RevokedPaymentRef>POST /ref/:refId/revoke
revokePayTo(options: RevokePayToOptions) => Promise<RevokedPayTo>POST /payto/:payTo/revoke

Create options

TypeScript
interface CreatePaymentRefOptions { gateway: string; payTo: string; network: string; asset?: 'USDC'; amount?: string; invoiceId?: string; notifyUrl?: string; label?: string; description?: string; expiresInSecs?: number; apiKey?: string;}
FieldValidation
gatewayCanonical HTTPS origin or local development origin
payToEVM address
networkSupported network name
assetCurrently USDC only
amountPositive atomic decimal string; omit for open amount
invoiceIdBounded public id and requires fixed amount
notifyUrlPublic HTTPS URL on port 443; requires apiKey in this low-level API
labelAt most 120 UTF-8 bytes
descriptionAt most 512 UTF-8 bytes
expiresInSecsPositive safe integer
apiKeyBearer credential when the gateway requires merchant auth

Return model

TypeScript
interface PaymentRef { refId: string; refUrl: string; snapshot: { v: 2; scheme: 'exact'; network: string; payTo: string; asset: 'USDC'; amount?: string; resource: string; invoiceId?: string; description?: string; mimeType: string; expiresAt?: number; };}

Persist the immutable snapshot with the business record. It is the expected payment context used for receipt matching and incident analysis.

Listing

listPaymentRefs requires gateway, payTo, and apiKey. limit is a positive safe integer and cursor must be the exact opaque value returned by the gateway.

Each item contains ref id, payTo, network, asset, optional amount/invoice/label, creation and expiry times, and active | revoked status.

Revocation behavior

Revoking a ref prevents future authorization through that ref. Retiring a payTo prevents future use according to gateway policy. Neither operation reverses an already mined transfer; verify historical settlement from chain state and archived receipts.