Skip to main content
POST
Generate Batch Child Codes

Endpoint Overview

POST https://api.unibee.dev/merchant/discount/batch/children/generate Generate child codes for a batch template. Template must be in active status. Supports initial generation, retry on failure, and incremental expansion. Either templateId or templateCode must be provided. If quantity > 1000, isAsync must be set to true. Default is synchronous execution.

Authorization

All UniBee Merchant API requests require authentication via API key.

Parameters

Parameters for this endpoint are listed below. The schema is also shown in the Try it panel.

Request body


Request examples

cURL

Sandbox


Response

Success responses return a JSON envelope with code, data, message, redirect, and requestId. code 0 indicates success.

Error handling

When code in the response body is non-zero, check message for details. Use requestId when contacting support.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

Generate child codes for a batch template. Template must be in active status. Supports initial generation, retry on failure, and incremental expansion. Either templateId or templateCode must be provided. If quantity > 1000, isAsync must be set to true. Default is synchronous execution.

codeLength
integer<*int>

Optional. Total length of generated child code (prefix + random part). Must be > len(templateCode) and <= 190. The random part length must be sufficient to support the template's target quantity.

isAsync
boolean<*bool>

Force async execution. Default is false (synchronous). If quantity > 1000, this must be set to true.

quantity
integer<*int64>

Number of child codes to generate. If not provided, generates up to the template's quantity limit minus existing count. Must not exceed the remaining available quantity.

randomStyle
string<*string>

Optional. Random part style: auto|numeric|lower|upper. Default is auto, which infers style from templateCode: all digits -> numeric, all lowercase (with optional digits) -> lower, otherwise upper.

templateCode
string<string>

The template's code prefix (alternative to templateId)

templateId
integer<*int64>

The template's Id (alternative to templateCode)

Response

200 - application/json
code
integer<int>
data
object
merchantId
integer<int64>
message
string<string>
redirect
string<string>
requestId
string<string>