x402 Payment Protocol · Base Network · USDC
Base URL: https://urlgate.xyz
Protocol: x402 (HTTP 402 Payment Required)
Network: Base (Ethereum L2, Chain ID: 8453)
Currency: Native USDC (0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913)
Most endpoints are permissionless and use x402 payment proofs for authentication.
When an endpoint requires payment, it returns 402 Payment Required:
{
"error": "Payment Required",
"message": "Payment required to access this resource",
"accepts": [{
"scheme": "exact",
"network": "base",
"asset": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
"payTo": "0x...",
"maxAmountRequired": "1000000",
"resource": "/api/urlgate/create"
}]
}
After paying on-chain, retry with:
Authorization: x402 <transaction-hash>
Create a new short link (for humans via web UI).
| Field | Type | Required | Description |
|---|---|---|---|
url |
string | Yes | Valid HTTP/HTTPS destination URL |
price |
string | Yes | Access price in USDC (0.01 to 1,000,000) |
wallet |
string | Yes | Your Base wallet address (receives payments) |
shortcode |
string | No | Custom shortcode (3-20 chars, auto-generated if omitted) |
{
"success": true,
"shortcode": "abc123",
"shortUrl": "https://urlgate.xyz/abc123",
"destinationUrl": "https://example.com/content",
"price": "0.050000",
"creatorWallet": "0xYourWalletAddress",
"feeBreakdown": {
"serviceFee": "0.000000",
"serviceFeePercentage": 0,
"creatorReceives": "0.050000",
"creatorPercentage": 100
},
"createdAt": "2026-08-05T00:00:00.000Z"
}
Create a new short link (for AI agents and programmatic access).
Same request/response as /api/urlgate/create, plus agentCreated: true in response.
Access a paid link. Also works as /:code (both paths identical).
Authorization: x402 <transaction-hash> // After payment
X-Wallet-Address: 0xYourWallet // Optional, check if already paid
{
"error": "Payment Required",
"accepts": [{
"maxAmountRequired": "50000", // 0.05 USDC in micro-units
"payTo": "0xCreatorWallet"
}]
}
HTTP/1.1 303 See Other
Location: https://example.com/content
{
"destination": "https://example.com/content",
"alreadyPaid": true
}
Get public information about a link without paying.
{
"shortcode": "abc123",
"destinationUrl": "https://example.com/content",
"price": "0.050000",
"totalClicks": 42,
"active": true,
"createdAt": "2026-08-05T00:00:00.000Z"
}
Get all links a wallet has paid to access.
| Parameter | Type | Default | Description |
|---|---|---|---|
limit |
number | 10 | Results per page (max 100) |
offset |
number | 0 | Pagination offset |
search |
string | - | Filter by destination URL |
Get statistics and links created by a wallet.
{
"success": true,
"wallet": "0xCreatorWallet",
"totalLinks": 5,
"totalClicks": 123,
"totalPayments": 42,
"totalEarnings": "2.100000",
"links": [...]
}
// Create a link with payment
async function createPaidLink(url, price, wallet) {
const response = await fetch('https://urlgate.xyz/api/urlgate/create', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ url, price, wallet })
});
if (response.status === 402) {
const payment = await response.json();
const payTo = payment.accepts[0].payTo;
const amount = payment.accepts[0].maxAmountRequired;
// Send USDC payment via MetaMask
const txHash = await sendUSDCPayment(payTo, amount);
// Retry with proof
const retryResponse = await fetch('https://urlgate.xyz/api/urlgate/create', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `x402 ${txHash}`
},
body: JSON.stringify({ url, price, wallet })
});
return await retryResponse.json();
}
return await response.json();
}
import requests
def get_link_info(shortcode):
response = requests.get(
f'https://urlgate.xyz/api/urlgate/{shortcode}/info'
)
return response.json()
def create_link(url, price, wallet, tx_hash=None):
headers = {'Content-Type': 'application/json'}
if tx_hash:
headers['Authorization'] = f'x402 {tx_hash}'
response = requests.post(
'https://urlgate.xyz/api/urlgate/create',
json={'url': url, 'price': price, 'wallet': wallet},
headers=headers
)
if response.status_code == 402:
payment_info = response.json()
print(f"Payment required: {payment_info['accepts'][0]}")
return None
return response.json()
# Get link info
curl https://urlgate.xyz/api/urlgate/abc123/info
# Create link (returns 402 payment required)
curl -X POST https://urlgate.xyz/api/urlgate/create \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com","price":"0.05","wallet":"0x..."}'
# Create link (with payment proof)
curl -X POST https://urlgate.xyz/api/urlgate/create \
-H "Content-Type: application/json" \
-H "Authorization: x402 0xTransactionHash..." \
-d '{"url":"https://example.com","price":"0.05","wallet":"0x..."}'
Creation endpoints: 100 requests per minute per IP
Other endpoints: No limit
Rate limit response: 429 Too Many Requests