Coupon
Private Coupon API endpoints
An API endpoint to get a paginated list of coupons.
Query parameters
idsoptionalinteger[]Filter by coupon IDs
queryoptionalstringSearch by coupon code or name
activeoptionalintegerFilter by active status (0 or 1)
Possible values: 0, 1.
trashedoptionalintegerInclude soft-deleted coupons (0 or 1)
Possible values: 0, 1.
sort[field]optionalstringSort field
Possible values: id, name.
sort[direction]optionalstringSort direction; defaults to asc.
Possible values: asc, desc.
Defaults to "asc".
pageoptionalintegerPage number
per_pageoptionalintegerItems per page
expand[]optionalstring[]List of relations to expand in the response. Each expandable field on the response schema names its key, e.g. expand[]=customer. Nested keys use dot notation, e.g. items.product or subscriptions.items. Fields marked as always present are returned without being requested. An expanded list is null, not [], when there are no records. Unknown keys are ignored unless the endpoint says otherwise.
Returnsobject
Coupons list response
Error responses
422objectA query parameter fails validation: ids is not an array of distinct integers, query is not a string or is longer than 255 characters, active or trashed is not 0 or 1, sort[field] is missing or is not id or name while sort is sent, sort[direction] is not asc or desc, page is not an integer of at least 1, per_page is not an integer between 1 and 100, or expand[] is not an array.
Create a new coupon. Must include either a discount or a gift (or both).
Query parameters
expand[]optionalstring[]List of relations to expand in the response. Each expandable field on the response schema names its key, e.g. expand[]=customer. Nested keys use dot notation, e.g. items.product or subscriptions.items. Fields marked as always present are returned without being requested. An expanded list is null, not [], when there are no records. Unknown keys are ignored unless the endpoint says otherwise.
Request body
nameRequiredstringcoupon_codeRequiredstringUnique coupon code within the shop
durationRequiredstringPossible values: once, forever, multiple.
duration_in_monthsoptionalintegerRequired when duration is "multiple". Prohibited when duration is "once" or "forever".
remove_gifts_after_end_of_durationoptionalintegerPossible values: 0, 1.
max_redemptionsoptionalinteger | nulllimit_one_per_customeroptionalintegerPossible values: 0, 1.
redeem_byoptionalstring | nullExpiry date in Y-m-dTH:i:s format, interpreted as UTC. Must be after tomorrow.
conditionoptionalobject | nullWhether the coupon can be used on the cart. product, collection: the cart has a listed product, or a product from a listed collection. cart_value, cart_quantity: the value in cents, or the quantity, of the counted products is within min..max. any counts all products, only the listed ones, except all but the listed ones. At least one counted product is required. Products are variant IDs. Gift lines are not counted.. Set to null for no condition.
discountoptionalobject | nullDiscount action. Required if gift is not provided.
giftoptionalobject | nullProducts added to the cart, with the discount on those lines only.. Required if discount is not provided.
rulesoptionalobject | nullWho can use the coupon. When emails and customers are both set, matching either is enough..
ReturnsCoupon
Coupon created
Error responses
422objectThe body fails validation. name, coupon_code and duration are required, and coupon_code must not be in use in the shop ("The coupon code :input is already in use."). duration_in_months is required when duration is multiple and not allowed otherwise. redeem_by must use Y-m-d H:i:s or Y-m-dTH:i:s and fall after the start of tomorrow (UTC). You must send discount or gift, and each needs exactly one of amount_off or percent_off ("A discount must specify either an amount off or a percent off."). discount.amount_off cannot be combined with discount.first_shipment_only. condition.operator must suit condition.type (product and collection accept only only). condition.products is required for only and except and not allowed for any or collection, condition.collections is required for and limited to collection, and condition.cart_value and condition.cart_quantity fit only their own type and need min when max is set. Condition products must be variants of the shop, and discount products, collections, customers and subscription products must belong to the shop. A gift product must be a one-time variant of the shop that is not a gift card and not in a configurable bundle.
Get a single coupon by its ID.
Path parameters
coupon_idRequiredintegerCoupon ID
Query parameters
expand[]optionalstring[]List of relations to expand in the response. Each expandable field on the response schema names its key, e.g. expand[]=customer. Nested keys use dot notation, e.g. items.product or subscriptions.items. Fields marked as always present are returned without being requested. An expanded list is null, not [], when there are no records. Unknown keys are ignored unless the endpoint says otherwise.
ReturnsCoupon
Coupon object response
Error responses
404objectNo coupon exists with this ID in the shop, or the coupon is deleted.
422objectThe expand[] parameter is not an array.
Partially update a coupon. All fields are optional.
Path parameters
coupon_idRequiredintegerCoupon ID
Query parameters
expand[]optionalstring[]List of relations to expand in the response. Each expandable field on the response schema names its key, e.g. expand[]=customer. Nested keys use dot notation, e.g. items.product or subscriptions.items. Fields marked as always present are returned without being requested. An expanded list is null, not [], when there are no records. Unknown keys are ignored unless the endpoint says otherwise.
Request body
nameoptionalstringdurationoptionalstringPossible values: once, forever, multiple.
duration_in_monthsoptionalintegerRequired when duration is "multiple". Prohibited when duration is "once" or "forever".
remove_gifts_after_end_of_durationoptionalintegerPossible values: 0, 1.
max_redemptionsoptionalinteger | nulllimit_one_per_customeroptionalintegerPossible values: 0, 1.
redeem_byoptionalstring | nullExpiry date in Y-m-dTH:i:s format, interpreted as UTC. Must be after tomorrow.
conditionoptionalobject | nullWhether the coupon can be used on the cart. product, collection: the cart has a listed product, or a product from a listed collection. cart_value, cart_quantity: the value in cents, or the quantity, of the counted products is within min..max. any counts all products, only the listed ones, except all but the listed ones. At least one counted product is required. Products are variant IDs. Gift lines are not counted.. Set to null to remove the condition.
discountoptionalobject | nullUpdate discount settings.
giftoptionalobject | nullProducts added to the cart, with the discount on those lines only..
rulesoptionalobject | nullWho can use the coupon. When emails and customers are both set, matching either is enough.. Omit a type to leave it unchanged.
ReturnsCoupon
Coupon updated
Error responses
404objectNo coupon exists with this ID in the shop, or the coupon is deleted.
422objectA field you send fails validation. Every field is optional and follows the create rules. condition.type and condition.operator are required with condition, and gift.addon_duration and gift.remove_products_after_coupon_detached are required with gift. Once the coupon has a discount, discount.amount_off and discount.percent_off are not allowed ("The discount amount off cannot be changed once the coupon has a discount action."), and the same holds for the gift amounts. discount.first_shipment_only fails when the existing discount is a fixed amount off ("First shipment only is not available when the existing discount is a fixed amount off."). Each *.delete.*.id and each rules.customers.delete.* or rules.subscriptions.delete.* must be an integer, and each rules.emails.delete.* must be an email.
Archive (deactivate) a coupon.
Path parameters
coupon_idRequiredintegerCoupon ID
ReturnsCoupon
Coupon archived
Error responses
404objectNo coupon exists with this ID in the shop, or the coupon is deleted.