# PayOwl Wallet · Merchant API

Accept USDT, USDC, TRX, BNB, POL and SOL with permanent (static) addresses on Tron, BNB Smart Chain, Polygon and Solana. Payments are credited to your PayOwl Wallet balance, and your server is told by webhook. Send money out with the payout API.

**OxaPay-compatible.** Paths, the `merchant_api_key` header, response envelopes and webhooks follow OxaPay's API v1. An OxaPay static-address integration moves over by changing the base URL and the key. Differences from OxaPay are marked **Differs from OxaPay**.

Human-readable version: https://docs.payowl.io

## Basics

- **Base URL:** `https://api.payowl.io/v1`
- **Authentication:** header `merchant_api_key: YOUR_KEY` (payment endpoints; `/general/account/balance` also accepts `general_api_key`). Payouts use a separate header `payout_api_key: YOUR_PAYOUT_KEY`. The `/common/*` endpoints need no key. Each header name also works with dashes instead of underscores (`merchant-api-key`, `payout-api-key`, `general-api-key`): some proxies and servers drop headers with underscores, so use the dashed name if yours gets "No API key". **Differs from OxaPay** (it takes the underscore names only).
- **Getting keys:** open @PayOwlWalletBot in Telegram → the app → ⋮ → Settings → **Merchant** tab → New API key (payments), or the **Payouts** tab → New payout key. Each key is shown once.
- **Several keys:** up to 10 API keys and 10 payout keys, each with its own name (e.g. one per shop, bot or site) and settings: accepted coins, a default callback URL, bot messages on or off, and for payout keys their own limits. Each key sees and manages **only its own** addresses, payments and payouts, and signs their webhooks; the **balance is shared** by all of them. A key's name shows in your Telegram messages (🛍 Merchant API: My Shop). A new key for an existing one (Settings → the key → New key) keeps its name, settings and addresses; a deleted key stops at once, and payments to its addresses are still credited to your balance, without webhooks.
- **Content type:** JSON bodies (`Content-Type: application/json`).
- **Rate limit:** 120 requests a minute per key.
- **Status:** https://status.payowl.io shows whether the API, deposits and withdrawals are working, per network (also as JSON: `/status.json`).
- **Amounts:** JSON numbers in the coin's units (e.g. `20` = 20 USDT). Timestamps are UNIX seconds.

### Response envelope (every endpoint)

```json
{ "data": { }, "message": "Operation completed successfully!", "error": {}, "status": 200, "version": "1.0.0" }
```

### Networks and coins

| `network` value (name) | Also accepted | Coins | Addresses |
|---|---|---|---|
| `Tron Network` | `TRON`, `TRC20`, `TRX` | USDT, TRX | `T…` (34 chars) |
| `Binance Smart Chain` | `BSC`, `BEP20`, `BNB` | USDT, USDC, BNB | `0x…` (40 hex) |
| `Polygon Network` | `POLYGON`, `POL`, `MATIC` | USDT, USDC, POL | `0x…` (40 hex) |
| `Solana Network` | `SOLANA`, `SOL`, `SPL` | USDT, USDC, SOL | base58, 32–44 chars, case-sensitive |

- An address takes every coin of its network.
- Minimum payments (as OxaPay): 0.01 USDT/USDC, 0.03 TRX, 0.00002 BNB, 0.1 POL, 0.0001 SOL. Smaller payments aren't credited (they're listed in `ignored_payments`). Live values: `GET /common/currencies`.
- On Solana, tokens must be sent to the address itself (its standard associated token account), as every Solana wallet does.

### Fees

