Settlements and balances
Your balance is what we hold for you. A settlement moves part of it to a bank account or USDT address of yours.
Balances
GET/v1/balances (scope balances:read) gives one balance per currency: total, and how much of it you can spend (available) and cannot spend yet (frozen). Show total as your balance at Nice Pay, available as what you can pay out now and frozen as what is on its way or on hold:
total = available + frozen − debt
frozen = pending + reserved + heldUSDT is one balance across both chains (by_chain only tells where it came in or went out).
- total — everything we hold for you in that currency. It is a signed amount: negative only when you owe Nice Pay more than it holds;
- available — yours to pay out or settle;
- frozen — yours, counted in
total, but not spendable yet. It is exactly the three parts below: - pending — credited but not yet released to available;
- reserved — set aside for your payouts and settlements on their way (amount plus fee), until each one ends;
- held — put on hold by Nice Pay, with a reason. It is still your money, but it cannot be paid out or settled until the hold is released.
holdslists each hold that makes upheld: itsid,amount,placed_atandcomment— why it is held, in plain text. - debt — what you owe Nice Pay: a payout Nice Pay paid into a negative balance for you, or a credit taken back that your balance could not cover. Money arriving repays it first;
- net —
available−debt, negative when you owe more than you can spend; - unfunded_payouts — amount plus fee of your payouts waiting for funds;
- projected —
net−unfunded_payouts: where you stand once the waiting payouts are paid.
A settlement needs the money to be available now: it never waits for funds and is refused with 402 insufficient_balance when the balance is short.
- by_chain (USDT only) —
totalsplit by the chain each amount came in or went out on:[{ "chain": "bsc", "amount": "…" }, { "chain": "tron", "amount": "…" }]. Every pay-in, payout, settlement and fee takes the chain of its rail; an entry Nice Pay makes with no rail names one. USDT is still one balance — a payout on either chain spends it — so one chain may be negative while the total is positive (collected on TRC20, paid out on BEP20). The amounts always add up tototal.
A hold is one item: it is never merged with another or released in part. When it is released, exactly its amount returns to available. If you have a question about a hold, quote its id to your account manager.
Every movement is a balance transaction (GET/v1/balance-transactions): the ledger entries of your account, newest first, cursor-paged. Use them to reconcile — they add up to your balance exactly. account says which balance an entry is on (available, pending, reserved, held, debt).
Three types carry a note written for you, and null everywhere else: hold.place (why an amount was put on hold: one entry out of available, one into held), hold.release (why it was released: the same amount back) and balance.recover (an amount Nice Pay took back from your balance or from a hold, with the reason).
samples/ts/balances.ts// Balances and the statement: reconcile your books against every ledger entry.
import { nicepay } from "./nicepay.ts";
interface Balance {
readonly currency: string;
readonly available: string;
readonly pending: string;
readonly reserved: string;
readonly held: string;
readonly holds: readonly { readonly id: string; readonly amount: string; readonly comment: string; readonly placed_at: string }[];
}
interface Entry {
readonly id: string;
readonly account: string;
readonly amount: string;
readonly currency: string;
}
// Money is added up as whole minor units (paise for INR, millionths for USDT) in a
// bigint — never as floating-point numbers: 0.1 + 0.2 is not 0.3.
function decimalPlaces(currency: string): number {
if (currency === "INR") return 2;
if (currency === "USDT") return 6;
throw new TypeError(`unknown currency: ${currency}`);
}
function toMinor(amount: string, currency: string): bigint {
const decimals = decimalPlaces(currency);
const m = /^(-?)(\d+)(?:\.(\d+))?$/.exec(amount);
if (!m || (m[3] ?? "").length > decimals) throw new TypeError(`not an amount in ${currency}: ${amount}`);
const minor = BigInt(m[2] ?? "0") * 10n ** BigInt(decimals) + BigInt((m[3] ?? "").padEnd(decimals, "0"));
return m[1] === "-" ? -minor : minor;
}
function fromMinor(minor: bigint, currency: string): string {
const decimals = decimalPlaces(currency);
const abs = minor < 0n ? -minor : minor;
const unit = 10n ** BigInt(decimals);
return `${minor < 0n ? "-" : ""}${String(abs / unit)}.${String(abs % unit).padStart(decimals, "0")}`;
}
const balances = await nicepay<{ data: Balance[] }>("GET", "/v1/balances");
for (const b of balances.data) {
console.log(`${b.currency}: available ${b.available}, pending ${b.pending}, reserved ${b.reserved}, held ${b.held}`);
// Each hold is its own item, with the reason it was placed.
for (const h of b.holds) console.log(` on hold ${h.amount} since ${h.placed_at}: ${h.comment} (${h.id})`);
}
// Every entry, page by page (newest first).
const entries: Entry[] = [];
let startingAfter: string | undefined;
for (;;) {
const page = await nicepay<{ data: Entry[]; has_more: boolean }>("GET", "/v1/balance-transactions", { query: { currency: "INR", limit: 100, starting_after: startingAfter } });
entries.push(...page.data);
if (!page.has_more) break;
startingAfter = page.data.at(-1)?.id;
}
let available = 0n;
for (const e of entries) if (e.account === "available") available += toMinor(e.amount, e.currency);
const inr = balances.data.find((b) => b.currency === "INR");
console.log(`${String(entries.length)} entries; available entries sum to ${fromMinor(available, "INR")} (balance ${String(inr?.available)})`);The statement of a day
GET/v1/statements?day=YYYY-MM-DD (scope balances:read) gives one business day — in Nice Pay's zone (timezone, Asia/Kolkata), the same day boundary as our daily close — per currency, and per chain for USDT (by_chain):
| Field | Meaning |
|---|---|
opening | what we held for you when the day began |
money_in | pay-ins and top-ups received, before their fees |
money_out | payouts and settlements sent (their amounts; a payout sent back is subtracted) |
fees | the fees on that day's money in and out |
adjustments | reversals, recoveries, openings and other entries made by Nice Pay |
late | entries dated an earlier day that reached the books after we closed that day |
closing | opening + money_in − money_out − fees + adjustments + late |
final is true once our close of that day is signed: from then on the figures never change, and anything dated that day which arrives later shows on a later day as late. A day still open, and every test-mode day, is final: false. A day in the future, or not a calendar day, is 400 invalid_request.
Settle your balance
A settlement moves available balance to a bank account (or USDT address) of yours.
POST /v1/settlementsReference
- Scope:
settlements:write Idempotency-Keyrequired — use your own id- Success: HTTP 201
| Field | Notes |
|---|---|
amount, currency | "25000.00", "INR" |
destination_id | one of your destinations, from GET/v1/settlement-destinations |
outside_hours_ack | optional: true once whoever asked has read the outside-working-hours warning (below) |
- A key with
settlements:writealways has an IP allowlist. - Destinations are added in the merchant portal, by a team member with a fresh second factor — never through the API — and can be used only after a cooling-off period.
GET/v1/settlement-destinationslists them withusableandusable_after. - A settlement to a USDT destination costs what a USDT payout costs: 1 % plus 2.50 USDT on TRC20 or 0.50 USDT on BEP20, unless agreed otherwise. Its
feeis on the answer. - The answer is
201with the settlement. The amount plus fee is reserved at once;402 insufficient_balance,422 invalid_destination(a destination that is not yours, or still in its cooling-off period) and403 merchant_not_active(your account is frozen or closed) create nothing. - Working hours: 09:00–18:00 IST. Outside them a settlement is refused with
409 outside_working_hoursand nothing is created. Itsdetailis the warning to show whoever asked — "This is not working hours. The payment gets delayed, and it can cause deviation in treasury calculations if it's not settled today." — andworking_hoursandtimezonesay when the hours are. If they still want it, send the same request again with"outside_hours_ack": true; it then goes ahead as usual. Inside the hours the field is not needed and changes nothing. - Paid by itself, or approved first. A settlement up to the automatic limit (₹1,00,000 unless agreed otherwise) is sent for paying at once; a larger one, and every USDT settlement unless agreed otherwise, waits for Nice Pay to approve it. The answer's
statussays which:approved(sent for paying) orrequested(waiting). - Then it is paid; you get
settlement.approved,settlement.paid,settlement.completed— orsettlement.rejected, and the reserve comes back. Each event carries the settlement asGET/v1/settlements/{id}returns it, with itsst_…id. - Settlements recorded by our staff for a manual USDT settlement appear in the same list with
method: "manual_usdt",usdt_amount,rateandtx_hash; they cannot be created by API. initiated_bysays who started a settlement:merchant(you), orplatform— Nice Pay settled your available balance to one of your own registered destinations. It is paid and reported like any other settlement, with the same events.
samples/ts/settlements.ts samples/php/settlements.php// Settlements: move your available balance to a bank account registered in the portal.
// bun settlements.ts 2500.00
import { nicepay } from "./nicepay.ts";
interface Settlement {
readonly id: string;
readonly status: string;
readonly fee: string;
}
const amount = process.argv[2] ?? "2500.00";
// Destinations are added in the merchant portal (with a second factor), never by API,
// and can be used only after their cooling-off period.
const destinations = await nicepay<{ data: { id: string; usable: boolean; masked: string }[] }>("GET", "/v1/settlement-destinations");
const usable = destinations.data.find((d) => d.usable);
if (!usable) throw new Error("no destination is past its cooling-off period yet");
const balances = await nicepay<{ data: { currency: string; available: string }[] }>("GET", "/v1/balances");
const inr = balances.data.find((b) => b.currency === "INR");
console.log(`available ${String(inr?.available)} INR; settling ${amount} to ${usable.masked}`);
// One settlement per request id of yours: a retry returns the same settlement.
const requestId = `SETTLE-${new Date().toISOString().slice(0, 10)}-${amount}`;
const settlement = await nicepay<Settlement>("POST", "/v1/settlements", { body: { amount, currency: "INR", destination_id: usable.id }, idempotencyKey: requestId });
console.log(`settlement ${settlement.id}: ${settlement.status}, fee ${settlement.fee}`);
const again = await nicepay<Settlement>("GET", `/v1/settlements/${settlement.id}`);
const listed = await nicepay<{ data: Settlement[] }>("GET", "/v1/settlements", { query: { limit: 10 } });
console.log(`listed: ${String(listed.data.some((s) => s.id === again.id))}`);<?php
// Move available balance to your bank account (registered in the portal).
// php settlements.php 1500.00
declare(strict_types=1);
require __DIR__ . '/nicepay.php';
$amount = $argv[1] ?? '1500.00';
$destinations = nicepay('GET', '/v1/settlement-destinations');
$usable = array_values(array_filter($destinations['data'], static fn (array $d): bool => $d['usable']));
if ($usable === []) {
throw new RuntimeException('no destination is past its cooling-off period yet');
}
$requestId = 'SETTLE-' . gmdate('Y-m-d') . '-' . $amount; // one settlement per request of yours
$settlement = nicepay('POST', '/v1/settlements', [
'body' => ['amount' => $amount, 'currency' => 'INR', 'destination_id' => $usable[0]['id']],
'idempotency_key' => $requestId,
]);
echo "settlement {$settlement['id']}: {$settlement['status']}, {$settlement['amount']} + fee {$settlement['fee']} to {$settlement['destination']['masked']}\n";Top-ups
If you prefund your balance (bank transfer, or USDT to your project's top-up address from GET/v1/topup-addresses), each top-up appears in GET/v1/topups, raises topup.succeeded, and shows as a balance transaction of type topup.
Mistakes that lose money
- Settling with a random idempotency key on each retry: use one id per settlement request of yours.
- Reconciling with floating-point sums. Add amounts as integers in minor units, as the balances example above does.