Creates a discount code creation job.
The batch endpoint can be used to asynchronously create up to 100 discount codes in a single request. It
enqueues and returns a discount_code_creation
object that can be monitored for completion.
You can enqueue a single creation job per a shop and you can't enqueue more until the job completes.
The price_rule_id
path parameter is the ID of the price rule that the discount code will belong to. This is required because
each discount code must belong to a price rule.
Response fields that are specific to the batch endpoint include:
status
: The state of the discount code creation job. Possible values are:
queued
: The job is acknowledged, but not started.running
: The job is in process.completed
: The job has finished.codes_count
: The number of discount codes to create.imported_count
: The number of discount codes created successfully.failed_count
: The number of discount codes that were not created successfully. Unsuccessful attempts will retry up to three times.logs
: A report that specifies when no discount codes were created because the provided data was invalid. Example responses:
curl --location --request POST 'https://demo.myshopify.com//admin/api//price_rules//batch.json'
{
"discount_code_creation": {
"id": 989355119,
"price_rule_id": 507328175,
"started_at": null,
"completed_at": null,
"created_at": "2023-01-03T12:38:25-05:00",
"updated_at": "2023-01-03T12:38:25-05:00",
"status": "queued",
"codes_count": 3,
"imported_count": 0,
"failed_count": 0,
"logs": []
}
}