> ## 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.

# Payouts, sweeps & balances

> Send your customers' USDT and USDC to outside addresses, one at a time or 500 at once, sweep balances to your treasury, and follow each payout to the chain.

A **payout** moves a customer's USDT or USDC from their Rach address to any outside address on
the same chain. Your servers send payouts **on your customers' behalf**: you created the
customers, so no customer step is involved. Every request is signed with your
[payout key](https://docs.rach.finance/guides/caas-payout-signing.md).

**Who pays what.** `amount` is exactly what the destination receives. Rach's flat fee for the
chain is taken **on top**, in the same token and from the same customer's address. Rach pays the
network gas, including TRON energy and Solana fees. Your customer needs no ETH, BNB, POL, TRX or
SOL. Each response shows the `fee` and the `total_debited`.

## Send payouts

Up to 500 payouts per request, across any mix of chains, tokens and customers.

`POST https://api.rach.finance/caas/v1/payouts`, signed (see
[Payout keys & signing](https://docs.rach.finance/guides/caas-payout-signing.md) for the headers), with for example
`Idempotency-Key: withdrawals-batch-20261121-07`:

```json theme={null}
{
  "items": [
    { "customer_ref": "cus_8f2a91", "chain": "tron",     "token": "USDT", "amount": "125.50",
      "to_address": "TQ5dK…Xh", "reference": "withdrawal-991" },
    { "customer_ref": "cus_1b7c03", "chain": "base",     "token": "USDC", "amount": "40",
      "to_address": "0x5e1f…a2", "reference": "withdrawal-992" },
    { "customer_ref": "cus_77de10", "chain": "solana",   "token": "USDT", "amount": "1000",
      "to_address": "9WzD…WM", "reference": "withdrawal-993" }
  ]
}
```

* `chain`: `polygon`, `base`, `ethereum`, `bsc`, `tron` or `solana`. The aliases `eth`, `bnb`,
  `pol`, `trx` and `sol` are also accepted.
* `token`: `USDT` or `USDC` where the chain has it (TRON: USDT; Base: USDC).
* `amount`: a decimal string with up to 6 decimals.
* `reference`: yours, up to 128 characters, and echoed in every response and webhook.
* Name the customer by `customer_ref`, or by Rach's `customer_id`.

**All or nothing.** Every item is checked before anything moves: chain, token, address format,
and that the customer holds `amount + fee` beyond what their earlier queued payouts will take.
Several items from one customer are counted together. If any item fails a check, **nothing** is
sent and you get `422` listing every item to fix:

```json theme={null}
{
  "error": "No payouts were made: fix the listed items and send the request again",
  "items": [
    { "index": 1, "error": "insufficient balance: 39.000000 USDC available, 41.000000 needed (amount 40.000000 + fee 1.000000)" }
  ]
}
```

On success you get `202` with the batch. Each item is now a durable transfer that Rach drives
to the chain, retrying and recovering on its own.

```json theme={null}
{
  "id": "pob_3f6c…",
  "kind": "PAYOUT",
  "origin": "API",
  "status": "PROCESSING",
  "item_count": 3,
  "items": [
    { "id": "po_91a2…", "batch_id": "pob_3f6c…", "reference": "withdrawal-991", "customer_ref": "cus_8f2a91",
      "customer_id": "c4b1…9e", "chain": "tron", "token": "USDT", "amount": "125.500000", "fee": "…",
      "total_debited": "…", "to_address": "TQ5dK…Xh", "status": "QUEUED", "created_at": "2026-11-21T09:20:00Z" }
  ],
  "created_at": "2026-11-21T09:20:00Z"
}
```

## Follow each payout

Each item ends exactly once, and you are told by webhook:

```json theme={null}
{
  "event": "payout.settled",
  "event_id": "payout.settled:po_91a2…",
  "payout_id": "po_91a2…",
  "batch_id": "pob_3f6c…",
  "reference": "withdrawal-991",
  "customer_ref": "cus_8f2a91",
  "customer_id": "c4b1…9e",
  "chain": "tron",
  "token": "USDT",
  "amount": "125.500000",
  "fee": "…",
  "total_debited": "…",
  "to_address": "TQ5dK…Xh",
  "status": "SETTLED",
  "tx_hash": "a9e3…",
  "updated_at": "2026-11-21T09:21:04Z"
}
```

`payout.failed` has the same shape, with `status: "FAILED"` and a `reason`. A failed payout
moved nothing and charged no fee, so return the funds to your customer's balance in your ledger.
Deduplicate on `event_id`.

Item statuses: `QUEUED`, then `SUBMITTED` (broadcast), then `SETTLED` or `FAILED`. A batch is
`PROCESSING` until every item has ended, then `COMPLETED`, `PARTIAL` (some failed) or `FAILED`.

If a webhook is missed, poll:

```bash theme={null}
GET /v1/payouts                 # your batches, newest first (?limit=&offset=)
GET /v1/payouts/{batch_id}      # a batch with all its items
GET /v1/payout-items/{id}       # one item
```

> [!TIP]
>
> **Debit your customer when you send, not when it settles.** Hold `total_debited` from their
> balance when you submit. Release it on `payout.failed`; treat it as final on `payout.settled`.
> That way two withdrawals cannot spend the same balance. Rach enforces the same rule on chain
> balances.

## Sweep balances to one address

A sweep moves **every** customer's balance of a token on one chain to a single address, such as
your treasury. Each wallet sends its whole balance less the chain's fee. Wallets holding less
than the fee are skipped.

`POST /v1/sweeps`, signed:

```json theme={null}
{
  "chain": "tron",
  "token": "USDT",
  "to_address": "TTreasury…",
  "min_amount": "20",
  "customer_refs": ["cus_8f2a91", "cus_1b7c03"],
  "reference": "daily-sweep-2026-11-21"
}
```

* `min_amount` (optional): skip wallets that would send less than this after the fee.
* `customer_refs` (optional): sweep only these customers. Leave it out to sweep everyone.

The answer is a batch of `kind: "SWEEP"`, followed and reported exactly like payouts.

## From the dashboard

Owners and admins can do all of this in **CaaS dashboard → Payouts**: see balances, upload a CSV
of payouts (`customer_ref, chain, token, amount, to_address, reference`), sweep, and watch each
batch to the chain. The dashboard needs no payout key. It uses your signed-in session and its
own idempotency keys.

## Sandbox

Test-mode keys check the request and the signature, then answer with
`status: "SANDBOX_SIMULATED"` and the default fee for the chain. Nothing is read or moved.


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