A merchant balance with a floor: keep working funds, sweep the rest to the bank (UC-A-04)
Status: current as of 2026-11-18.
Who this is for
A platform whose merchants want to keep some USDC on hand to pay from, and have everything above that amount swept to their own bank accounts. When you finish, each merchant's wallet keeps the amount you set and sends the rest to its own bank on a schedule, at a threshold, or when you ask.
Before you start
- Account: a SET API platform account, on the SET API plan.
- Key: a SET API key sent as
Authorization: Bearer …, with the scopeswrite(every POST, PUT and DELETE below) andread(every GET). - Switches: none.
- What must exist: a merchant verified by the provider (Give each merchant its own US account details, steps 1 and 2). The rule is the merchant's own standing instruction, set with your key; SET's operator cannot set, change or run it.
By API
- Open the merchant's wallet, held in custody by SET's provider. A repeat returns the same wallet.
POST /v1/wallets·Idempotency-Key``json { "customer": "cus_…", "chain": "base" }`The next step uses:id,address,chain`.
- Link each of the merchant's own bank accounts that a sweep may pay.
POST /v1/bank_accounts·Idempotency-Key``json { "customer": "cus_…", "currency": "usd", "ownerName": "…", "routingNumber": "…", "accountNumber": "…", "checkingOrSavings": "checking", "address": { "streetLine1": "…", "city": "…", "state": "…", "postalCode": "…" } }`The next step uses:id`.
- Fund the wallet. Payers send USDC to its
address, or bank transfers pay into it through an account that settles to it.POST /v1/virtual_accounts·Idempotency-Key``json { "customer": "cus_…", "currency": "usd", "settleTo": { "wallet": "wal_…" } }`The next step uses:depositInstructions`.
- Set the rule:
keepstays in the wallet, andallocationssplits each sweep across 1 to 5 of the merchant's own bank accounts, with shares adding up to 100.PUT /v1/wallets/{id}/treasury``json { "schedule": "weekly", "keep": "5000.00", "allocations": [{ "bankAccount": "…", "share": 100 }] }`Add"threshold": "…"to also sweep when the balance passes it, and"keepShare": "…"(a percent from 0 to 99.99) to leave part of what is abovekeepin the wallet. The next step uses:active,nextSweepAt`.
- Read the rule, or stop it.
DELETEon the same path turns it off.GET /v1/wallets/{id}/treasury·DELETE /v1/wallets/{id}/treasuryThe fields to read:active,nextSweepAt,lastSweptAt,lastResult.
- Sweep now when needed: by default everything above
keep, split by the rule.POST /v1/wallets/{id}/sweeps·Idempotency-Key``json {}`Send"amount": "…"to sweep less, orallocationsto split this sweep differently. The fields to read:id,amount,result,withdrawals`.
In SET Console
- In Platform View, Balances and conversion, the Wallets panel lists the merchant's wallets. Opening a wallet: Console: not available. Use the API call.
- Link a bank account. Console: not available. Use the API call.
- Open an account that pays into the wallet with the workflow in Collect on any rail into one balance.
- Set the rule. In the demo console, Platform View, Workflows, Keep working funds, sweep the rest shows the form: Wallet, Amount to keep, Bank account and Schedule, then Review and Confirm. The signed-in console opens the same workflow.
- Read or stop the rule. Console: not available. Use the API call.
- Sweep now. Console: not available. Use the API call.
Check it worked
GET /v1/wallets/{id}/withdrawals: each part of a sweep is a withdrawal to the merchant's own bank.GET /v1/wallets/{id}/treasury:lastSweptAtandlastResult.- In Platform View, Balances and conversion shows Balance transactions and Wallets.
- Webhooks:
wallet.created,wallet_withdrawal.created,wallet_withdrawal.payment_processed.
If it fails
400 schedule_invalid:scheduleis notdaily,weekly(Mondays) ormonthly(the 1st). Sweeps run at 15:00 UTC.400 treasury_rule_invalid: neitherschedulenorthresholdwas set.400 threshold_invalid: the threshold is not more thankeep.400 allocations_invalid: not 1 to 5 bank accounts, a repeated account, or shares that do not add up to 100. A sweep with no rule and noallocationsalso answers this.400 bank_account_invalid: a bank account that is not this merchant's own.400 keep_share_invalid:keepShareoutside 0 to 99.99.409 in_flight: a withdrawal from the wallet is still in flight; a sweep waits for it.409 nothing_to_sweep: nothing abovekeep.409 below_minimum: a part of the sweep is under the cash-out minimum, or less than 1.00 would reach the bank after SET's fee.409 initiation_required,409 provider_refused: the provider did not accept the withdrawal.403 operator_cannot_withdraw: SET's operator cannot set or run a rule.409 location_not_supported,503 custodial_wallets_disabled: the wallet cannot be opened for this merchant or deployment.401 api_key_invalid,403 scope_missing,429 rate_limited: the key, its scopes, or the rate limit.
All codes: Errors. Retrying a POST safely: Idempotency.
Related
- Treasury mode and split payouts
- Collect on any rail into one balance
- Travel Rule data: name each payer into the wallet with
POST /v1/wallets/{id}/activity/{eventId}/sender - All use cases
Changes
- 2026-11-18: In Console: the signed-in console opens the workflows its contract test proves.
- 2026-11-16: Every use case step by step, by API and in the console.
- 2026-11-16: Documentation written from the wallet's code.