Nice Paydocs API version 2026-12-01 OpenAPI

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:

Text
total = available + frozen − debt
frozen = pending + reserved + held

USDT is one balance across both chains (by_chain only tells where it came in or went out).

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.

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).

runs in CI 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):

FieldMeaning
openingwhat we held for you when the day began
money_inpay-ins and top-ups received, before their fees
money_outpayouts and settlements sent (their amounts; a payout sent back is subtracted)
feesthe fees on that day's money in and out
adjustmentsreversals, recoveries, openings and other entries made by Nice Pay
lateentries dated an earlier day that reached the books after we closed that day
closingopening + 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

FieldNotes
amount, currency"25000.00", "INR"
destination_idone of your destinations, from GET/v1/settlement-destinations
outside_hours_ackoptional: true once whoever asked has read the outside-working-hours warning (below)
runs in CI 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))}`);

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