Documentation Index
Fetch the complete documentation index at: https://docs.midasprotocol.org/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The x402 endpoint lets your agent pay any external service that supports the x402 protocol (HTTP 402 Payment Required). MIDAS acts as a proxy:
- Makes the HTTP request on your behalf
- If the service returns
402 Payment Required, MIDAS parses the payment requirements
- Signs an EIP-3009
transferWithAuthorization using your agent’s Base wallet
- Retries the request with the
PAYMENT-SIGNATURE header
- Returns the service response to you
Protocol fees (1.5%) apply. Transaction limits based on your reputation tier apply.
Request
The target URL to call. Must be a valid HTTPS URL.
HTTP method: GET, POST, PUT, PATCH, or DELETE.
Optional headers to forward to the target service.
Request body for POST/PUT/PATCH requests. Max 50KB.
Example
curl -X POST https://api.midasprotocol.org/x402/pay \
-H "Authorization: Bearer pp_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"url": "https://api.example.com/premium-data",
"method": "GET"
}'
Response (no payment needed)
If the target service does not require payment, the response is proxied directly:
{
"success": true,
"statusCode": 200,
"headers": { "content-type": "application/json" },
"body": "{\"data\": \"...\"}"
}
Response (payment settled)
If the service returned 402 and MIDAS paid successfully:
{
"success": true,
"statusCode": 200,
"headers": { "content-type": "application/json" },
"body": "{\"data\": \"premium content\"}",
"payment": {
"amount": "0.01",
"asset": "USDC",
"network": "eip155:8453",
"payTo": "0x...",
"protocolFee": "0.00015"
}
}
Response (payment failed)
{
"success": false,
"statusCode": 402,
"headers": {},
"body": "[...]",
"error": "No compatible payment requirement found. MIDAS supports exact scheme on Base (eip155:8453) with USDC."
}
Supported Payment Schemes
| Scheme | Network | Asset | Status |
|---|
exact (EIP-3009) | Base (eip155:8453) | USDC | Supported |
Prerequisites
- Your agent must have a blockchain wallet (automatically created at registration)
- Sufficient USDC balance in your internal wallet
- Transaction must be within your reputation tier limit
How It Works (Technical)
- MIDAS makes the initial HTTP request
- On 402 response, parses
PAYMENT-REQUIRED header or response body
- Selects a compatible payment requirement (exact scheme, Base network, USDC)
- Decrypts the agent’s private key and signs an EIP-3009
TransferWithAuthorization
- Retries with both
X-PAYMENT and PAYMENT-SIGNATURE headers
- On success, debits the agent’s internal USDC balance + 1.5% protocol fee