Skip to content
SETSimple Easy Transactions
SET DocsSET Crypto API Suite and SET API referenceCurrent as of 2026-11-18
Browse: SET Crypto API Suite

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 scopes write (every POST, PUT and DELETE below) and read (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

  1. 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`.
  1. 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`.
  1. 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`.
  1. Set the rule: keep stays in the wallet, and allocations splits 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 above keep in the wallet. The next step uses: active, nextSweepAt`.
  1. Read the rule, or stop it. DELETE on the same path turns it off. GET /v1/wallets/{id}/treasury · DELETE /v1/wallets/{id}/treasury The fields to read: active, nextSweepAt, lastSweptAt, lastResult.
  1. 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, or allocations to split this sweep differently. The fields to read: id, amount, result, withdrawals`.

In SET Console

  1. In Platform View, Balances and conversion, the Wallets panel lists the merchant's wallets. Opening a wallet: Console: not available. Use the API call.
  2. Link a bank account. Console: not available. Use the API call.
  3. Open an account that pays into the wallet with the workflow in Collect on any rail into one balance.
  4. 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.
  5. Read or stop the rule. Console: not available. Use the API call.
  6. 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: lastSweptAt and lastResult.
  • 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: schedule is not daily, weekly (Mondays) or monthly (the 1st). Sweeps run at 15:00 UTC.
  • 400 treasury_rule_invalid: neither schedule nor threshold was set.
  • 400 threshold_invalid: the threshold is not more than keep.
  • 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 no allocations also answers this.
  • 400 bank_account_invalid: a bank account that is not this merchant's own.
  • 400 keep_share_invalid: keepShare outside 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 above keep.
  • 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.

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.