Skip to main content
POST
/
merchant
/
discount
/
batch
/
children
/
generate
Generate Batch Child Codes
curl --request POST \
  --url https://api.unibee.dev/merchant/discount/batch/children/generate \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "codeLength": 123,
  "isAsync": true,
  "quantity": 123,
  "randomStyle": "<string>",
  "templateCode": "<string>",
  "templateId": 123
}
'
{
  "code": 123,
  "data": {
    "existingCount": 123,
    "failedCount": 123,
    "generatedCount": 123,
    "isAsync": true,
    "successCount": 123,
    "templateCode": "<string>",
    "templateId": 123,
    "totalTarget": 123
  },
  "merchantId": 123,
  "message": "<string>",
  "redirect": "<string>",
  "requestId": "<string>"
}

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>