Balance Service
redeem_code flows
How admins issue one-time redeem_code credits and how users redeem them directly into balance.
Use redeem_code when you need:
- promotional credits
- manual compensation
- one-time gift codes
The difference from topup is simple:
topupmeans "create first, confirm later"redeem_codemeans "user enters a code and balance is credited immediately"
Create a redeem_code from the trusted side
const issued = await admin.balance.redeemCodes.create({
amount: 500,
note: "launch gift",
});The result includes:
redeem_code_idamountunitstatuscodecode_mask
Important:
codeplaintext is returned only once at creation time- list APIs only return
code_mask
Redeem from the user side
const result = await user.service("balance").action("redeem-codes/redeem").invoke({
code: "ABCD-EFGH-JKLM-NPQR",
});On success the service will:
- mark the
redeem_codeasredeemed - credit the current user balance immediately
- write a
redeemledger entry
List and disable on the trusted side
List:
const items = await admin.balance.redeemCodes.list({
status: "active",
});Disable:
await admin.balance.redeemCodes.disable({
redeem_code_id: issued.redeem_code_id,
note: "expired",
});A disabled redeem_code can no longer be redeemed.
When to choose redeem_code vs topup
Choose redeem_code when:
- you want a human-entered gift code
- you do not depend on payment callbacks
- you want immediate credit on successful validation
Choose topup when:
- you need an order first
- you wait for a payment platform or admin confirmation
- you want recharge initiation and credit confirmation to stay separate
Common endpoints
POST /v1/balance/redeem-codes/redeemGET /v1/balance/redeem-codesPOST /v1/balance/redeem-codes/createPOST /v1/balance/redeem-codes/disable