Docs · x402
HTTP 402 for the agent era.
Hvisk implements the x402 protocol so any HTTP server can charge a fraction of a cent for a single request. Agents pay invisibly, privately, and faster than a payment gateway round-trip.
The lifecycle.
- An agent requests a paid resource.
- The server responds with HTTP 402 and an invoice header.
- The agent checks its policy, signs a payment, and submits to /api/x402/settle.
- The server verifies the Solana signature and re-runs the original request.
Invoice schema.
type PaymentRequest = {
id: string; // pay_xxxxxxxxxxxxxxxx
amount: number; // 0.05
token: "USDC" | "USDT" | "SOL";
recipient: string; // Solana pubkey
chain: "solana";
privacy: "public" | "partial" | "full";
memo?: string;
expiresAt: number; // ms epoch
meta?: Record<string, string | number | boolean>;
};Worked example.
An agent calling a paid endpoint:
# 1. Hit the resource
curl -i https://api.example.com/score
HTTP/1.1 402 Payment Required
X-Payment-Required: true
X-Payment-ID: pay_5b3a8e7c2d4f1
Content-Type: application/json
{ "amount": 0.05, "token": "USDC", "recipient": "9xQe…", "privacy": "full" }
# 2. Pay
curl -X POST https://hvisk.app/api/x402/settle \
-H 'Content-Type: application/json' \
-d '{
"id": "pay_5b3a8e7c2d4f1",
"signature": "5abc…"
}'
# 3. Re-issue the original request with the receipt
curl -H 'X-Payment-Receipt: 5abc…' https://api.example.com/scoreWhy privacy matters here.
Without shielding, every machine payment is public. Competitors can map your agent fleet's spending patterns, infer which APIs you use, and game pricing. With Hvisk, the payment is settled through the privacy pool. Counterparties see the receipt for the call they served, and nothing else.