With Pay.sh

You can accept payments on API requests via Pay.sh by setting up a Pay server. Install Pay with:

brew install pay

or

npm install -g @solana/pay

Verify the installation with:

pay --version

The toolchain will set up your address for you. Run the following to setup and topup your wallet:

pay setup

Setting up the demo server

You can start accepting payments by starting your server. You can see a demo server in action with:

pay server demo

This does two things. It starts a live Pay server which you can query via HTTP request, and it generates a pay-demo.yml file in your current directory.

All API routes are configured via the endpoints YAML config. In order to accept payments, you have to add a metering: attribute. The /api/v1/reports/usage route has been done as an example for you:

endpoints:
- method: GET
path: "api/v1/reports/usage"
resource: "reports"
description: "Usage report — flat fee, no splits."
metering:
dimensions:
- direction: usage
unit: requests
scale: 1
tiers:
- price_usd: 0.01

You can test that the payments work by running the following command as a client on another terminal:

pay --sandbox curl http://127.0.0.1:1402/api/v1/reports/usage

You can learn more about how to define pricing in the Pay.sh Building with Pay > Pricing docs

Learn more about setting up Pay.sh in production in the Pay.sh Configuration docs.

Is this page helpful?

Table of Contents

Edit Page
© 2026 Solana Foundation. All rights reserved.