t2000: Pay for x402 API Service
Status
✅ Active — requires t2000 CLI with @t2000/x402 installed.
Purpose
Make a paid HTTP request to any x402-protected endpoint. Handles the 402 handshake, signs the USDC payment from the available balance, and returns the API response.
Command
t2000 pay <url> [options]
Examples:
t2000 pay https://api.example.com/data t2000 pay https://api.example.com/analyze --method POST --data '{"text":"hello"}' t2000 pay https://api.example.com/premium --max-price 0.10 t2000 pay https://api.example.com/data --dry-run t2000 pay https://api.example.com/data --header 'X-Custom=value' --timeout 60
Options
Option Description Default
--method <method>
HTTP method (GET, POST, PUT) GET
--data <json>
Request body for POST/PUT —
--max-price <amount>
Max USDC per request $1.00
--header <key=value>
Additional HTTP header (repeatable) —
--timeout <seconds>
Request timeout in seconds 30
--dry-run
Show what would be paid without paying —
Flow (automatic)
-
Makes initial HTTP request to the URL
-
If 402: reads PAYMENT-REQUIRED header for amount and terms
-
If price ≤ --max-price: signs and broadcasts USDC payment on Sui
-
Retries with X-PAYMENT proof header
-
Returns the API response body
Safety
-
If requested price exceeds --max-price, payment is refused (no funds spent)
-
Default max-price: $1.00 USDC per request
-
Payment only broadcast after 402 terms are validated
Errors
-
PRICE_EXCEEDS_LIMIT : API asking more than --max-price
-
INSUFFICIENT_BALANCE : not enough available USDC
-
UNSUPPORTED_NETWORK : 402 requires a network other than Sui
-
PAYMENT_EXPIRED : payment challenge has expired
-
DUPLICATE_PAYMENT : nonce already used on-chain