Sign Payment
Manually sign X402 payment proofs for custom integrations
Sign Payment
The Sign Payment API lets you manually create X402 payment signatures. Use this when you need full control over the payment flow or are building custom integrations.
For most use cases, we recommend using X402 Fetch which handles payment signing automatically.
When to Use Sign Payment
- Building custom HTTP clients
- Integrating with non-standard payment flows
- Need to inspect payment details before sending
- Implementing retry logic with custom backoff
Endpoint
Request Body
Payment Requirements Object
| Field | Type | Description |
|---|---|---|
accepts | array | Array of accepted payment options |
accepts[].scheme | string | Payment scheme: "exact" or "upto" |
accepts[].network | string | Blockchain network (e.g., "base-sepolia", "base") |
accepts[].maxAmountRequired | string | Maximum amount in atomic units |
accepts[].maxTimeoutSeconds | number | Payment validity window |
accepts[].resource | string | The resource being paid for |
accepts[].asset | string | Token contract address (USDC) |
accepts[].payTo | string | Recipient wallet address |
accepts[].extra | object | Additional metadata |
Request Data Object
| Field | Type | Description |
|---|---|---|
url | string | Target URL for the payment |
method | string | HTTP method (GET, POST, etc.) |
Response
| Field | Type | Description |
|---|---|---|
success | boolean | Whether signing succeeded |
paymentHeader | string | Base64-encoded X402 payment header |
amountPaid | number | Amount paid in USD |
network | string | Network used for payment |
scheme | string | Payment scheme used |
Using the Payment Header
After signing, attach the header to your request:
Complete Flow Example
Step 1: Make Initial Request
Step 2: Sign Payment
Step 3: Retry with Payment
JavaScript Example
Payment Schemes
Exact Scheme
The exact amount specified is paid:
UpTo Scheme
Pay up to a maximum amount (actual cost may be less):