Overview
The /open endpoint is the production gateway for processing payments through OpenX402. Use this endpoint for live transactions that cost $1 USDC.
Endpoint
POST https://open.x402.host/open
Cost
$1 USDC per transaction on Base network.
When to Use
- Production applications with real users
- Live services that require payment verification
- After testing with
/test endpoint
Use /test for development. Only use /open for production traffic to avoid unnecessary costs.
Request
| Header | Value | Required |
Content-Type | application/json | Yes |
X-402-Payment | Payment proof/authorization | Yes |
Body Parameters
| Parameter | Type | Description | Required |
network | string | Blockchain network (e.g., “base”) | Yes |
txHash | string | Transaction hash | Yes |
amount | number | Payment amount in USDC | Yes |
recipient | string | Payment recipient address | Yes |
Example Request
const response = await fetch('https://open.x402.host/open', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-402-Payment': paymentAuthorization
},
body: JSON.stringify({
network: 'base',
txHash: '0x...',
amount: 1.00,
recipient: '0x...'
})
});
Response
Success Response
{
"success": true,
"transactionId": "tx_abc123",
"network": "base",
"amount": "1.00",
"status": "confirmed"
}
Error Response
{
"success": false,
"error": "Insufficient payment",
"required": "1.00 USDC",
"provided": "0.50 USDC"
}
Status Codes
| Code | Meaning |
200 | Payment successful |
400 | Invalid request parameters |
402 | Payment required or insufficient |
500 | Server error |
Complete Example
async function processProductionPayment(txHash, amount) {
try {
const response = await fetch('https://open.x402.host/open', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
network: 'base',
txHash: txHash,
amount: amount,
recipient: process.env.RECIPIENT_ADDRESS
})
});
if (!response.ok) {
throw new Error(`Payment failed: ${response.status}`);
}
const data = await response.json();
console.log('Payment successful:', data.transactionId);
return data;
} catch (error) {
console.error('Payment processing error:', error);
throw error;
}
}
Best Practices
- Validate before calling - Check payment amount client-side
- Handle errors gracefully - Provide clear feedback to users
- Log transactions - Keep records of all payment attempts
- Use timeouts - Don’t let requests hang indefinitely
- Verify settlement - Call
/verify after /open for confirmation
Rate Limiting
- 100 requests per minute per IP address
- Exceeding limits returns
429 Too Many Requests