← All articles

KuCoin API error 200004 Balance insufficient: fix it in Node.js

KuCoin error 200004 (“Balance insufficient”) usually does not mean the account is empty. It means the account the order draws from has too little available balance. With the kucoin-api Node.js SDK you can see which account holds the funds, move them with one call and retry the order.

Why 200004 appears when you can see funds in the app

KuCoin keeps separate accounts per user. Deposits land in the main (funding) account, while spot orders draw from the trade account. The app shows a combined total, so a balance can look fine while the trade account is at zero. The other common causes are:

  • Funds are held by open orders, so available is lower than balance.
  • The order size plus fees is slightly more than the available amount.
  • A market buy uses size (base currency) when you meant funds (quote currency).

Check balances per account with getBalances()

SpotClient.getBalances() returns one row per account type, with balance, available and holds:

import { SpotClient } from 'kucoin-api';
import { randomUUID } from 'crypto';

const client = new SpotClient({
  apiKey: process.env.KUCOIN_API_KEY!,
  apiSecret: process.env.KUCOIN_API_SECRET!,
  apiPassphrase: process.env.KUCOIN_API_PASSPHRASE!,
});

async function checkBalances(currency: string) {
  const res = await client.getBalances({ currency });
  for (const acc of res.data) {
    console.log(acc.type, 'balance', acc.balance, 'available', acc.available, 'holds', acc.holds);
  }
}

If the main row has the funds and the trade row does not, that is your 200004.

Move funds from main to trade with submitFlexTransfer()

getTransferable() tells you how much can be moved, and submitFlexTransfer() calls KuCoin’s universal transfer endpoint. Use a fresh clientOid for each transfer:

async function moveToTrade(currency: string, amount: string) {
  const transferable = await client.getTransferable({ currency, type: 'MAIN' });
  console.log('transferable from main:', transferable.data.transferable);

  const res = await client.submitFlexTransfer({
    clientOid: randomUUID(),
    type: 'INTERNAL',
    currency,
    amount,
    fromAccountType: 'MAIN',
    toAccountType: 'TRADE',
  });
  console.log('transfer orderId', res.data.orderId);
}

The API key needs the transfer permission for this call. Keep that on a separate key from your order key if you can.

Retry the order with submitHFOrder()

async function placeOrder() {
  const res = await client.submitHFOrder({
    clientOid: randomUUID(),
    symbol: 'BTC-USDT',
    side: 'buy',
    type: 'limit',
    price: '10000',
    size: '0.0001',
  });
  console.log(res.data);
}

async function main() {
  await checkBalances('USDT');
  await moveToTrade('USDT', '5');
  await placeOrder();
}

main().catch(console.error);

Sizes and prices are strings. Round them to the symbol’s baseIncrement and priceIncrement from getSymbol() before sending, or the order fails with a different error.

Checklist when 200004 still appears

  • Compare available, not balance, with the order cost including fees.
  • Cancel or wait for open orders that hold the same currency.
  • For a market buy, send funds in the quote currency instead of size.
  • If your account has moved to KuCoin’s unified trading account, read balances and transfer through the UTA endpoints instead. The SDK exposes those separately.

The KuCoin API JavaScript tutorial covers keys, REST, WebSockets and order flows end to end, and the Siebly SDK docs list every method. kucoin-api comes from the same maintainers as the Binance, Bybit and OKX SDKs, with over 4.5 million npm downloads across 10+ SDKs, with more in the works.