> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://docs.postnuvia.com/llms.txt.

# MPP

> PostNuvia's MPP integration for machine-to-machine payments via Stripe

## Getting started

[MPP (Machine Payments Protocol)](https://mpp.dev) is Stripe's open protocol that enables machine-to-machine payments. By integrating MPP with PostNuvia, your agents can pay for API usage directly without managing API keys or subscriptions.

### Base URLs

To authenticate with MPP instead of an API key, you must use the MPP-specific base URLs below. These replace the default PostNuvia base URLs and route requests through the MPP payment layer.

| Protocol  | URL                    |
| --------- | ---------------------- |
| HTTP      | `mpp.api.postnuvia.com` |
| WebSocket | `mpp.ws.postnuvia.com`  |

### Prerequisites

* A crypto wallet with funds (EVM-compatible wallet)
* Node.js installed

### Install dependencies

```bash
npm install postnuvia mppx viem
```

### Quickstart

```typescript
import { privateKeyToAccount } from "viem/accounts";
import { Mppx, tempo } from "mppx/client";

import { PostNuviaClient } from "postnuvia";


// setup MPP client

const PRIVATE_KEY = "0x...";

const account = privateKeyToAccount(PRIVATE_KEY);

export const mppx = Mppx.create({ methods: [tempo({ account })] });


// setup PostNuvia client

export const client = new PostNuviaClient({ mppx });


// create inbox

const inboxRes = await client.inboxes.create({
  username: `mpp-${Date.now()}`,
});
console.log("Created inbox: ", inboxRes.inboxId);


// subscribe to inbox

const socket = await client.websockets.connect();
console.log("Connected to websocket");

socket.on("message", async (event) => {
  if (event.type === "subscribed") {
    console.log("Subscribed to", event.inboxIds);
  } else if (event.type === "event" && event.eventType === "message.received") {
    console.log("Received message from: ", event.message.from);
  }
});

socket.sendSubscribe({
  type: "subscribe",
  inboxIds: [inboxRes.inboxId],
});
```

## How it works

When you pass an `mppx` client to `PostNuviaClient`, the SDK automatically handles payment negotiation for each API request. The MPP client signs payments using your wallet, enabling your agent to pay per request seamlessly.

This means your agent can use the full PostNuvia API (inboxes, messages, threads, attachments) without needing a traditional API key. Payment happens per-request via Stripe's Machine Payments Protocol.

## Resources

* [MPP documentation](https://mpp.dev)
* [PostNuvia API reference](/api-reference)
* [WebSockets overview](/websockets)