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, per currency:
- available — yours to pay out or settle;
- pending — credited but not yet released to available;
- reserved — held for payouts and settlements on their way;
- 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.
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, Money, type BalanceTransaction } from "@nicepay/sdk-ts";
const nicepay = new NicePay({
keyId: process.env["NICEPAY_KEY_ID"] ?? "",
secret: process.env["NICEPAY_KEY_SECRET"] ?? "",
...(process.env["NICEPAY_API_BASE"] ? { baseUrl: process.env["NICEPAY_API_BASE"] } : {}),
});
const balances = await nicepay.getBalances();
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). Add them up with Money — never with floats.
const entries: BalanceTransaction[] = [];
let startingAfter: string | undefined;
for (;;) {
const page = await nicepay.listBalanceTransactions({ currency: "INR", limit: 100, ...(startingAfter ? { starting_after: startingAfter } : {}) });
entries.push(...page.data);
if (!page.has_more) break;
startingAfter = page.data.at(-1)?.id;
}
let available = Money.of("0", "INR");
for (const e of entries) if (e.account === "available") available = available.add(Money.of(e.amount, e.currency));
const inr = balances.data.find((b) => b.currency === "INR");
console.log(`${String(entries.length)} entries; available entries sum to ${available.toString()} (balance ${String(inr?.available)})`);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- SDK:
createSettlement() - Success: HTTP 201
| Field | Notes |
|---|---|
amount, currency | "25000.00", "INR" |
destination_id | one of your destinations, from GET/v1/settlement-destinations |
- 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. - 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. - Our finance team approves and pays it; 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/sdk-ts";
const nicepay = new NicePay({
keyId: process.env["NICEPAY_KEY_ID"] ?? "",
secret: process.env["NICEPAY_KEY_SECRET"] ?? "",
...(process.env["NICEPAY_API_BASE"] ? { baseUrl: process.env["NICEPAY_API_BASE"] } : {}),
});
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.listSettlementDestinations();
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.getBalances();
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.createSettlement({ amount, currency: "INR", destination_id: usable.id }, { idempotencyKey: requestId });
console.log(`settlement ${settlement.id}: ${settlement.status}, fee ${settlement.fee}`);
const again = await nicepay.getSettlement(settlement.id);
console.log(`listed: ${String((await nicepay.listSettlements({ limit: 10 })).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 'vendor/autoload.php';
$config = ['key_id' => getenv('NICEPAY_KEY_ID') ?: '', 'secret' => getenv('NICEPAY_KEY_SECRET') ?: ''];
if (getenv('NICEPAY_API_BASE')) {
$config['base_url'] = getenv('NICEPAY_API_BASE');
}
$nicepay = new NicePay\Client($config);
$amount = $argv[1] ?? '1500.00';
$usable = array_values(array_filter($nicepay->listSettlementDestinations()['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->createSettlement(['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 (the SDKs'
Money).