Skip to main content

Buy

One-command checkout. The x402 payment amount equals the product's total price including tax and shipping. No transaction signing needed — x402 handles the entire payment flow.

If the product is unavailable, you'll receive a 400 error. No payment is charged.

Cost: Product price (dynamic — determined per request)

Endpoint

POST /x402/buy

Request Body

FieldTypeRequiredDescription
asinstringNoAmazon ASIN (use this OR productUrl)
productUrlstringNoAmazon or Shopify product URL
emailstringYesEmail for order confirmation
shippingAddressobjectYesShipping address
variantIdstringNoRequired for Shopify products

Shipping Address

FieldTypeRequired
namestringYes
line1stringYes
line2stringNo
citystringYes
statestringYes
postalCodestringYes
countrystringYes (ISO 3166-1 alpha-2)

Example

All requests require x402 payment. Use fetchWithPay from the Quick Start:

const res = await fetchWithPay("https://api.purch.xyz/x402/buy", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
asin: "B0CXYZ1234",
email: "buyer@example.com",
shippingAddress: {
name: "John Doe",
line1: "123 Main St",
city: "San Francisco",
state: "CA",
postalCode: "94102",
country: "US",
},
}),
});
const data = await res.json();

Response

{
"orderId": "550e8400-e29b-41d4-a716-446655440000",
"status": "processing",
"product": {
"title": "Nike Pegasus 41",
"price": { "amount": "129.99", "currency": "USD" }
},
"totalPrice": { "amount": "136.49", "currency": "usdc" }
}