Skip to main content
Enable agents to pay for APIs and content using MPP, an open protocol for machine-to-machine payments over HTTP. Privy’s server wallets provide the signing layer, while the mppx SDK handles the 402 payment flow automatically.

What is MPP?

MPP (Machine Payments Protocol) is an open protocol for machine-to-machine payments over HTTP. When a resource requires payment, the server responds with 402 Payment Required and payment details. The client signs a payment credential using the agent’s wallet and retries the request. Settlement happens on the Tempo blockchain using PathUSD.

Installation

  • @privy-io/node provides server-side wallet creation and signing
  • mppx provides the MPP client that handles 402 payment flows
  • viem provides the account interface used by Privy’s viem helper and mppx

Creating a Privy-backed account

MPP’s tempo.charge() payment method expects a viem Account for signing. Use Privy’s createViemAccount helper to create a viem account backed by a Privy wallet.
Use @privy-io/node v0.20.0 or later. Earlier versions required custom Tempo transaction serialization logic.

Making MPP payments

Pass the Privy-backed account to the MPP client’s tempo.charge() method. The client automatically handles 402 responses, signs payment credentials, and retries requests.

Using mppx.fetch

mppx.fetch is a drop-in replacement for fetch. When a server returns 402 Payment Required, the client reads the payment requirements, signs a credential with the Privy wallet, and retries the request automatically. Use tempo({account}) instead when the client should support both one-time charges and Tempo sessions.

Using polyfill mode

Your app can also polyfill the global fetch so all HTTP requests handle 402 challenges automatically:

How it works

  1. Agent requests content: Your app calls mppx.fetch() or the polyfilled fetch()
  2. Server responds 402: Returns payment requirements (amount, currency, recipient)
  3. MPP client signs credential: Uses the Privy-backed account to sign a payment credential
  4. Retry with credential: Request repeats with the signed credential attached
  5. Server verifies and settles: Verifies the credential and settles payment on Tempo
  6. Server delivers: Returns content with 200 OK

Creating an MPP-enabled service

The mppx/nextjs package provides middleware for adding payment requirements to API routes:
When a client calls this route without a payment credential, the middleware responds with 402 Payment Required. With a valid credential, it verifies the payment, settles on Tempo, and returns the data.

Full example

Learn more