---
title: With Pay.sh
description: Accept payments with Pay.sh.
---

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

```bash
brew install pay
```

or

```bash
npm install -g @solana/pay
```

Verify the installation with:

```bash
pay --version
```

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

```bash
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:

```bash
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:

```yaml
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:

```bash
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](https://pay.sh/docs/building-with-pay/pricing)

Learn more about setting up Pay.sh in production in the
[Pay.sh Configuration docs](https://pay.sh/docs/toolchain/configuration).
