Promotions API Routes
A promotion discounts an amount or percentage off a cart's items, shipping methods, or the entire order.
Promotions have different types, such as a standard promotion that just discounts an amount, or a buyget promotion to enforce a "buy X get Y" promotion.
A promotion has rules to restrict how and when they're applied.
Promotions belong to a campaign, which sets conditions on the promotion such as when it starts and ends.
These API routes allow admin users to manage promotions.
GET /admin/promotions#
List Promotions
Retrieve a list of promotions. The promotions can be filtered by fields such as id. The promotions can also be sorted or paginated.
Authentication: secret API key (HTTP Basic authorization), cookie session, JWT bearer token.
Query parameters
fieldsstringOptional+ it will be added to the default fields, using - will remove it from the default fields. without prefix it will replace the entire default fields.offsetnumberOptionallimitnumberOptionalorderstringOptional-.qstringOptionalcodestring | string[]Optionalcampaign_idstring | string[]Optionalapplication_methodobjectOptionalApply filters on the application methods to retrieve the promotions of the matching application methods.
application_methodobjectOptionalcreated_atobjectOptionalupdated_atobjectOptionaldeleted_atobjectOptional$andobject[]Optional$orobject[]Optionalwith_deletedbooleanOptionalidstring | string[] | objectOptionalRequest examples
Responses
200 OK
limitnumberoffsetnumbercountnumberpromotionsobject[]The list of promotions.
promotionsobject[]400, 401, 404, 409, 422, 500: an error response is returned.
POST /admin/promotions#
Create Promotion
Create a promotion.
Authentication: secret API key (HTTP Basic authorization), cookie session, JWT bearer token.
Query parameters
fieldsstringOptional+ it will be added to the default fields, using - will remove it from the default fields. without prefix it will replace the entire default fields.Request body (application/json)
codestringis_automaticbooleanOptionaltype"standard" | "buyget"campaign_idstringcampaignobjectOptionalThe details of a campaign to create and add the promotion to it.
campaignobjectOptionalapplication_methodobjectThe promotion's application method.
application_methodobjectrulesobject[]OptionalThe promotion's rules.
rulesobject[]Optionaladditional_dataobjectOptionaladditional_data parameter.Request examples
Responses
200 OK
promotionobjectThe promotion's details.
promotionobject400, 401, 404, 409, 422, 500: an error response is returned.
GET /admin/promotions/rule-attribute-options/{rule_type}#
List Rule Attribute Options of a Rule Type
Retrieve a list of potential rule attributes for the promotion and application method types specified in the query parameters. Only the attributes of the rule type specified in the path parameter are retrieved:
-
If
rule_typeisrules, the attributes of the promotion's type are retrieved. -
If
rule_typeistarget-rules, the target rules' attributes of the application method's type are retrieved. -
If
rule_typeisbuy-rules, the buy rules' attributes of the application method's type are retrieved.
Authentication: secret API key (HTTP Basic authorization), cookie session, JWT bearer token.
Path parameters
rule_type"rules" | "target-rules" | "buy-rules"Query parameters
promotion_type"standard" | "buyget"Optionalapplication_method_type"fixed" | "percentage"Optionalapplication_method_target_type"items" | "shipping_methods" | "order"OptionalRequest examples
Responses
200 OK
attributesobject[]The list of attributes.
attributesobject[]400, 401, 404, 409, 422, 500: an error response is returned.
GET /admin/promotions/rule-value-options/{rule_type}/{rule_attribute_id}#
List Rule Values Given a Rule Attribute
Retrieve all potential values for promotion rules and target and buy rules based on the specified rule attribute and type.
For example, if you provide the ID of the currency_code rule attribute, and set rule_type to rules, a list of currencies are retrieved in label-value pairs.
Authentication: secret API key (HTTP Basic authorization), cookie session, JWT bearer token.
Path parameters
rule_type"rules" | "target-rules" | "buy-rules"rule_attribute_idstringQuery parameters
offsetnumberOptionallimitnumberOptionalorderstringOptional-.with_deletedbooleanOptionalapplication_method_target_typestringOptionalqstringOptionalvaluestring | string[]OptionalfieldsstringOptional+ it will be added to the default fields, using - will remove it from the default fields. Without prefix it will replace the entire default fields.Request examples
Responses
200 OK
limitnumberoffsetnumbercountnumbervaluesobject[]The list of rule values.
valuesobject[]400, 401, 404, 409, 422, 500: an error response is returned.
GET /admin/promotions/{id}#
Get a Promotion
Retrieve a promotion by its ID. You can expand the promotion's relations or select the fields that should be returned.
Authentication: secret API key (HTTP Basic authorization), cookie session, JWT bearer token.
Path parameters
idstringQuery parameters
fieldsstringOptional+ it will be added to the default fields, using - will remove it from the default fields. without prefix it will replace the entire default fields.Request examples
Responses
200 OK
promotionobjectThe promotion's details.
promotionobject400, 401, 404, 409, 422, 500: an error response is returned.
POST /admin/promotions/{id}#
Update a Promotion
Update a promotion's details.
Authentication: secret API key (HTTP Basic authorization), cookie session, JWT bearer token.
Path parameters
idstringQuery parameters
fieldsstringOptional+ it will be added to the default fields, using - will remove it from the default fields. without prefix it will replace the entire default fields.Request body (application/json)
codestringOptionalis_automaticbooleanOptionaltype"standard" | "buyget"Optionalcampaign_idstringapplication_methodobjectOptionalThe properties to update in the application method.
application_methodobjectOptionaladditional_dataobjectOptionaladditional_data parameter.Request examples
Responses
200 OK
promotionobjectThe promotion's details.
promotionobject400, 401, 404, 409, 422, 500: an error response is returned.
DELETE /admin/promotions/{id}#
Delete a Promotion
Delete a promotion.
Authentication: secret API key (HTTP Basic authorization), cookie session, JWT bearer token.
Path parameters
idstringRequest examples
Responses
200 OK
idstringobjectstringDefault: "promotion"
deletedboolean400, 401, 404, 409, 422, 500: an error response is returned.
POST /admin/promotions/{id}/buy-rules/batch#
Manage the Buy Rules of a Promotion
Manage the buy rules of a buyget promotion to create, update, or delete them.
Authentication: secret API key (HTTP Basic authorization), cookie session, JWT bearer token.
Path parameters
idstringQuery parameters
promotion_type"standard" | "buyget"Optionalapplication_method_type"fixed" | "percentage"Optionalapplication_method_target_type"items" | "shipping_methods" | "order"OptionalRequest body (application/json)
createobject[]OptionalThe buy rules to create.
createobject[]Optionalupdateobject[]OptionalThe buy rules to update.
updateobject[]Optionaldeletestring[]OptionalRequest examples
Responses
200 OK
createdobject[]The created buy rules.
createdobject[]updatedobject[]The updated buy rules.
updatedobject[]deletedobjectThe details of the deleted buy rules.
deletedobject400, 401, 404, 409, 422, 500: an error response is returned.
POST /admin/promotions/{id}/rules/batch#
Manage a Promotion's Rules
Manage the rules of a promotion to create, update, or delete them.
Authentication: secret API key (HTTP Basic authorization), cookie session, JWT bearer token.
Path parameters
idstringQuery parameters
promotion_type"standard" | "buyget"Optionalapplication_method_type"fixed" | "percentage"Optionalapplication_method_target_type"items" | "shipping_methods" | "order"OptionalRequest body (application/json)
createobject[]OptionalThe rules to create.
createobject[]Optionalupdateobject[]OptionalThe rules to update.
updateobject[]Optionaldeletestring[]OptionalRequest examples
Responses
200 OK
createdobject[]The created rules.
createdobject[]updatedobject[]The updated rules.
updatedobject[]deletedobjectThe details of the deleted buy rules.
deletedobject400, 401, 404, 409, 422, 500: an error response is returned.
POST /admin/promotions/{id}/target-rules/batch#
Manage Target Rules of a Promotion
Manage the target rules of a promotion to create, update, or delete them.
Authentication: secret API key (HTTP Basic authorization), cookie session, JWT bearer token.
Path parameters
idstringQuery parameters
promotion_type"standard" | "buyget"Optionalapplication_method_type"fixed" | "percentage"Optionalapplication_method_target_type"items" | "shipping_methods" | "order"OptionalRequest body (application/json)
createobject[]OptionalThe target rules to create.
createobject[]Optionalupdateobject[]OptionalThe target rules to update.
updateobject[]Optionaldeletestring[]OptionalRequest examples
Responses
200 OK
createdobject[]The created target rules.
createdobject[]updatedobject[]The updated target rules.
updatedobject[]deletedobjectThe details of the deleted target rules.
deletedobject400, 401, 404, 409, 422, 500: an error response is returned.
GET /admin/promotions/{id}/{rule_type}#
List Rules of a Promotion
Retrieve a list of rules in a promotion. The type of rules retrieved depend on the value of the rule_type path parameter:
-
If
rule_typeisrules, the promotion's rules are retrivied. - Ifrule_typeistarget-rules, the target rules of the promotion's application method are retrieved. -
If
rule_typeisbuy-rules, the buy rules of the promotion's application method are retrieved.
Authentication: secret API key (HTTP Basic authorization), cookie session, JWT bearer token.
Path parameters
idstringrule_type"rules" | "target-rules" | "buy-rules"Query parameters
fieldsstringOptional+ it will be added to the default fields, using - will remove it from the default fields. without prefix it will replace the entire default fields.promotion_type"standard" | "buyget"Optionalapplication_method_type"fixed" | "percentage"Optionalapplication_method_target_type"items" | "shipping_methods" | "order"OptionalRequest examples
Responses
200 OK
rulesobject[]The list of promotion rules.
rulesobject[]400, 401, 404, 409, 422, 500: an error response is returned.