- **Payments to your static addresses:** 1% of each payment (or the rate agreed with you: yours is shown in the app, ⋮ → Settings → Merchant), plus a fixed **0.46 USDT per payment on Tron USDT** (OxaPay's `static_fixed_fee`). Taken from the amount credited (`received_amount`), never more than the payment. Deposits to your own wallet address are free.
- **Payouts:** the withdrawal fee of the coin and network, on top of the amount (see `/common/currencies`: `withdraw_fee`, `withdraw_min`). To another PayOwl Wallet user's address: free and instant.

## Build it with AI

An AI assistant can write most of the integration for you, as long as it has these docs. They're available as plain Markdown for exactly that:

- **This page as Markdown:** https://docs.payowl.io/docs.md (also `/llms-full.txt`)
- **Index for AI tools:** https://docs.payowl.io/llms.txt
- **Copy for AI** (the button at the top of the web page) copies the whole reference to your clipboard.

### With Claude (claude.ai or the Claude app)

1. On https://docs.payowl.io press **Copy for AI**.
2. Start a chat, paste, and then ask for what you need. Say which language and framework you use, for example:

```text
Above is the PayOwl Wallet merchant API reference. I run a Node.js (Express) shop.
Write:
1. a function that gets a permanent USDT address on Tron for a customer (order_id = the customer's id),
2. a POST /payowl/callback route that verifies the HMAC header with my API key from the
   PAYOWL_MERCHANT_KEY environment variable, answers "ok", and credits the customer's
   order only when status is "Paid" (ignoring repeats of the same tx_hash + status).
```

### With Claude Code (in your project)

Claude Code works in your codebase and can read the docs itself. In your project folder, run `claude` and ask:

```text
Read https://docs.payowl.io/llms-full.txt (the PayOwl Wallet merchant API).
Add PayOwl payments to this app: a static TRON USDT address per customer, shown on
their billing page, and a webhook endpoint that verifies the HMAC signature and marks
payments paid on "Paid". Keep the API key in PAYOWL_MERCHANT_KEY. Add tests.
```

To keep the reference in your repository (so every later session has it), ask Claude Code to save it, e.g. to `docs/payowl-api.md`, and mention that file in your project's `CLAUDE.md`.

### With ChatGPT, Cursor and others

The same works anywhere: paste the Markdown (**Copy for AI**) into ChatGPT, or in Cursor add https://docs.payowl.io/docs.md as a doc (**@Docs → Add new doc**) and refer to it in your prompt.

### Good prompts to start from

- *"Create a static address per customer on Tron, BNB Smart Chain and Solana, and store the `track_id` with the customer."*
- *"Write the webhook handler: verify the `HMAC` header (HMAC-SHA512 of the raw body with my API key), answer `ok`, act only on `Paid`."*
- *"Show my balance per coin from `GET /general/account/balance` on the admin page."*
- *"Pay a user's withdrawal with `POST /payout`, using my withdrawal id as the `Idempotency-Key`, and handle the payout webhooks."*

### Keep your keys safe

- **Never paste your API key or payout key into a chat.** Tell the assistant the key is in an environment variable (e.g. `PAYOWL_MERCHANT_KEY`) and put the real key there yourself.
- The payout key can send money: keep it on your server only, never in a website, app or repository.
- Check what the assistant wrote before going live: the webhook handler must **verify the signature** and deliver goods **only on `Paid`**. Use the app's **Send a test webhook** (Settings → Merchant → Webhooks) to try your endpoint.

## Static addresses

### POST /payment/static-address

Creates a permanent address. Every payment to it, above the minimum, at any time, is credited to you.

| Field | Type | |
|---|---|---|
| `network` | string | **Required.** A network name or alias from the table above |
| `callback_url` | string | Where webhooks go (https). Left out: the key's default callback URL (set in the app), if any. Sent again with the same `order_id`, a new `callback_url` replaces the address's old one (its undelivered webhooks follow); left out, the old one stays. |
| `order_id` | string | Your reference (e.g. your customer's id). **Idempotent:** the same `order_id` on the same network with the same API key always returns the same address (another of your keys gets its own). **Differs from OxaPay** (it would create a new one). |
| `email` | string | Payer's email, for your reports |
| `description` | string | Up to 1000 characters |
| `auto_withdrawal` | integer | `1`: each payment to this address is sent on to **your withdrawal address for its coin** once confirmed, instead of staying in your balance (as OxaPay's Address List). Set the addresses in the app: Settings → Merchant → Auto-withdrawal. Needs an address for at least one coin on the network. `0` or left out: payments stay in your balance. Sent again with the same `order_id`, it changes the address's setting. See [Auto-withdrawal](#auto-withdrawal). |
| `to_currency` | | Not supported (no auto-convert): leave it out. |

```bash
curl -X POST https://api.payowl.io/v1/payment/static-address \
  -H "merchant_api_key: YOUR_KEY" -H "Content-Type: application/json" \
  -d '{"network":"TRON","order_id":"customer-42","callback_url":"https://example.com/callback"}'
```

```json
{
  "data": {
    "track_id": "184035117",
    "network": "Tron Network",
    "address": "TQ9w…",
    "memo": "",
    "qr_code": "https://api.payowl.io/qr/TQ9w….png",
    "date": 1790421988
  },
  "message": "Operation completed successfully!", "error": {}, "status": 200, "version": "1.0.0"
}
```

Errors: creating an address on a network where you accept no coin is refused (`error.key = "network"`). Up to 10,000 addresses without payments per merchant.

### Accepted coins

Choose them in the app (Settings → Merchant → Accepted coins). `GET /payment/accepted-currencies` lists them. A payment in a coin you don't accept is still credited to your balance (nothing can refuse it on chain), but no webhook is sent for it.

### GET /payment/static-address

Your static addresses, newest first. Query filters: `track_id`, `network`, `currency`, `address`, `have_tx` (1/0), `order_id`, `email`, `page`, `size` (max 200).

```json
{ "data": { "list": [ { "track_id": "184035117", "address": "TQ9w…", "network": "Tron Network", "callback_url": "https://…",
  "email": "", "order_id": "customer-42", "description": "", "date": 1790421988 } ],
  "meta": { "page": 1, "last_page": 1, "total": 1 } }, "message": "…", "error": {}, "status": 200, "version": "1.0.0" }
```

### POST /payment/static-address/revoke

Body: `{"address": "T…"}`. Stops webhooks for that address. **Differs from OxaPay:** a payment that still arrives there is credited to your balance anyway (it just isn't reported by webhook).


### Auto-withdrawal

With `auto_withdrawal: 1`, each payment to the address is **sent on automatically** once it's confirmed and credited, to the withdrawal address you saved for that coin (e.g. USDT on Tron → your USDT TRC-20 address).

- **What's sent:** the amount credited (after the payment fee) minus the coin's network fee (the withdrawal fee in `/common/currencies`). It's an ordinary withdrawal, sent within seconds. To an address saved **more than 24 hours ago** there's no daily limit: only a single forward above 10× the review limit (e.g. 5,000 USDT) gets a quick manual check. To a newly saved or changed address, the usual daily review limit applies for its first 24 hours (a safeguard if someone else ever changes it). Auto-withdrawals don't count toward your own withdrawals' daily limit.
- **Webhooks:** unchanged (`Paying`, `Paid`). In payment information, `txs[].auto_withdrawal.processed` becomes `true` once it's made.
- **When it can't be made** (no address saved for the coin, below the minimum withdrawal after the fee, withdrawals paused): the payment stays in your balance, you get a Telegram message saying why, and the app shows it on the payment.
- **For a whole key, without code:** in the app, Settings → Merchant → the key → **Auto-withdrawal: On** sends every payment to that key's addresses on (addresses made earlier too). Off: only addresses made with `auto_withdrawal: 1`.
- **Your addresses:** one per coin and network, in the app (Settings → Merchant → Auto-withdrawal). Each change is announced in the bot. To another PayOwl Wallet user's address it's instant and free.

## Payment information

### GET /payment/{track_id}

A static address and all its payments, in OxaPay's payment-information format. The `track_id` is the address's; each payment to it is an entry in `txs`.

- `status`: `waiting` (no payment yet), `paying` (a payment is confirming), `paid`.
- `amount`: the total paid.
- Extra (not in OxaPay): `ignored_payments`, payments below the minimum that weren't credited, each with `tx_hash`, `amount`, `currency`, `network`, `sender_address`, `reason` (`below_minimum`), `minimum`, `date`.

```json
{ "data": { "track_id": "184035117", "type": "static_address", "amount": 105, "currency": "USDT", "status": "paid",
  "mixed_payment": false, "callback_url": "https://…", "description": "", "email": "", "fee_paid_by_payer": 0, "lifetime": 0,
  "order_id": "customer-42", "under_paid_coverage": 0, "return_url": "", "thanks_message": "", "expired_at": 0, "date": 1790421988,
  "txs": [ { "tx_hash": "aa23…11b", "amount": 100, "currency": "USDT", "network": "Tron Network", "address": "TQ9w…",
    "status": "confirmed", "confirmations": 19, "auto_convert": { "processed": false, "amount": 0, "currency": "" },
    "auto_withdrawal": { "processed": false }, "date": 1790422100 } ],
  "ignored_payments": [] }, "message": "…", "error": {}, "status": 200, "version": "1.0.0" }
```

### GET /payment

Your static addresses that received payments, one entry per `track_id` in the format above. Filters: `track_id`, `status` (`paying`/`paid`), `currency`, `address`, `from_date`, `to_date` (UNIX), `from_amount`, `to_amount`, `sort_by` (`create_date`, `pay_date`, `amount`), `sort_type` (`asc`/`desc`), `page`, `size`.

## Balance

### GET /general/account/balance

```json
{ "data": { "USDT": 1284.5, "TRX": 310.2, "USDC": 50, "BNB": 0.4, "POL": 0, "SOL": 1.5 }, "message": "…", "error": {}, "status": 200, "version": "1.0.0" }
```

By coin, networks added up (as OxaPay reports). In the wallet each network is its own balance.

## Payouts

Send from your wallet balance to any address, in OxaPay's payout format, with the **payout key** (`payout_api_key` header). The merchant key can't send money.

- **Your limits** (set in the app, Settings → Payouts → the key): per payout key, a maximum per payout and a daily maximum (that key's payouts in the last 24 hours), in US dollars (stablecoins 1:1, TRX, BNB, POL and SOL at the current price). A payout above them is refused with `error.key = "limit"`; nothing leaves your balance.
- **Review:** large payouts (above the wallet's review limit, e.g. 500 USDT in 24 hours) wait for a manual check (`processing`), then are sent, or rejected and refunded.
- To another PayOwl Wallet user's address: instant and free (`"internal": true`).

### POST /payout

| Field | Type | |
|---|---|---|
| `address` | string | **Required.** Recipient: `T…` on Tron, `0x…` on BSC/Polygon, base58 on Solana |
| `currency` | string | **Required.** `USDT`, `USDC`, `TRX`, `BNB`, `POL` or `SOL` |
| `amount` | number | **Required.** What the recipient gets; the fee comes on top, from your balance |
| `network` | string | Required for a coin on several networks (USDT, USDC): a network name or alias |
| `callback_url` | string | Where payout webhooks go. Left out: the payout key's default callback URL (set in the app), if any. |
| `description` | string | For your reports |
| `memo` | string | Accepted and stored (no network here needs one) |

Header `Idempotency-Key` (optional, recommended): a unique value per payout, e.g. your withdrawal id. A retried request with the same key returns the same payout instead of paying twice. **Differs from OxaPay** (it has no such protection).

```bash
curl -X POST https://api.payowl.io/v1/payout \
  -H "payout_api_key: YOUR_PAYOUT_KEY" -H "Idempotency-Key: withdrawal-5813" -H "Content-Type: application/json" \
  -d '{"address":"TJRabPrwbZy45sbavfcjinPJC18kjpRTv8","currency":"USDT","network":"TRON","amount":20,"callback_url":"https://example.com/payout-callback"}'
```

```json
{ "data": { "track_id": "257810344", "status": "pending" }, "message": "Operation completed successfully!", "error": {}, "status": 200, "version": "1.0.0" }
```

### GET /payout/{track_id} and GET /payout

A payout, or your payouts. List filters: `status`, `type` (`internal`/`external`), `currency`, `network`, `from_amount`, `to_amount`, `from_date`, `to_date`, `sort_by`, `sort_type`, `page`, `size`.

```json
{ "track_id": "257810344", "address": "TJRab…", "currency": "USDT", "network": "Tron Network", "amount": 20, "fee": 1,
  "status": "confirmed", "tx_hash": "4f1c…", "description": "", "internal": false, "memo": "", "date": 1790430000 }
```

| `status` | Meaning |
|---|---|
| `processing` | Waiting for a manual check |
| `pending` | Queued to be sent |
| `confirming` | Sent, waiting for the network |
| `confirmed` | Paid |
| `rejected` | Not sent; amount and fee are back in your balance |

### When a payout is refused

The payout's amount **plus its fee** (`withdraw_fee` in `/common/currencies`) must be in your balance on that network: with 4.95 USDT on BSC and a 0.25 fee, the most you can pay out is 4.70.

Refusals are about **your** account (your balance, your limits), so **don't show the message to your customers**: show them your own text (e.g. "Your withdrawal is being processed") and deal with it on your side. The message itself stays neutral, and the numbers are in `error.details` for your code:

| `error.key` | `error.message` | `error.details` |
|---|---|---|
| `insufficient_funds` | Insufficient balance for this payout. | `amount`, `fee`, `required`, `balance`, `max_payout` |
| `limit` | This payout is above the allowed limit. | `limit` (`per_payout` or `daily`), `max_usd` or `daily_usd`, `used_usd`, `payout_usd` |

`error.details` is **not in OxaPay's API** (OxaPay integrations ignore it).

### Payout webhooks

To the payout's `callback_url`, signed like payment webhooks but with the **payout key**: `Confirming` (sent), then `Confirmed`, or `Failed` (rejected and refunded).

```json
{ "track_id": "257810344", "status": "Confirmed", "type": "payout", "tx_hash": "4f1c…", "address": "TJRab…",
  "amount": 20, "value": 20, "currency": "USDT", "network": "Tron Network", "description": "", "date": 1790430000 }
```

## More endpoints

Mainly for OxaPay SDKs and plugins.

| Endpoint | Key | Returns |
|---|---|---|
| `GET /payment/accepted-currencies` | merchant | `{"list": ["USDT", "TRX", "USDC", "BNB", "POL", "SOL"]}` |
| `GET /payment/stats` | merchant | Per coin: `pay_currency`, `total` (number of payments), `received_amount` (after the fee, string). Filters: `type`, `network`, `pay_currency`, `from_date`, `to_date` |
| `GET /common/currencies` | none | Each coin with its networks (keyed `Tron`, `BSC`, `Polygon`, `Solana`): `required_confirmations`, `deposit_min`, `withdraw_fee`, `withdraw_min`, `static_fixed_fee` |
| `GET /common/prices` | none | USD prices, e.g. `{"USDT": 1, "TRX": 0.34, "USDC": 1, "BNB": 778, "POL": 0.12, "SOL": 124}` |
| `GET /common/fiats` | none | Fiat currencies with the USD value of one unit: `{"EUR": {"symbol": "EUR", "name": "Euro", "price": 1.087, "display_precision": 0.001}, …}` |
| `GET /common/networks` | none | The networks switched on: `{"list": ["Tron Network", "Binance Smart Chain", "Polygon Network", "Solana Network"]}` |
| `GET /common/monitor` | none | `{"status": true}` when the service is up |

## Payment webhooks

For each payment to an address with a `callback_url`, we POST JSON to it:

1. `"status": "Paying"`: seen on chain and confirming, within seconds. **Don't deliver yet.**
2. `"status": "Paid"`: final and credited to your balance. **Safe to deliver.** Seconds on BSC, a few seconds to a minute on Polygon, ~15 seconds on Solana, 19 blocks (~1 minute) on Tron (TRX on Tron is only seen once final, so its two webhooks arrive together).
3. `"status": "Failed"` (**not in OxaPay's API**): only if a payment you were sent `Paying` for is reversed by the network before it's final (`txs[0].status: "failed"`, `received_amount: 0`). Nothing was credited.

Only deliver goods on `Paid`.

```json
{
  "track_id": "184035117", "status": "Paid", "type": "static_address", "module_name": "PayOwl Wallet",
  "amount": 100, "value": 100, "sent_value": 100, "currency": "USDT",
  "order_id": "customer-42", "email": "", "note": "", "fee_paid_by_payer": 0, "under_paid_coverage": 0, "description": "",
  "date": 1790422100,
  "txs": [{
    "status": "confirmed", "tx_hash": "aa23…11b", "sent_amount": 100, "received_amount": 99, "value": 100, "sent_value": 100,
    "currency": "USDT", "network": "Tron Network", "sender_address": "TJRa…", "address": "TQ9w…", "rate": 1,
    "confirmations": 19, "auto_convert_amount": 0, "auto_convert_currency": "", "date": 1790422100
  }]
}
```

### Verify the signature

The `HMAC` header is the hex HMAC-SHA512 of the **raw request body**, keyed with the API key that made the address (payout webhooks: the payout key that made the payout), exactly as OxaPay. Reject anything that doesn't match.

```js
const crypto = require("crypto");
const expected = crypto.createHmac("sha512", MERCHANT_API_KEY).update(rawBody).digest("hex");
if (!crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(String(req.headers["hmac"] || "")))) return res.status(400).end();
```

```python
import hmac, hashlib
expected = hmac.new(MERCHANT_API_KEY.encode(), raw_body, hashlib.sha512).hexdigest()
if not hmac.compare_digest(expected, request.headers.get("HMAC", "")):
    abort(400)
```

### Answer "ok"

Reply HTTP 200 with the body `ok`. Otherwise we retry after about 1 minute, 3 minutes, 30 minutes and 3 hours (5 attempts in all). The same payment can reach you more than once: use `tx_hash` + `status` to ignore repeats. In the app (Settings → Merchant or Payouts → Webhooks) you can send a signed test webhook, see what your server answered, and resend any webhook.

**Tip: set the callback URL on the key, not in each request.** In the app (Settings → Merchant → your key → Default callback URL), save your callback URL once and create addresses **without** `callback_url`. They use the key's URL, whatever it is at the time: if your server moves, change it there and every address follows at once, old ones included, along with webhooks not delivered yet. An address created **with** its own `callback_url` keeps it (move those as below). The same works for payouts, with the payout key's default callback URL.

| Address created… | After you change the key's callback URL |
|---|---|
| without `callback_url` | Follows automatically: new payments (and undelivered webhooks) go to the new URL |
| with its own `callback_url` | Keeps its own URL: move it with **Change** below, or send the same `order_id` again with the new `callback_url` |

**Your callback URL moved?** In the app (Settings → Merchant → Webhooks → Callback URLs), tap **Change** next to the old URL and enter the new one: every address, payout and key default using it switches, including webhooks not delivered yet (then resend the failed ones in one tap). We send a signed test webhook to the new URL first, so it must answer 200 `ok`. The addresses themselves don't change. Webhooks already delivered to the old URL aren't sent again.

## Errors

```json
{ "data": {}, "message": "network must be one of: …", "error": { "type": "validation_error", "key": "network", "message": "network must be one of: …" }, "status": 400, "version": "1.0.0" }
```

| HTTP status | `error.type` |
|---|---|
| 400 | `validation_error`: `error.key` names the field |
| 401 | `authentication_error`: missing or wrong key |
| 404 | `not_found` |
| 429 | too many requests (120 a minute) |
| 500 | `server_error` |
