Promotions > Coupons > couponsGenerate
Commerce APIPromotionsCouponscouponsGenerate
couponsGenerate
POST:coupons/generate.json

Description

Generate a bunch of coupons at once using various template parameters.

Example mutation

mutation GenerateFiveCoupons($shopID: String!, $promotionID: String!) {
  couponsGenerate(
    shop_id: $shopID
    promotion_id: $promotionID
    data: {
      quantity: 5
      length: 8
      format: numeric
      prefix: "PROMO-"
      dash_section_length: 4
    }
  )
}

Example result

PROMO-1286-6703
PROMO-2358-5157
PROMO-7005-0283
PROMO-1247-7714
PROMO-6219-6036

Permission bit: "coupons.create"

Topic: Coupons

Arguments

data: CouponBulk!

Main argument for mutations.


promotion_id: String!

Unique promotion identifier. See also: Unique Identifiers

Example: "pr_EQzGqWoY"


shop_id: String!

Unique shop identifier. See also: Unique Identifiers

Example: "sh_EQzGqWoY"


Data Argument Fields

dash_section_length: Int

Dash every N characters


format: CouponBulkFormat!

Format of the generated coupon code


length: Int!

Length of a generated coupon code (without prefix/suffix and dashes)

Valid when: length is in range: 1 ≤ length ≤ 100


prefix: String

Coupon code prefix

Valid when: prefix's length doesn't exceed 25 characters


quantity: Int!

Amount of coupons to generate

Valid when: quantity is in range: 1 ≤ quantity ≤ 500


suffix: String

Coupon code suffix

Valid when: suffix's length doesn't exceed 25 characters


Result

Boolean

Preview (typescript)

Loading module