MPP API

Monetize your API with micropayments via the Machine Payments Protocol

MPP API Status
Protocol: MPP (Tempo)
Not Configured

Endpoints

MethodPathTypePriceDescription
GET/healthFree-Service health check
GET/api/plansCharge$0.01List all active plans
POST/api/chargeableSession$0.02Filter chargeable subscriptions
GET/api/plans/streamSession$0.005/planStream plan data via SSE

Quick Start

1. Configure environment variables
# .env
MPP_SECRET=your_mpp_secret_key
MPP_BASE_URL=http://localhost:4020
CRON_RPC_URL=https://rpc.base.org
CRON_CONTRACT_ADDRESS=0x...
2. Start the server
npm run start
# Server running on http://localhost:4020
3. Test an endpoint
npx mppx http://localhost:4020/api/plans

CronAgent Integration

Configure your CronAgent with MPP endpoints for automated micropayment collection.

import { CronAgent } from "@cron/sdk";

const agent = new CronAgent({
  rpcUrl: process.env.CRON_RPC_URL,
  contractAddress: process.env.CRON_CONTRACT_ADDRESS,
  mpp: {
    secret: process.env.MPP_SECRET,
    baseUrl: process.env.MPP_BASE_URL,
    endpoints: [
      { path: "/api/plans", type: "charge", price: 0.01 },
      { path: "/api/chargeable", type: "session", price: 0.02 },
      { path: "/api/plans/stream", type: "session", price: 0.005 },
    ],
  },
});

await agent.start();