Pay for Service
Make paid requests to x402-enabled APIs using USDC
Pay for Service
Call x402-enabled API endpoints with automatic USDC payment on Base.
Command
Options
| Option | Description |
|---|---|
<url> | Full URL of the x402-enabled API endpoint |
-X, --method <method> | HTTP method (default: GET) |
-d, --data <json> | Request body as JSON string |
-q, --query <params> | Query parameters as JSON string |
-h, --headers <json> | Custom HTTP headers as JSON string |
--max-amount <amount> | Max payment in USDC atomic units (1000000 = $1.00) |
--correlation-id <id> | Group related operations |
--json | Output as JSON |
USDC Atomic Units
X402 uses USDC atomic units (6 decimals):
| Atomic Units | USD |
|---|---|
| 1000000 | $1.00 |
| 100000 | $0.10 |
| 50000 | $0.05 |
| 10000 | $0.01 |
Recommended Workflow
-
Check requirements first (optional but recommended):
-
Verify balance:
-
Make the paid request:
Examples
Prerequisites
- Must be authenticated (
npx agnic@latest statusto check; use--token,AGNIC_TOKEN, or browser login) - Wallet must have sufficient USDC balance on Base
Error Handling
| Error | Solution |
|---|---|
| "Not authenticated" | Provide --token, set AGNIC_TOKEN, or run npx agnic@latest auth login |
| "Insufficient balance" | Fund wallet with USDC (npx agnic@latest balance to check) |
| "No X402 payment requirements found" | URL may not be an x402 endpoint |
Invalid JSON in --data | Ensure the body is valid JSON before passing |
| HTTP 4xx/5xx from the API | Check the status code and response body |