post
https://{subdomain}.myshoplaza.com/openapi/2025-06/price_rules//discount_codes
Allows you to create a unique discount code associated with a specific price rule.
Requireswrite_price_rulesaccess scope. More access scope
The Create Discount Code API allows you to create a unique discount code associated with a specific price rule.
This API is especially useful for:
- Generating custom discount codes for promotional campaigns.
- Associating discount codes with predefined price rules.
- Managing discount-specific details like usage and restrictions.
Request Parameters
Public Request Parameters
Path Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
price_rule_id | string | Yes | Price rule ID | pr_123456 |
Body Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
discount_code | object | Yes | The discount code configuration object | {...} |
discount_code.code | string | Yes | The actual discount code text (must be unique) | SUMMER20 |
discount_code.use_with_other | int32 | No | Whether the code can be used with other discounts (1=yes, 0=no) | 1 |
discount_code.usage_limit | int32 | No | Maximum number of times the code can be used | 100 |
Response Explanation
Public Response Parameters
Successful Response
| Parameter | Type | Example | Description |
|---|---|---|---|
code | string | 200 | Error code (200 indicates success) |
message | string | Success | Error message |
data | object | {...} | Contains the price rules data |
data.discount_codes | array of objects | [ {...}, {...} ] | List of discount code objects |
Discount Code Object Structure
| Parameter | Type | Example | Description |
|---|---|---|---|
id | string | dc_123456 | Unique identifier of the discount code |
price_rule_id | string | pr_123456 | ID of the associated price rule |
code | string | SUMMER20 | The actual discount code text |
created_at | string | 2023-06-20T15:30:00Z | Timestamp when the discount code was created |
updated_at | string | 2023-06-21T09:15:00Z | Timestamp when the discount code was last updated |
use_with_other | int32 | 1 | Whether the code can be used with other discounts (1=yes, 0=no) |
usage_count | int32 | 42 | Number of times the discount code has been used |
Error Response
| Field | Type | Example | Description |
|---|---|---|---|
code | string | InvalidParameter | Error http message |
message | string | `` | Error message |
