Closed Beta ProgramsPromotions UpdatesAPI ReferenceCoupon Codes Bulk

Generate Multiple Coupon Codes

Generate a batch of coupon codes for a particular bulk coupon promotion. **Note:** * batch_size (number of codes generated per request) is limited to 250. If batch_size is not an integer or larger than 250, it will return a 422 error code. * The default rate limit for this endpoint is 10 concurrent requests.

Authentication

X-Auth-Tokenstring
### OAuth scopes | UI Name | Permission | Parameter | |:--------|:-----------|:----------| | Marketing | modify | `store_v2_marketing` | | Marketing | read-only | `store_v2_marketing_read_only` | ### Authentication header | Header | Argument | Description | |:-------|:---------|:------------| | `X-Auth-Token` | `access_token` | For more about API accounts that generate `access_token`s, see [API Accounts and OAuth Scopes](/developer/docs/overview/api-accounts#api-accounts). | ### Further reading For example requests and more information about authenticating BigCommerce APIs, see [Authentication and Example Requests](/developer/docs/overview/api-accounts). For more about BigCommerce OAuth scopes, see [API Accounts and OAuth Scopes](/developer/docs/overview/api-accounts#api-accounts). For a list of API status codes, see [API Status Codes](/developer/api-reference/rest/overview#rest-http-status-codes).

Path parameters

promotion_idstringRequired
The ID of the associated promotion.

Headers

AcceptstringRequiredDefaults to application/json
The [MIME type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) of the response body.

Request

This endpoint expects an object.
batch_sizeintegerRequired1-250
The number of coupon codes to generate in each batch. The maximum value is 250.
max_usesintegerOptional0-100000
The maximum number of times each coupon code can be used. The default value is 1. The value 0 means unlimited usage.
max_uses_per_customerintegerOptional0-100000
The maximum number of times a specific customer can use each coupon code. The default value is 1. The value 0 means unlimited usage.
prefixstringOptionalformat: "[A-Z0-9_-]"<=20 characters
The fixed text that will appear at the beginning of every generated coupon code. Only capital letters, numbers, underscores and hyphens are allowed.
suffixstringOptionalformat: "[A-Z0-9_-]"<=20 characters
The fixed text that will appear at the end of every generated coupon code. Only capital letters, numbers, underscores and hyphens are allowed.
delimiterstringOptionalformat: "[_-]"<=1 character

An optional single character (_ or -) that will be placed between the prefix and the randomly generated code, and again between the randomly generated code and the suffix. It will only be applied if a valid prefix or suffix is present.

exclude_characterslist of stringsOptional

An optional array of single length string elements to exclude from the randomly generated part. Only capital letters and numbers are allowed. The default value is an empty array [].

code_lengthintegerOptional6-16

The length of the random string to be generated for each coupon code. The value must be between 6 and 16. The default length is 16. The total length of each generated coupon code is calculated as : code_length + length of prefix with delimiter + length of suffix with delimiter. The maximum total length of a coupon code is 50.

Response

dataobject
metaobject
Empty meta object, which may be used at a later time.

Errors

400
Bad Request Error
403
Forbidden Error
405
Method Not Allowed Error
422
Unprocessable Entity Error