Nice Paydocs API version 2026-12-01 OpenAPI

Payouts

A payout sends money from your balance to your customer: a player's withdrawal.

Create one

POST /v1/payoutsReference

A key with payouts:write always has an IP allowlist; use an Ed25519 key for it if you can.

Request

FieldNotes
merchant_payout_idyour withdrawal id: 1 to 64 characters of A–Z a–z 0–9 _ . : -; unique per project forever
amount, currency"5000.00", "INR" (USDT methods take "USDT")
methodupi, bank_transfer, usdt_trc20, usdt_bep20
destinationupi: { vpa, holder_name } · bank_transfer: { account_number, ifsc, holder_name } · USDT: { address }
customer.refoptional, your customer's id
risk_hintsoptional facts only you know (customer_age_days, lifetime_deposits, lifetime_withdrawals, kyc_level, flags). They can raise scrutiny; they never lower a limit
metadataoptional, up to 20 keys with string values

Destinations are checked strictly — IFSC format, VPA format, address checksum for the stated chain. A Tron address on a BNB Smart Chain payout is refused, never guessed.

Response

201 with the payout, in status queued. The amount plus fee is reserved from your available balance at that moment. destination comes back masked.

Errors

CodeWhen
402 insufficient_balancethe available balance is lower than the amount plus fee
422 invalid_destinationthe destination is malformed or does not match the method
409 duplicate_merchant_referencea payout with this merchant_payout_id exists; existing_id is its id
403 merchant_not_activeyour account is frozen or closed
400 invalid_requesta field is wrong; errors names it

Nothing is created and nothing is reserved when a request is refused.

Example

runs in CI samples/ts/payouts.ts samples/php/payouts.php
// Payouts: pay a player's withdrawal exactly once, and never guess at an unknown outcome.
//   bun payouts.ts WD-99120
import { NicePay, NicePayConnectionError, NicePayError, type Payout } 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 withdrawalId = process.argv[2] ?? `WD-${String(Date.now())}`;

let payout: Payout;
try {
  payout = await nicepay.createPayout(
    {
      merchant_payout_id: withdrawalId, // your withdrawal id: unique forever
      amount: "1000.00",
      currency: "INR",
      method: "upi",
      destination: { vpa: "ramesh@okhdfc", holder_name: "Ramesh Kumar" },
      customer: { ref: "player-7591035" },
    },
    { idempotencyKey: withdrawalId }, // and the idempotency key: a retry never pays twice
  );
} catch (error) {
  if (error instanceof NicePayConnectionError && error.outcomeUnknown) {
    // We do not know whether Nice Pay received it. Keep the withdrawal "processing" on
    // your side and send the same call again later with the same key. Never pay the
    // player another way and never put the money back on a guess.
    console.log(`unknown outcome for ${withdrawalId}: retry later with the same idempotency key`);
    process.exit(1);
  }
  if (error instanceof NicePayError && error.code === "insufficient_balance") {
    console.log("not enough available balance: nothing was created");
    process.exit(1);
  }
  throw error;
}
console.log(`payout ${payout.id}: ${payout.status}, fee ${payout.fee}, to ${payout.destination.masked}`);

// Test mode only: the bank pays it.
await nicepay.simulatePayout(payout.id, { action: "succeed" });

for (let i = 0; i < 30; i += 1) {
  const now = await nicepay.getPayout(payout.id);
  // processing / sent: the money may be on its way — never pay the player again.
  if (now.status === "succeeded" || now.status === "failed" || now.status === "cancelled" || now.status === "reversed") {
    console.log(`final: ${now.status}, reference ${String(now.reference)}`);
    process.exit(0);
  }
  await new Promise((resolve) => setTimeout(resolve, 1000));
}
throw new Error("the payout did not finish within 30 seconds");

Statuses

Text
queued ──► processing ──► sent ──► succeeded ──► reversed   (paid, later returned by the bank)
   │            │           │
   │            └───────────┴────► failed                   (amount and fee released back to you)
   └──► cancelled

queued waitingprocessing in progresssent in progresssucceeded finished wellfailed went wrongcancelled overreversed needs a look

Mistakes that lose money