Batch Create Discount Code

🔒

Requires write_price_rules access scope. More access scope

The Batch Create Discount Code API creates multiple discount codes associated with a specific price rule in a single API call. This bulk operation allows merchants to efficiently generate large numbers of discount codes for marketing campaigns, promotions, or special events.

This API is particularly useful for:

  1. Generating hundreds or thousands of codes for large-scale promotions
  2. Creating codes for segmented marketing campaigns (email lists, social media channels)
  3. Setting up automated discount code generation for partner programs

Request Parameters

Public Request Parameters

📘

Path Parameters

ParameterTypeRequiredDescriptionExample
price_rule_idstringYesPrice rule IDpr_123456

Body Parameters

ParameterTypeRequiredDescriptionExample
discount_codesobjectYesThe discount code configuration object{...}
discount_codes[].codestringYesThe actual discount code text (must be unique)SUMMER20
discount_codes[].use_with_otherint32NoWhether the code can be used with other discounts (1=yes, 0=no)1
discount_codes[].usage_limitint32NoMaximum number of times the code can be used100

Response Explanation

Public Response Parameters

📘

Successful Response

ParameterTypeExampleDescription
codestring200Error code (200 indicates success)
messagestringSuccessError message
dataobject{...}Contains the price rules data
data.discount_codesarray of objects[ {...}, {...} ]List of discount code objects

Discount Code Object Structure

ParameterTypeExampleDescription
idstringdc_123456Unique identifier of the discount code
price_rule_idstringpr_123456ID of the associated price rule
codestringSUMMER20The actual discount code text
created_atstring2023-06-20T15:30:00ZTimestamp when the discount code was created
updated_atstring2023-06-21T09:15:00ZTimestamp when the discount code was last updated
use_with_otherint321Whether the code can be used with other discounts (1=yes, 0=no)
usage_countint3242Number of times the discount code has been used

Error Response

FieldTypeExampleDescription
codestringInvalidParameterError http message
messagestring``Error message

API Structure Overview

Language
Credentials
Header
URL
Click Try It! to start a request and see the response here!