For developers. This page covers the technical integration. For what YaaS is, the model, and how
to apply, see the Yield-as-a-Service overview.
Prerequisites
- Crypto Lending enabled where it runs. Lending is available on the main account with B2B access; on sub-accounts it is not enabled by default — request enablement for each end-user sub-account via the account manager (see the overview). Until it is enabled, the lending endpoints are not available on that sub-account.
- A sub-account per end user, each with its own type:2 API key (info, trading, deposits, withdraws) — type:2 is required to run lending on a sub-account.
- Funds in the main account’s Main balance to allocate to each sub-account.
- HMAC-signed requests — see Authentication.
Integration building blocks
1. Provision a sub-account per end user
Create one sub-account per end user and issue that sub-account a type:2 API key. Sign both requests with the main-account key. Build with Sub-Accounts for account creation and key management, and the Embedded Trading integration guide for the full walkthrough (per-customer keys, KYC URLs).
Only the create response returns the API secret. After a create request without a response, the partner checks the key
list, deletes any key the request created, and creates the key again.
The 14-day deactivation of unused keys applies to sub-account keys too, and any
authenticated request with the key resets the timer. See API key lifecycle.
The partner’s backend enrolls each end user with the sub-account and API key steps of WaaS Wallet creation, plus the deposit-address step where the sub-account takes crypto deposits.
2. Fund the sub-account
Move funds from the main account’s Main balance to the end user’s sub-account with a fee-free transfer, signed with the main-account key. The transfer credits the sub-account’s Main balance, which the first investment draws from. Invest once the amount shows on the sub-account’smain balance and matches the partner’s own record of the transfer.
For a managed sub-account (
shareKyc: false, created with the end user’s email), WhiteBIT refuses the transfer until the end user’s KYC is approved; the refusal names the to field. A sub-account created with shareKyc: true and no email is never refused on this ground.
The transfer request takes no idempotency key, and two identical requests move the funds twice. A 200 response
means WhiteBIT received the request, and the transfer can still fail after the response. After a timeout or a 5xx
response, the transfer can still complete. A record in the transfer history shows that the request was received, not
that the funds moved, so the history does not confirm a transfer.
The sub-account’s own balance confirms a transfer: read main for the ticker on the sub-account. A transfer to the
sub-account raises it by the amount, and a transfer to the main account lowers it. The main account’s balance
changes with transfers to and from every sub-account and does not confirm a single transfer. After a 200, a timeout or a 5xx,
read the sub-account’s main until it shows the transfer, and do not resend while waiting. A transfer that does
not show is a manual check, not an automatic resend.
The caller cannot attach its own reference to a transfer, so an integration stores its own record of each transfer
before the call and compares the sub-account’s main with the amount expected from its records of every movement on
the sub-account, including deposits and withdrawals. Send the next transfer for the same sub-account and ticker only
after the previous one shows.
Read the sub-account’s main balance with POST /api/v4/sub-account/balances, as in WaaS
Crypto purchases with fiat.
For crypto deposits to a sub-account, the partner’s backend polls the deposit history with the sub-account’s key, as in the deposit flow. Webhooks are optional.
3. Offer yield inside the sub-account
Run the Crypto Lending lifecycle — fetch plans, invest, track, withdraw — signed with the sub-account’s own key, so investments and Flex interest stay with that sub-account. The request and response fields are in the Crypto Lending quickstart (Flex) and, for Fixed, in the API reference linked from the Crypto Lending technical overview.The
main-account/ path segment addresses the signing account’s own Main balance — for a
sub-account key, that is the sub-account’s balance, not the main account’s. This is why a sub-account key
runs the lending lifecycle against that end user’s funds.
The partner’s backend places each investment in a flexible or a fixed plan and signs every call with the sub-account’s own key.
4. Reconcile earnings per user
Each sub-account’s investments and payment history are that end user’s earnings. There is no aggregated cross-sub report, so attribution is per sub-account — read each sub-account with its own key. An investment debits the sub-account’s Main balance (see Balances), andPOST /api/v4/sub-account/balances reports only the main, spot and collateral balances. The partner’s backend
reads open investments through the investments endpoints below.
The partner’s backend signs each lending call below with the sub-account’s own key and gets back only that sub-account’s records.
The partner’s backend reconciles each sub-account on a schedule against that end user’s ledger.
5. Redeem investments and pay out
The partner’s backend, signing with the sub-account’s key, withdraws part of a Flex investment or closes it by plan ID, and closes a Fixed investment by investment ID. Early closure of a Fixed investment follows the early-withdrawal terms in Crypto Lending plan types. From the sub-account’s Main balance, the funds follow the WaaS payment and payout flows:- Fiat payout — a transfer to the main account, then a payout from the partner’s own system, as in Crypto sales for fiat.
- Crypto withdrawal — created with the sub-account’s key and confirmed by the main account, as in
Sub-account withdrawal approval. Available where
the account manager has enabled sub-account withdrawals. The sub-account also needs its own withdrawal permission,
withdrawsEnabled. - Payout in another currency — Convert on the sub-account first, as in Conversion.
6. Offboard an end user
Invested funds do not show inPOST /api/v4/sub-account/balances (see
Reconcile earnings per user). Offboarding therefore starts with the sub-account’s
key, before the block refuses that key with 401. The partner’s backend lists and closes every active investment, then follows
End-user offboarding to empty and block the sub-account. The wait for held deposits in that flow reads POST /api/v4/main-account/balance
with the sub-account’s key, so the partner first switches that URL on for the key with
POST /api/v4/sub-account/api-key/edit, as in WaaS Wallet creation. A Fixed
investment closed before maturity follows the early-withdrawal terms in
Crypto Lending plan types. The sub-account’s key creates the final withdrawal
and the main account confirms it, as in
Sub-account withdrawal approval. The final
withdrawal is available where the account manager has enabled sub-account withdrawals. The sub-account also needs its
own withdrawal permission. A later
Delete Sub-Account call is refused while any Flex or Fixed investment
stays active.
Testing
WhiteBIT does not offer a public testnet or sandbox. Test on the live API with minimum amounts, and check available plans and per-plan minimums via the plans endpoints first.Reference
- Sub-Accounts — create and manage per-user accounts and keys.
- Crypto Lending — Fixed and Flex plan mechanics, supported assets, and the full endpoint reference.
- Crypto Lending quickstart — the invest, track, and withdraw lifecycle.
What’s next
FAQ
How B2B yield differs from the single-account flow.
Crypto Lending
Plan mechanics, supported assets, and the endpoint reference.
Sub-Accounts
Create and manage the per-user accounts this program provisions.