Import Coupon Codes
Uploads a CSV file of coupon codes to import into a bulk coupon promotion.
The request validates the whole file before it creates any codes. If the file passes, the import is queued, the codes are created in the background, and the response returns the task that tracks the import. To follow its progress, poll Get Latest Promotion Task.
CSV format
The first line must be this header: code,max_uses,max_uses_per_customer,valid_from,valid_until. Every row after it must have all five columns. Blank lines are skipped.
A custom redemption window must fall within the promotion’s start and end dates. Dates must be after 1970-01-01T00:00:00+00:00 and no later than 2038-01-19T03:14:07+00:00.
How rows are imported
- If any row is invalid, the request returns a 422 that lists the invalid rows, and no codes are created. At most 20 rows are reported.
errors_truncatedistruewhen more rows are invalid. - A code that already exists in the store, or that appears earlier in the same file, is skipped and reported in the task’s
failure_details. Codes are compared case-insensitively.
Notes
- Only bulk coupon promotions (
coupon_typeofBULK) accept imported codes. - Send the file as
multipart/form-datain theimportfilefield. The file name must end in.csv. - The whole request body, including multipart encoding, must be no larger than 20 MB (20,971,520 bytes).
- A store can run one import at a time. While an import is
queuedorprocessing, another upload returns a 429 before its contents are validated. An import that is stillqueuedorprocessingmore than 24 hours after it was created is treated as abandoned, and a new upload can start. - Uploading the same file as the store’s latest import returns a 422, unless that import failed or was abandoned. Files are compared by content, so this applies even when the promotion differs.
- The default rate limit for this endpoint is 3 concurrent requests.
Authentication
OAuth scopes
Authentication header
Further reading
For example requests and more information about authenticating BigCommerce APIs, see Authentication and Example Requests.
For more about BigCommerce OAuth scopes, see API Accounts and OAuth Scopes.
For a list of API status codes, see API Status Codes.
Path parameters
Headers
The MIME type of the response body.
Request
The .csv file of coupon codes to import.
Response
The promotion task.
Coupon code import tasks
completedmeans the import created at least one code. It may not have processed every row. If the import stopped early, for example because the promotion was archived,codes_createdpluscodes_failedis less thancodes_total.failedmeans the import created no codes.failure_reasonexplains why.- An import that is still
queuedorprocessingmore than 24 hours after it was created is treated as abandoned. Itsstatusdoes not change, but a new import can start, including one with the same file.
A long-running operation performed on a promotion, such as a coupon code import.