# Payouts

Sending money out of a customer's wallet: to a payee's bank account, to another wallet, or to an outside address. This page covers the rails and the rule that picks one, quotes, dry run, scheduled and conditional payouts, batches, the travel rule, holds, and the remittance text each rail carries.

Status: available. USD by ACH, same-day ACH and wire, and EUR by SEPA, for every verified customer; other rails per customer. The code is `lib/ops/payout.ts`, `lib/pure/rails.ts`, `lib/payout-quotes.ts`, `lib/scheduled-payouts.ts`, `lib/payout-batches.ts`, `lib/pure/travel-rule.ts` and `lib/pure/external-ref.ts`.

| Operation | Scope | Idempotency-Key | Moves money | What it does |
|---|---|---|---|---|
| `POST /customers/{id}/payees` | `payees:write` | optional | no | Add a bank account as a destination for money. |
| `GET /customers/{id}/brand` | `customers:read` | none | no | The business's own look on Skerry's hosted checkout and payment-link pages: logo, accent, theme, font, corner radius, language. |
| `PUT /customers/{id}/brand` | `customers:write` | none | no | Set that look. |
| `GET /customers/{id}/payees` | `payees:read` | none | no | The customer's payees, each with the receiving bank's name check (`name_check`) where the rail has one. |
| `GET /customers/{id}/payees/{payee_id}` | `payees:read` | none | no | One payee, with the name check as it stands now. |
| `DELETE /customers/{id}/payees/{payee_id}` | `payees:write` | none | no | Remove a payee. |
| `POST /customers/{id}/payees/{payee_id}/pause` | `payees:write` | optional | no | Stop paying a payee for now without removing it. |
| `POST /customers/{id}/payees/{payee_id}/resume` | `payees:write` | optional | no | Pay a paused payee again. |
| `POST /customers/{id}/payees/{payee_id}/check` | `payees:write` | optional | no | Ask the receiving bank again whether the name on the account matches, and return the payee with the answer as `name_check`. |
| `POST /payouts/quote` | `payouts:write` | none | no | What a payout would cost, as a quote that binds the instruction. |
| `POST /payouts` | `payouts:write` | required | yes | Send money to a payee, a wallet or an address. |
| `POST /payouts/batches` | `payouts:write` | required | yes | Up to 50 payouts in one call. |
| `GET /payouts/batches` | `payouts:read` | none | no | Batches, newest first, each with the outcome of each payout in it. |
| `GET /payouts/batches/{id}` | `payouts:read` | none | no | One batch, with the outcome of each payout in it. |
| `GET /customers/{id}/payout-fees` | `payouts:read` | none | no | Who bears the cost of a bank payout, per currency and rail: `fees.usd.wire` and the like, as the banking partner states them. |
| `PATCH /customers/{id}/payout-fees` | `customers:write` | none | no | Change who bears the cost of a bank payout. |
| `POST /customers/{id}/batch-settlement-schedules` | `payouts:write` | optional | no | Retired: the banking partner deprecated batch settlement schedules and named no replacement. |
| `GET /payouts` | `payouts:read` | none | no | Payouts this project has made, with the reference each was given. |
| `GET /payouts/{id}` | `payouts:read` | none | no | One payout and where it has got to, with `amount_minor`, `fee_minor` and `authorisation`. |
| `PATCH /payouts/{id}` | `payouts:write` | required | yes | Change the amount of a payout that is still `awaiting_funds`; once its funds have arrived it is refused with 409 `payout_not_amendable`. |
| `DELETE /payouts/{id}` | `payouts:write` | none | no | Cancel a payout that has not left yet. |
| `GET /rates` | `*` | none | no | The rate between two currencies. |
| `POST /customers/{id}/standing-orders` | `standing_orders:write` | optional | yes | An address that converts and pays out whatever arrives. |
| `GET /customers/{id}/standing-orders` | `standing_orders:read` | none | no | The customer's standing orders. |
| `GET /customers/{id}/standing-orders/{standing_order_id}/conversions` | `standing_orders:read` | none | no | What one standing order has converted, newest first, as the banking partner reports it: each `{ id, amount, currency, status, standing_order_id, occurred_at }`. |
| `GET /payouts/scheduled` | `payouts:read` | none | no | Scheduled payouts, newest first. |
| `GET /payouts/scheduled/{id}` | `payouts:read` | none | no | One scheduled payout: when it runs next, how many times it has run, the last payout it made and how the last run went. |
| `DELETE /payouts/scheduled/{id}` | `payouts:write` | none | no | Cancel a scheduled payout that has not run, or stop a recurring one. |
| `POST /payouts/{id}/release` | `payouts:write` | optional | yes | A person releases a conditional payout (`{id}` is the scheduled payout's id): it runs now, spending what was set aside for it. |

## Sending one

```text
POST /payouts
Authorization: Bearer sk_test_…
Idempotency-Key: 5e88…

{ customer_id, amount | amount_minor, from: { currency, wallet_id }, to: { currency, payee_id | wallet_id | address, chain? }, rail?, speed?, quote_id?, execute_at? | schedule?: { every, unit: day|week|month, end_at? | count? } | release_on?: { event, object_id } | "approval", expires_at?, travel_rule?: { originator, beneficiary }, reference?, external_ref?, external_kind?, remittance?: { invoice_number?, amount?, date? }, dry_run? }
```

`amount` is a decimal string in `from.currency`; `amount_minor` is the same amount in integer minor units, and either may be sent. `to` names exactly one of `payee_id`, `wallet_id` or `address`. The answer carries `amount_minor`, `fee_minor`, `rail`, `rail_reason` and `authorisation`.

The call needs an `Idempotency-Key`.

A payout is checked by the spend guard as `payout.create`: the freeze, the customer's withdrawal allow-list, the new-payee hold and cooling-off, the risk rules, the caller's mandates and budgets. See [approvals.md](approvals.md) and [mandates.md](mandates.md). An outside address is checked for its chain's format (Base when no chain is named) and for the coin existing on that chain before anything is sent.

`DELETE /payouts/{id}` cancels a payout that has not left yet: its entries in the books are reversed and what it counted against a limit or budget is given back.

`PATCH /payouts/{id}` with `{ amount }` (or `amount_minor`) changes the amount of a payout that is still `awaiting_funds`; once its funds have arrived it answers 409 `payout_not_amendable`. It needs an `Idempotency-Key`. A higher amount is checked by the spend guard as `payout.create` for the difference, and the difference is counted under the payout, so it is given back with the rest if the payout fails, is cancelled or comes back. If the check holds it, nothing changes until the same request is sent again with `Skerry-Approval`. A lower amount is not checked, and what was already counted stays counted. The stored record takes the new amount, and the difference is booked in the payout's own movement.

## Rails

| Rail | Currency | Approval the customer must hold | Per-payment limit | Reference the payee's bank shows | Status |
|---|---|---|---|---|---|
| `ach` | USD | `base` or `reliance` | 1,000,000.00 USD | `ach_reference`, 10 characters, separators removed before it is cut | available |
| `ach_same_day` | USD | `base` or `reliance` | 1,000,000.00 USD | `ach_reference`, 10 characters, separators removed before it is cut | available |
| `wire` | USD | `base` or `reliance` | none applied | `wire_message`, 140 characters | available |
| `fednow` | USD | `base` or `reliance` | 10,000,000.00 USD | none carried | per customer: the payee's bank must report it |
| `rtp` | USD | none | none applied | none carried | not offered: reported on money arriving only |
| `sepa` | EUR | `sepa` | none applied | `sepa_reference`, 140 characters | available |
| `faster_payments` | GBP | `faster_payments` | none applied | none carried | per customer |
| `spei` | MXN | `spei` | none applied | none carried | per customer |
| `pix` | BRL | `pix_offramp` or `pix` | none applied | none carried | per customer |
| `bre_b` | COP | `cop` | none applied | none carried | per customer |
| `co_bank_transfer` | COP | `cop` | none applied | none carried | per customer |

Money can arrive on more rails than a payout can leave on; `account.credited` carries the rail it came by.

### The rule that picks one

The rule is `chooseRail` in `lib/pure/rails.ts`, a pure function, so every choice comes back with `rail_reason`: a code and a sentence.

1. The currency that lands fixes the family of rails: USD (ach, ach_same_day, wire, fednow), EUR (sepa), GBP (faster_payments), MXN (spei), BRL (pix), COP (bre_b or co_bank_transfer, by the kind of payee account).
2. A rail is usable only if the customer holds the approval for it. FedNow also needs the payee's bank to report that it can receive it; without the bank's own word it is not assumed.
3. A named `rail` is used if it is usable and refused if it is not. It is never swapped for another.
4. Otherwise, for USD, `speed` decides: `fastest` prefers fednow, then wire, then ach_same_day, then ach; `cheapest` prefers ach, then ach_same_day, then wire; `standard`, and no preference, sends by ach up to the ACH limit and by wire above it.
5. Amount limits are applied last: a rail whose limit the amount exceeds is skipped, or refused if it was named.

Reason codes on a choice: `requested`, `only_rail_for_currency`, `payee_account_kind`, `fastest_enabled`, `cheapest_enabled`, `standard_for_amount`, `above_ach_limit`. A refusal names one of `rail_unknown`, `speed_unknown`, `currency_unsupported`, `rail_wrong_currency`, `rail_not_offered`, `rail_not_enabled`, `rail_wrong_payee`, `amount_over_rail_limit`, with the rails the customer is enabled for.

RTP is listed because it is asked for by name. The banking partner reports it on money arriving and does not offer it for payouts, so it is never chosen and is refused when named.

## Quotes that bind

```text
POST /payouts/quote

{ customer_id, amount | amount_minor, from, to, rail?, speed? }
```

The answer carries `quote_id` and `valid_until` (120 seconds by default, `SKERRY_PAYOUT_QUOTE_SECONDS`), the rail it would leave on and why, and for a bank payout the name check on the payee (`payee_check`). `POST /payouts` with that `quote_id` executes exactly the quoted customer, amount, source, destination and rail, once. A payout that does not repeat the instruction is refused with `quote_mismatch` (`detail.field`: amount, from, to or rail); a spent or lapsed quote with `quote_used` or `quote_expired`.

What is bound is the instruction and the rail. `fee`, `rate` and the receive amount are what the provider's dry run reported when the quote was made. The provider is not asked to hold them, so on a payout that converts, the amount that arrives can differ from the quote. This is not a guaranteed rate.

## Dry run

Send `Skerry-Dry-Run: true`, or `dry_run: true` in the body, to check a payout without sending it. Validation, ownership, the freeze, policies, budgets, risk rules and payee rules are evaluated, and the provider's own dry run is asked. The answer is 200:

```text
{ "dry_run": true, "next": "run" | "hold" | "refuse", "checks": [ { "check": "freeze", "result": "passed" }, … ], "object": { … } }
```

`checks` lists `freeze`, `agent`, `withdrawal_allow_list`, `payee`, `risk`, `policy`, `budget` and `provider`, each `passed`, `held`, `refused` or `skipped`. Nothing is reserved, sent or created. With the header, no Idempotency-Key is needed and no idempotency record is kept.

The body flag is declared on these operations:

| Operation | operationId |
|---|---|
| `POST /payouts` | `payouts.create` |
| `POST /payouts/batches` | `payouts_batches.create` |
| `PATCH /payouts/{id}` | `payouts.update` |
| `POST /checkout-sessions` | `checkout_sessions.create` |
| `POST /payment-links` | `payment_links.create` |
| `POST /payments` | `payments.create` |
| `POST /payments/{id}/refunds` | `payments_refunds.create` |
| `POST /settlements` | `settlements.create` |
| `POST /subscriptions` | `subscriptions.create` |
| `POST /conversions` | `conversions.create` |
| `POST /agent-payments` | `agent_payments.create` |

The header also works on checkout sessions and payment links.

## Scheduled and conditional payouts

`POST /payouts` creates a scheduled payout instead of sending now when the body states exactly one of:

| Field | Plan |
|---|---|
| `execute_at` | Once, at a future time. |
| `schedule: { every, unit: day \| week \| month, end_at? \| count? }` | Recurring, starting at `execute_at` when one is given and otherwise one interval from now. |
| `release_on: { event, object_id }` | Conditional: runs when a Skerry event of that type about that object is recorded. |
| `release_on: "approval"` | Conditional: runs when a person calls `POST /payouts/{id}/release` (`{id}` is the scheduled payout's id). An agent's own credential is refused. |

Times are UTC. A monthly schedule keeps the day of the month it started on and falls back to the last day of a shorter month.

When it is due, the worker runs it as an ordinary payout, as the key that scheduled it and under that key's mandate as it stands at that moment: limits, allow-lists, budgets, risk rules and approval holds apply then, not when it was scheduled. A frozen customer, a revoked or expired key, a revoked agent or a revoked mandate cancels the schedule, with the reason (`payout.schedule_canceled`).

A conditional payout sets its amount aside in the source wallet (an earmark kept by Skerry; nothing moves at the provider) until it is released, cancelled, or lapses at `expires_at`: 7 days by default, 90 at most. `travel_rule` cannot be scheduled.

`GET /payouts/scheduled/{id}` says when it runs next, how many times it has run, and how the last run went. `DELETE /payouts/scheduled/{id}` cancels one that has not run, or stops a recurring one; payouts already made are not recalled. In the sandbox, `POST /sandbox/payouts/scheduled/{id}/advance` runs one now, and `POST /sandbox/events` records a named event so a payout waiting for it is released.

Scheduled payouts and sweep rules run only while the in-process worker is on; see operations.md.

## Batches

```text
POST /payouts/batches
Idempotency-Key: c40d…

{ payouts: [ ...as POST /payouts ], reference?, dry_run? }
```

Up to 50 payouts. The banking partner has no bulk call, and a batch is not one. Every item is validated first, and if any is wrong nothing is sent. The batch's total, per customer and currency, is checked against the caller's daily and monthly limits before anything is sent, so a batch that could not be completed is refused whole. Then each item runs as its own payout, with its own idempotency key derived from the batch's key and the item's position, and reports its own outcome: one can be refused by a policy, held for approval or rejected by the provider while the others go through. `GET /payouts/batches/{id}` returns the outcome of each. A dry run checks every item and the totals and writes nothing.

## Travel rule

A payout to an outside address may carry originator and beneficiary details, which the banking partner must pass on to the receiving institution:

```text
"travel_rule": {
  "originator":  { "is_self": true },
  "beneficiary": { "is_self": false, "name": "…", "address": { "street_line_1": "…", "city": "…", … }, "wallet_type": "hosted" | "external" | "self_custodied" }
}
```

`name` is required when `is_self` is false. The originator may also carry `identifying_information` (`type`, `number`, `issuing_country`), `birth_date` and `place_of_birth`. Skerry validates the shape, hands it over with the payout, and keeps none of it: the audit trail records only that it was sent and whether each party was the customer itself. One exception: a payout held for approval keeps the whole request, including `travel_rule`, in the approval until it is decided.

## States and holds

A payout is `awaiting_funds`, `processing`, `on_hold`, `paid`, `undeliverable`, `returning`, `returned`, `return_failed` or `canceled`. Every state the banking partner documents is mapped (`lib/pure/bridge-states.ts`); one it adds later is reported as `unknown`, which should be treated as still in progress.

While a payout is paused, `status` is `on_hold` and `hold` gives `{ reason_code, reason, deadline }`. Reason codes include `in_review`, `information_requested` (with `hold.compliance_request_id` when the request can be read), `exceeds_transaction_limits`, `exceeds_counterparty_limits`, `return_destination_missing` and `needs_attention`. This hold is the banking partner's. A hold for a person's approval is a different thing: the payout does not exist yet, and the call answered 202; see [approvals.md](approvals.md).

`GET /payouts/{id}?wait=<seconds up to 30>&until=<state>` holds the answer until the payout is paid, returned, canceled, undeliverable or return_failed, or reaches the state named.

## Remittance text per rail

`external_ref` (up to 200 characters) with `external_kind` (invoice, bill, order, booking or other) names the document a payout belongs to in your system. `reference` and `remittance: { invoice_number?, amount?, date? }` are what the payee's bank shows. Each rail has its own field and its own limit (the column in the rails table above), so the text is cut to what the rail carries rather than refused. Characters the rail does not carry are removed. On ACH, text that does not fit ten characters loses its separators and spaces before it is cut, so `SUP-2026-0042` leaves as `SUP2026004`; text that fits is sent unchanged. A SEPA reference shorter than six characters is not sent.

## Payees

`POST /customers/{id}/payees` adds a bank account as a destination. Its body is the banking partner's external-account fields, passed on as sent: `currency`, `account_type` (`us`, `iban` or `gb`), the owner's name, type and address, and the account's numbers; the reference gives the full list and an example. Each payee carries the receiving bank's name check (`name_check`) where the rail has one. Under a mandate that covers `payee.create`, the operation allow-list and approval rules apply; if it is held, send the same request again with `Skerry-Approval` once a person has approved it.

`POST /customers/{id}/payees/{payee_id}/pause` stops paying a payee without removing it, and `.../resume` pays it again; resuming is refused with `customer_frozen` while the customer is frozen. `.../check` asks the receiving bank for the name check again and returns the payee with the answer. Each is announced as `payee.updated`.

A US bank can be added by logging into it instead of typing its numbers: `POST /customers/{id}/bank-link` returns a `link_token` for the bank login page, and `POST /customers/{id}/bank-link/exchange` with `{ link_token, public_token }` finishes it and returns the payees it added, each announced as `payee.created`. A link token is finished once, and only for the customer it was started for. Finishing one is `payee.create` to a mandate.

Two settings are kept per customer at the banking partner and are reached through the API. `GET /customers/{id}/payout-fees` states who bears the cost of a bank payout, per currency and rail (`fees.usd.wire`, for instance), which decides whether a payee receives the amount sent or that amount less a fee; `PATCH` with `{ fees: { usd: { wire: "customer" } } }` changes the entries sent and leaves the rest. The currencies, rails and values on offer are the banking partner's and are passed through as it states them. `POST /customers/{id}/batch-settlement-schedules` with `{ currency, rail }` collapses the customer's bank payouts on that currency and rail into one settlement instead of one bank movement per payout; it is worth having only when one destination is paid many times a day. Neither can be changed with an agent's own credential, and both changes are written to the audit trail.

## Standing conversion

`POST /customers/{id}/standing-orders` creates an address that converts and pays out whatever arrives: `{ chain, currency, delivers_to: { payee_id | wallet_id, currency?, rail? }, reference?, return_instructions?: { address, memo? } }`. `return_instructions` says where a deposit that cannot be converted goes back to. A freeze stops new standing orders from being created.

`GET /customers/{id}/standing-orders/{standing_order_id}/conversions` lists what one standing order has converted, newest first, a page at a time, as the banking partner reports it.

## Events

| Event | Concerns | When |
|---|---|---|
| `payout.created` | payout | A payout was created. |
| `payout.processing` | payout | A payout's funds were received and it is on its way. |
| `payout.on_hold` | payout | A payout is paused: it is being checked, or information has been asked for. |
| `payout.canceled` | payout | A payout was canceled before it left. |
| `payout.updated` | payout | A payout changed state. |
| `payout.paid` | payout | A payout reached its destination. |
| `payout.returned` | payout | A payout came back. |
| `account.credited` | account | Money arrived in a customer's account. |
| `conversion.completed` | conversion | A conversion settled. |
| `wallet.created` | wallet | A wallet was created for a customer. |
| `payee.created` | payee | A payee was added. |
| `payee.updated` | payee | A payee changed: paused, resumed, or its name check came back. |
| `payee.removed` | payee | A payee was removed. |
| `standing_order.created` | standing_order | A standing conversion was created. |
| `standing_order.updated` | standing_order | A standing conversion changed state. |
| `standing_order.drained` | standing_order | Money that arrived at a standing conversion's address was converted and sent on. |
| `balance.low` | wallet | A wallet's balance fell under its floor. Sent once until the balance has been back at or above it. |
| `payout.scheduled` | scheduled_payout | A payout was set to run later: at a time, on an interval, or when an event arrives or a person releases it. |
| `payout.released` | scheduled_payout | A conditional payout was released, by the event it waited for or by a person, and runs now. |
| `payout.schedule_canceled` | scheduled_payout | A scheduled payout was cancelled: by request, because it lapsed, or because the key, agent, mandate or customer behind it may no longer send money. Carries the reason. |
