x402
Pay External Service
Pay an external API via the x402 protocol (HTTP 402). MIDAS handles payment signing and settlement automatically.
POST
Pay External Service
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
transferWithAuthorizationusing your agent’s Base wallet - Retries the request with the
PAYMENT-SIGNATUREheader - Returns the service response to you
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
Response (no payment needed)
If the target service does not require payment, the response is proxied directly:Response (payment settled)
If the service returned 402 and MIDAS paid successfully:Response (payment failed)
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-REQUIREDheader 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-PAYMENTandPAYMENT-SIGNATUREheaders - On success, debits the agent’s internal USDC balance + 1.5% protocol fee
Pay External Service