CouponCodes

Create a coupon code

Generates a new CouponCode under the parent Coupon. All body fields are optional — pass code to set a specific string, omit to auto-generate. Set valid_from_date/valid_to_date to time-limit the code, multi_use to allow multiple redemptions, and customer_credit_id + customer_id to pre-allocate it.

Requires the SETTINGS_MANAGE permission on the coupon's site. Returns 422 if code collides with another code under the same coupon (codes are unique per coupon, not globally).

post/shop/coupons/{couponId}/codes

Request body

codestring nullable

The redemption code customers type. Omitted = auto-generated. Must be unique within the coupon.

valid_from_datestring date-time nullable

ISO 8601 timestamp from which the code is redeemable. Null = valid immediately.

valid_to_datestring date-time nullable

ISO 8601 timestamp after which the code expires. Must be after valid_from_date if both are set.

multi_useboolean nullable

When true, the code can be redeemed multiple times (once per customer). When false / omitted, the code is single-use.

customer_credit_idstring nullable

If set, pre-allocates the code to a specific CustomerCredit. Requires customer_id.

customer_idstring uuid nullable

ID of the customer this code is pre-allocated to. Required when customer_credit_id is set.

revenueinteger nullable

Override revenue in the smallest currency unit. Null = use the coupon's default.

Example request

{
  "code": "SUMMER2026",
  "valid_from_date": "2026-06-01T00:00:00Z",
  "valid_to_date": "2026-08-31T23:59:59Z",
  "customer_credit_id": "5f1234567890abcdef123456",
  "customer_id": "11111111-1111-1111-1111-111111111111",
  "revenue": 5000
}

Response

A single CouponCode.

Example response

{
  "data": {
    "id": "5f1234567890abcdef123456",
    "code": "SUMMER2026",
    "coupon_id": "5f1234567890abcdef123456",
    "valid_from_date": "2026-06-01T00:00:00Z",
    "valid_to_date": "2026-08-31T23:59:59Z",
    "customer_credit_id": "5f1234567890abcdef123456",
    "customer_id": "11111111-1111-1111-1111-111111111111",
    "revenue": 5000
  }
}

Changes