> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rach.finance/llms.txt
> Use this file to discover all available pages before exploring further.

# Platforms & marketplaces

> Collect stablecoin payments for many stores, keep each store's money ring-fenced, take your platform fee, and pay each store to its own bank account.

Built for platforms that sell on behalf of many merchants — storefront builders,
marketplaces, booking and delivery apps. You integrate once; each of your stores
is a **sub-merchant** under your Rach account.

> [!TIP]
>
> Integrating now? Follow the step-by-step [Platform integration guide](https://docs.rach.finance/guides/platform-integration.md),
> with code for every call, a webhook handler and a daily payout job.

```mermaid theme={null}
sequenceDiagram
  participant C as Customer
  participant P as Your platform
  participant R as Rach
  P->>R: POST /checkout/create (sub_merchant, platform_fee)
  R-->>P: payment_url
  C->>R: pays USDT / USDC on the hosted page
  R->>P: payment.confirmed webhook (sub_merchant, platform_fee, fee)
  Note over R: store's share ring-fenced, your fee is yours
  P->>R: POST /platform/sub-merchants/{id}/payouts
  R-->>C: naira to the store's own bank account
```

## How the money moves

1. A customer pays a checkout created for one of your stores.
2. Rach takes its fee (0.5%, capped at 1 USD — or the customer pays it with
   `fee_bearer: "customer"`).
3. Your `platform_fee` is yours. The rest — the price less your platform fee, plus
   any overpayment — is the **store's share**.
4. Both sit in your Rach balance, but the store's share is **ring-fenced**: you
   cannot spend, swap or withdraw it as your own. It can only be paid out to that
   store's own bank account.

If Rach's fee is larger than your `platform_fee` (merchant-borne fee), the
difference comes out of the store's share.

## Create a store

```bash theme={null}
curl https://api.rach.finance/api/v1/platform/sub-merchants \
  -H "X-API-Key: $RACH_KEY" -H "Content-Type: application/json" \
  -d '{"reference":"kapo-farms","name":"Kapo Farms","email":"owner@kapo.example","country":"NG"}'
```

```json theme={null}
{
  "id": "sm_x8k2p0q4r7t1v5w9y3z6",
  "reference": "kapo-farms",
  "name": "Kapo Farms",
  "email": "owner@kapo.example",
  "country": "NG",
  "status": "active",
  "balances": [],
  "bank_accounts": [],
  "created_at": "2026-11-23T10:00:00Z",
  "updated_at": "2026-11-23T10:00:00Z"
}
```

`reference` is your own ID for the store and is unique on your account; repeating a
create with the same reference and name returns the same store (`200` instead of
`201`). Anywhere a store is named in a path or a checkout, its `sm_…` ID or your
reference both work.

| Endpoint | Purpose |
| - | - |
| `POST /platform/sub-merchants` | Create a store |
| `GET /platform/sub-merchants?page=&limit=&search=` | List stores with balances and bank accounts |
| `GET /platform/sub-merchants/{id}` | One store |
| `PATCH /platform/sub-merchants/{id}` | Change `name`, `email`, `country`, `metadata`, or `status` (`active`/`disabled`) |
| `GET /platform/sub-merchants/{id}/ledger` | Every movement of the store's share |
| `GET /platform/summary` | Store count, and per currency what is held for stores and what is yours |

A disabled store cannot take new checkouts or payouts; its share stays ring-fenced.

## Charge for a store

Add `sub_merchant` and, optionally, `platform_fee` (in the checkout's `currency`)
to an ordinary [checkout](https://docs.rach.finance/products/crypto-gateway.md):

```json theme={null}
{
  "amount": "50000",
  "currency": "NGN",
  "reference": "order-3001",
  "payment_method": "crypto",
  "fee_bearer": "customer",
  "sub_merchant": "kapo-farms",
  "platform_fee": "1000"
}
```

The response and the `payment.confirmed` webhook carry `sub_merchant` (the `sm_…`
ID), `platform_fee` (converted to dollars at the checkout's rate) and, once paid,
`fee` (Rach's fee taken). The hosted payment page shows the store's name with
"via" your platform's name. Neither the split nor the store ID is shown to the
customer.

## Store bank accounts

Each store can keep up to five Nigerian bank accounts, one of them primary.

| Endpoint | Purpose |
| - | - |
| `GET /platform/sub-merchants/{id}/bank-accounts` | List |
| `POST /platform/sub-merchants/{id}/bank-accounts` | Add: `bank_code`, `account_number`, `account_name`, optional `is_primary` |
| `PATCH /platform/sub-merchants/{id}/bank-accounts/{account_id}` | Correct details, or `{"is_primary": true}` |
| `DELETE /platform/sub-merchants/{id}/bank-accounts/{account_id}` | Remove (the next account becomes primary) |

Bank codes come from `GET /api/v1/banks?country=NG`. An account added or changed
**with an API key** can receive payouts only after 24 hours (`payable_after`), so a
leaked key cannot add an account and pay to it at once. Accounts added in the
dashboard are payable immediately.

## Pay a store

```bash theme={null}
curl https://api.rach.finance/api/v1/platform/sub-merchants/kapo-farms/payouts \
  -H "X-API-Key: $RACH_KEY" -H "Content-Type: application/json" \
  -d '{"amount":"20000","currency":"NGN","reference":"payout-kapo-2026-11-23"}'
```

```json theme={null}
{
  "id": "7c1e…",
  "reference": "payout-kapo-2026-11-23",
  "rach_reference": "WD-3F9A2C1B7D44",
  "sub_merchant": "sm_x8k2p0q4r7t1v5w9y3z6",
  "status": "pending",
  "amount": "20000",
  "currency": "NGN",
  "fee": "1",
  "fee_currency": "USD",
  "debit_usd": "15.598647",
  "payout_amount": "20000",
  "payout_currency": "NGN",
  "exchange_rate": "1369.99",
  "bank_account": { "bank_name": "OPay", "bank_code": "100004", "account_number": "8012345678", "account_name": "Kapo Farms" }
}
```

* `amount` is in naira (what the store receives) or in `USD` (what leaves the
  store's share). Rach's flat **1 USD** bank fee comes out of the store's share.
* Without `bank_account_id`, the store's primary account is paid.
* `reference` is your idempotency key: repeating it returns the first payout.
* `POST …/payouts/quote` with the same body prices a payout without locking anything.
* `GET …/payouts` lists a store's payouts; statuses are those of
  [withdrawals](https://docs.rach.finance/guides/settlement-withdrawals.md#withdrawal-statuses). A failed
  payout returns the whole amount to the store's share.
* When a payout finishes you receive a signed `payout.completed` or `payout.failed`
  [webhook](https://docs.rach.finance/guides/webhooks.md) with the naira paid, the rate and the bank reference.

### Turning on payouts by API key

Payouts are always available from the dashboard to a team member with the
withdrawal permission (and 2FA when enabled). Paying stores **by API key** is off
until a workspace owner switches it on under **Platform → API payouts**, with a 2FA
code. While it is off, the endpoint answers `403` with `api_payouts_disabled`.
Payouts by API key can only ever reach a store's own bank accounts.

## From the dashboard

**Payment gateway → Stores** shows how many stores you have, what you hold for them
and what is yours, and the **Payouts by API key** switch. Click a store to:

* see what is held for it, and disable or re-enable it;
* add bank accounts (up to five), make one primary, or remove one;
* pay it: enter naira to receive or dollars to send, see the live quote (rate, 1 USD
  fee, what leaves its share), and request the payout (with your 2FA code if enabled);
* follow its payouts and its ledger.

**Payment links** (on the Payment links tab) can be created for a store too: choose
the store and your platform fee in the form.

## Fees

| What | Fee |
| - | - |
| Each confirmed payment | 0.5%, capped at 1 USD (merchant- or customer-borne) |
| Each payout to a bank | 1 USD, from the store's share |
| Your platform fee | yours to set per checkout |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.