Skip to content

Generate codes

POST/admin/v1/stores/{store_id}/discounts/{discount_id}/codes/batches
  • discounts:write
  • Idempotency-Key supported

Starts making a batch of codes in the background.

Path parameters

  • store_idstringrequired

    The store's ID, like store_01k8qs5s…. Apps get it with the install, in the OAuth redirect and the token response.

  • discount_idstringrequired

    The discount's ID, like disc_01k8qs5s….

Headers

  • Idempotency-Keystring

    Send the same key to retry safely: the first answer is replayed for 24 hours.

  • shop-api-versionYYYY-MM

    The version to answer in. Without it, your app’s pinned version, else the newest.

Body

  • countintegerrequired

    How many: 1 to 100,000.

  • prefixstring · or null

    What each code starts with, up to 16 letters, digits, dashes or underscores.

  • lengthinteger · or null

    Random characters per code: 8 to 16, 10 by default.

Returns

202 Making them.

Errors

  • 403forbiddenMissing permission.
  • 404not_foundNo such discount.
  • 409A batch is running, or there would be too many.
  • 422validation_failedInvalid count, prefix or length.