Payouts
A payout sends money from your balance to your customer: a player's withdrawal.
Create one
POST /v1/payoutsReference
- Scope:
payouts:write Idempotency-Keyrequired — use your own id- Success: HTTP 201
A key with payouts:write always has an IP allowlist; use an Ed25519 key for it if you can.
Request
| Field | Notes |
|---|---|
merchant_payout_id | your 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") |
method | upi, bank_transfer, usdt_trc20, usdt_bep20. A payout never names a channel: Nice Pay chooses. upi only when UPI payouts are on for your account |
destination | upi: { vpa, holder_name } · bank_transfer: { account_number, ifsc, holder_name } · USDT: { address } |
customer.ref | optional, your customer's id |
customer.name, customer.phone, customer.email | optional, your customer's name, mobile number and e-mail. Some channels need the mobile (and an e-mail, formed from customer.ref when you send none): a payout without a mobile is never sent to them — another of your routes takes it, or it waits until one can. Send them whenever you have them; they are never returned. The pay-ins page has the details |
risk_hints | deprecated and ignored: player risk is yours, and Nice Pay does not score payouts. Still accepted for one release; stop sending it |
metadata | optional, up to 20 keys with string values |
description | optional: why — e.g. "player withdrawal 4711" (at most 200 characters); shown on the payment, in exports and in its payment record |
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. destination comes back masked.
funding: "funded"— the amount plusfeeis reserved from your available balance at that moment.funding: "unfunded"— your balance could not cover it (or older payouts are waiting ahead of it). It is kept with nothing reserved, and goes on by itself, oldest first, as soon as money arrives. If nobody funds it within 24 hours it fails withfailure_reason: negative_balance. Nice Pay may pay it into a negative balance; your balance then shows adebt. Your balance'sunfunded_payoutsandprojectedshow what waits.
Errors
| Code | When |
|---|---|
422 invalid_destination | the destination is malformed or does not match the method |
409 duplicate_merchant_reference | a payout with this merchant_payout_id exists; existing_id is its id |
403 merchant_not_active | your account is frozen or closed |
422 amount_too_small | (live mode) the amount is below your smallest payout in that currency; min_amount and max_amount give your range |
403 limit_exceeded | (live mode) the amount is above your largest payout: limit is amount_max, with min_amount and max_amount |
422 method_not_available | the method is not priced for your project; a upi payout while UPI payouts are off for your account (live mode: only the UPI channel or a Nice Pay desk pays UPI IDs — send it as bank_transfer); or Nice Pay has switched that currency off for you (live mode): switched_off is fiat (INR) or crypto (USDT) |
400 invalid_request | a field is wrong; errors names it |
Nothing is created and nothing is reserved when a request is refused. A short balance is not a refusal: the payout is created unfunded.
Your limits are the same as for pay-ins: unless agreed otherwise ₹300 to ₹20,000 and 5 to 50,000 USDT per payout, in live mode (your limits). A payout created while its currency was on and switched off before Nice Pay starts on it waits for a person at Nice Pay (held), who sends it on or rejects it (the amount and fee come back to you once). A USDT payout's fee is 1 % plus a flat amount per chain (0.50 USDT on BEP20, 2.50 USDT on TRC20) unless agreed otherwise; GET/v1/methods gives yours.
Example
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, NicePayError, NoAnswerError } from "./nicepay.ts";
interface Payout {
readonly id: string;
readonly status: string;
readonly fee: string;
readonly reference: string | null;
readonly destination: { readonly masked: string };
}
const withdrawalId = process.argv[2] ?? `WD-${String(Date.now())}`;
let payout: Payout;
try {
payout = await nicepay<Payout>("POST", "/v1/payouts", {
body: {
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 NoAnswerError && 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("POST", `/v1/test/payouts/${payout.id}/simulate`, { body: { action: "succeed" } });
for (let i = 0; i < 30; i += 1) {
const now = await nicepay<Payout>("GET", `/v1/payouts/${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");<?php
// A player's withdrawal, paid exactly once — and never guessed at when the outcome is unknown.
// php payouts.php WD-99120
declare(strict_types=1);
require __DIR__ . '/nicepay.php';
$withdrawalId = $argv[1] ?? 'WD-' . time();
try {
$payout = nicepay('POST', '/v1/payouts', [
'body' => [
'merchant_payout_id' => $withdrawalId, // your withdrawal id: unique forever
'amount' => '1000.00',
'currency' => 'INR',
'method' => 'bank_transfer',
'destination' => ['account_number' => '50100012345678', 'ifsc' => 'HDFC0001234', 'holder_name' => 'Ramesh Kumar'],
'customer' => ['ref' => 'player-7591035'],
],
'idempotency_key' => $withdrawalId, // and the idempotency key: a retry never pays twice
]);
} catch (NicePayNoAnswer $e) {
if ($e->outcomeUnknown) {
// We do not know whether Nice Pay received it. Keep the withdrawal "processing" on
// your side; send the same call later with the same key. Never refund on a guess.
echo "unknown outcome for {$withdrawalId}: retry later with the same idempotency key\n";
exit(1);
}
throw $e;
} catch (NicePayError $e) {
if ($e->errorCode === 'insufficient_balance') {
echo "not enough available balance: nothing was created\n";
exit(1);
}
throw $e;
}
echo "payout {$payout['id']}: {$payout['status']}, fee {$payout['fee']}, to {$payout['destination']['masked']}\n";
// Test mode only: the bank pays it.
nicepay('POST', "/v1/test/payouts/{$payout['id']}/simulate", ['body' => ['action' => 'succeed']]);
for ($i = 0; $i < 30; $i++) {
$now = nicepay('GET', "/v1/payouts/{$payout['id']}");
// processing / sent: the money may be on its way — never pay the player again.
if (in_array($now['status'], ['succeeded', 'failed', 'cancelled', 'reversed'], true)) {
echo "final: {$now['status']}, reference {$now['reference']}\n";
exit(0);
}
sleep(1);
}
throw new RuntimeException('the payout did not finish within 30 seconds');Statuses
queued ──► processing ──► sent ──► succeeded ──► reversed (paid, later returned by the bank)
│ │ │
│ └───────────┴────► failed (amount and fee released back to you)
└──► cancelledqueued waitingprocessing in progresssent in progresssucceeded finished wellfailed went wrongcancelled overreversed needs a look
queued: accepted, not yet sent — reserved (funding: funded) or waiting for your balance (funding: unfunded). A queued payout can also go straight tosentor tofailed.sent: handed to the bank or the chain, not yet final. If the transfer proves not to have happened, the payout isprocessingagain.succeeded: paid.reversedcan follow only this status.held: true— Nice Pay holds the payout for a person: an amount above what it pays without a person, one of its own safety stops, or an outcome being confirmed. It is still on its way;under_reviewhas the same value and is deprecated.processing— and"held": true— means it may be on its way or its outcome is being confirmed. We never refund or resend an ambiguous payout automatically; our staff resolve it. Treatprocessingas "do not pay this customer again".referencecarries the bank reference (UTR) or transaction hash once known.failed: not paid; the amount and fee are back in your available balance.failure_reasonsays why (below).
Find payouts
GET/v1/payins and GET/v1/payouts list yours, newest first, 100 at most per page (limit, starting_after). Filters, all optional and combined:
| Filter | Matches |
|---|---|
customer_ref | your customer's reference |
reference | exactly one reference: a UTR or bank reference (spaces and case ignored) or a transaction hash |
method, status, currency | as on the object |
created_from, created_to | an ISO 8601 instant with its offset, both inclusive |
amount_min, amount_max | an amount in currency (required with them) |
legacy_id, imported | payments imported from your previous system, by their old id; imported=true, false or both (the default) |
Why a payout was not paid
Every failed or cancelled payout, and its payout.failed event, carries failure_reason:
| Value | Meaning |
|---|---|
expired | nothing had started paying it within your expiry hours (24 unless agreed otherwise), counted from your request |
cancelled_by_merchant | you cancelled it |
cannot_pay | the desk it was given could not pay it |
destination_rejected | Nice Pay ended it: the destination was refused |
rail_closed | Nice Pay ended it: the rail is closed |
provider_refused | the gateway or the chain refused or failed the transfer |
rejected_by_staff | Nice Pay staff ended it |
timed_out_by_staff | Nice Pay's withdrawal timeout ended it |
negative_balance | it waited for funds and was not funded in time |
Refund your customer once on any of them. There is no separate "expired" event: an expired payout is payout.failed with failure_reason: expired.
Its record
GET/v1/payouts/{id} also gives the payout's timeline — every step, oldest first: requested, funded, admitted or held, approved, assigned (a gateway, a Nice Pay desk or the chain executor), sent_to_provider, provider_answered, paid, completed, failed, cancelled or reversed, each with its time and, where there is one, why — and durations: seconds_to_assign, seconds_at_processor and seconds_total. Nice Pay staff are never named. The list does not carry them. GET/v1/payins/{id} gives durations.seconds_to_receive; a USDT pay-in names each transfer's from_address, and an INR pay-in its payer (masked) when the gateway or desk reports it. The merchant portal downloads a payment's whole record as a file.
Cancel one
POST /v1/payouts/{id}/cancelReference
- Scope:
payouts:write - Success: HTTP 200
You can cancel a payout while nothing has started paying it — it may already be processing, waiting for a desk.
| Answer | When |
|---|---|
200, status: cancelled, failure_reason: cancelled_by_merchant | it was cancelled; the amount and fee are back in your available balance. Cancelling it again answers the same |
409 payout_in_progress | a desk, a gateway or the chain holds it, it was sent, or its outcome is being checked: it cannot be cancelled and ends with its real outcome. Do not refund on this answer |
409 invalid_state | it already ended another way: read it back for its status |
Mistakes that lose money
- Paying the customer a second time (another payout, or manually) while the first is
processingorsent. - A new
merchant_payout_idfor a retry of the same withdrawal: that is a second payout. Retry with the same id and idempotency key. - Treating a timeout — an unanswered request,
outcomeUnknownin the examples — as failed (idempotency). - Giving the money back to the player's wallet on
payout.processing; onlypayout.failedmeans it was not paid.
Imported payouts
If your platform moved to Nice Pay from its own payment system, its past payouts may have been imported so you can find them here. They come back from the same endpoints with imported: true and legacy_id (your old system's id); every payout made at Nice Pay has imported: false and legacy_id: null. An imported payout moved no money at Nice Pay: no balance, no event. fee is 0.00; amount is null only when your old system never recorded the USDT actually sent. Any write request on one (cancel, reference, check) answers 409 imported_record.