PayWeavePayWeaveBack to Home
Introduction

Quickstart

Get your first paid API endpoint live in under 5 minutes.

Prerequisites

Node.js 20+ installed on your machine.

A PayWeave account at app.payweave.app. A workspace is created automatically when you sign up, with wallets provisioned for both test and live modes.

1. Create an app

Go to Apps → Create App in the dashboard. You'll receive:

appId - Your public key identifier (e.g. app_cm5abc123def456), safe to include in code.

appSecret - Your secret key (e.g. sk_test_a1b2c3...). Save it immediately - it won't be shown again.

2. Install the SDK

Pick the middleware for your framework:

Terminal
npm install @payweave/hono    # or express, next, fastify

3. Add payment middleware

TypeScript
import { Hono } from 'hono';
import { Payweave } from '@payweave/hono';

const app = new Hono();
const payweave = new Payweave(
  process.env.PAYWEAVE_APP_ID!,
  process.env.PAYWEAVE_APP_SECRET!
);

// This endpoint costs $0.001 per request
app.get(
  '/api/weather',
  payweave.charge({ price: '0.001', description: 'Weather API' }),
  (c) => c.json({ temp: 72, unit: 'F' })
);

export default app;

4. Try it

Make a request without payment - you'll get a 402 Payment Required response with pricing information:

Terminal
curl http://localhost:3000/api/weather
JSON
{
  "type": "https://payweave.app/errors/payment-required",
  "title": "Payment Required",
  "status": 402,
  "detail": "This endpoint requires payment of $0.001 USD via MPP.",
  "instance": "/api/weather"
}

The response includes a WWW-Authenticate header with MPP payment instructions. Any MPP-compatible agent reads this, pays via Tempo, and retries with an Authorization: Payment ... header to get the response.

5. Use the Playground

Use the Playground in the dashboard to send a test request. You'll see the full 402 → payment → 200 flow in action without writing any client code.

Use test mode while developing. Test mode uses separate wallets with test tokens and doesn't settle real payments. Your secret key prefix (sk_test_ vs sk_live_) determines the mode automatically.