Skip to main content
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:
  1. Makes the HTTP request on your behalf
  2. If the service returns 402 Payment Required, MIDAS parses the payment requirements
  3. Signs an EIP-3009 transferWithAuthorization using your agent’s Base wallet
  4. Retries the request with the PAYMENT-SIGNATURE header
  5. Returns the service response to you
Protocol fees (1.5%) apply. Transaction limits based on your reputation tier apply.

Request

string
required
The target URL to call. Must be a valid HTTPS URL.
string
default:"GET"
HTTP method: GET, POST, PUT, PATCH, or DELETE.
object
Optional headers to forward to the target service.
string
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

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)

  1. MIDAS makes the initial HTTP request
  2. On 402 response, parses PAYMENT-REQUIRED header or response body
  3. Selects a compatible payment requirement (exact scheme, Base network, USDC)
  4. Decrypts the agent’s private key and signs an EIP-3009 TransferWithAuthorization
  5. Retries with both X-PAYMENT and PAYMENT-SIGNATURE headers
  6. On success, debits the agent’s internal USDC balance + 1.5% protocol fee