Skip to main content

Machine-payable protocol API

Create and manage ECDSA wallets for agents to make autonomous payments using the x402 machine-payable protocol. Agents can hold USDC balances and make HTTP requests that include automatic payment negotiation.
All MPP endpoints require session authentication. Wallet private keys are stored server-side and cannot be retrieved after creation.

List wallets

GET /api/agent/mpp?action=list-wallets
Returns all registered agent wallets.

Response

{
  "wallets": [
    {
      "agentId": "agent_123",
      "companyId": "company_456",
      "address": "0xabc...123"
    }
  ]
}
FieldTypeDescription
walletsarrayList of registered agent wallets
wallets[].agentIdstringAgent identifier
wallets[].companyIdstringCompany identifier
wallets[].addressstringWallet address (hex format)

Get wallet

GET /api/agent/mpp?action=get-wallet&agentId=agent_123
Returns the wallet address for a specific agent.

Query parameters

ParameterTypeRequiredDescription
actionstringYesMust be get-wallet
agentIdstringYesAgent identifier

Response

{
  "agentId": "agent_123",
  "address": "0xabc...123"
}

Errors

CodeDescription
404Wallet not found for the specified agent

Get balance

GET /api/agent/mpp?action=get-balance&agentId=agent_123
Returns the USDC balance for an agent’s wallet.

Query parameters

ParameterTypeRequiredDescription
actionstringYesMust be get-balance
agentIdstringYesAgent identifier

Response

{
  "agentId": "agent_123",
  "balance": "10.50"
}

Errors

CodeDescription
500Failed to fetch balance (for example, RPC error)

List endpoints

GET /api/agent/mpp
When no action parameter is provided, returns the list of available endpoints.
{
  "endpoints": {
    "GET /api/agent/mpp?action=list-wallets": "List all agent wallets",
    "GET /api/agent/mpp?action=get-wallet&agentId=xxx": "Get wallet for specific agent",
    "GET /api/agent/mpp?action=get-balance&agentId=xxx": "Get USDC balance",
    "POST /api/agent/mpp": "Create or manage wallet"
  }
}

Create wallet

POST /api/agent/mpp
Creates a new ECDSA wallet for an agent. The private key is stored server-side and cannot be retrieved.

Request body

FieldTypeRequiredDescription
actionstringYesMust be create-wallet
agentIdstringYesAgent identifier
companyIdstringYesCompany identifier
{
  "action": "create-wallet",
  "agentId": "agent_123",
  "companyId": "company_456"
}

Response

{
  "success": true,
  "agentId": "agent_123",
  "companyId": "company_456",
  "address": "0xabc...123",
  "message": "Wallet created. Private key stored server-side — it cannot be recovered!"
}

Errors

CodeDescription
400agentId and companyId required

Register wallet

POST /api/agent/mpp
Registers an existing wallet for an agent by providing its private key.

Request body

FieldTypeRequiredDescription
actionstringYesMust be register-wallet
agentIdstringYesAgent identifier
companyIdstringYesCompany identifier
privateKeystringYesWallet private key (hex format)

Response

{
  "success": true,
  "agentId": "agent_123",
  "companyId": "company_456",
  "address": "0xabc...123"
}

Errors

CodeDescription
400agentId, companyId, and privateKey required

Make payment

POST /api/agent/mpp
Makes an HTTP request on behalf of an agent with automatic x402 payment negotiation. When the target URL returns a 402 Payment Required response, the agent’s wallet is used to authorize the payment.

Request body

FieldTypeRequiredDescription
actionstringYesMust be make-payment
agentIdstringYesAgent identifier (must have a registered wallet)
urlstringYesTarget URL to request
methodstringNoHTTP method (default: GET)
headersobjectNoAdditional request headers
bodyobjectNoRequest body (JSON-serialized automatically)
{
  "action": "make-payment",
  "agentId": "agent_123",
  "url": "https://api.example.com/paid-resource",
  "method": "GET"
}

Response

{
  "success": true,
  "result": {}
}
FieldTypeDescription
resultanyThe response from the target URL after payment negotiation

Errors

CodeDescription
400url required
400Invalid action
402Payment failed (for example, insufficient balance or payment negotiation error)
500Internal error

Common errors

CodeDescription
401Unauthorized — session authentication required
500Internal error