Discount Codes
With discount codes it is possible to give specific cart discounts to an eligible set of users. They are defined by a string value which can be added to a cart so that specific cart discounts can be applied to the cart.
Representations
DiscountCode
id
- String
The unique ID of the discount code.version
- NumbercreatedAt
- DateTimecreatedBy
- CreatedBy BETA
Present on resources created after 2019-02-01 except for events not tracked.lastModifiedAt
- DateTimelastModifiedBy
- LastModifiedBy BETA
Present on resources updated after 2019-02-01 except for events not tracked.name
- LocalizedString - Optionaldescription
- LocalizedString - Optionalcode
- String
Unique identifier of this discount code. This value is added to the cart to enable the related cart discounts in the cart.cartDiscounts
- Array of Reference to a CartDiscount
The referenced matching cart discounts can be applied to the cart once the DiscountCode is added.cartPredicate
- Cart predicate - Optional
The discount code can only be applied to carts that match this predicate.groups
- Array of String
The groups to which this discount code belong.isActive
- BooleanvalidFrom
- DateTime - Optional
The time from which the discount can be applied on a cart. Before that time the code is invalid.validUntil
- DateTime - Optional
The time until the discount can be applied on a cart. After that time the code is invalid.references
- Array of Reference
The platform will generate this array from the cart predicate. It contains the references of all the resources that are addressed in the predicate.maxApplications
- Number - Optional
The discount code can only be appliedmaxApplications
times.maxApplicationsPerCustomer
- Number - Optional
The discount code can only be appliedmaxApplicationsPerCustomer
times per customer.applicationVersion
- Number - Optional
Used for the internal platform only and registers the reservation of use of a discount code. Do not use this field in your applications. It can change or be removed at any time without prior notice.custom
- CustomFields - Optional
DiscountCodeDraft
name
- LocalizedString - Optionaldescription
- LocalizedString - Optionalcode
- String
Unique identifier of this discount code. This value is added to the cart to enable the related cart discounts in the cart.cartDiscounts
- Array of Reference to a CartDiscount
The referenced matching cart discounts can be applied to the cart once the discount code is added. The number of cart discounts in a discount code is limited to 10.cartPredicate
- Cart predicate - Optional
The discount code can only be applied to carts that match this predicate.groups
- Array of String - Optional
The groups to which this discount code shall belong to.isActive
- BooleanvalidFrom
- DateTime - Optional
The time from which the discount can be applied on a cart. Before that time the code is invalid.validUntil
- DateTime - Optional
The time until the discount can be applied on a cart. After that time the code is invalid.maxApplications
- Number - OptionalmaxApplicationsPerCustomer
- Number - Optionalcustom
- CustomFieldsDraft - Optional
Get DiscountCode by ID
Endpoint: /{projectKey}/discount-codes/{id}
Method: GET
OAuth 2.0 Scopes: view_discount_codes:{projectKey}
(or, deprecated: view_orders:{projectKey}
)
Response Representation: DiscountCode
Query DiscountCodes
Endpoint: /{projectKey}/discount-codes
Method: GET
OAuth 2.0 Scopes: view_discount_codes:{projectKey}
(or, deprecated: view_orders:{projectKey}
)
Response Representation: PagedQueryResult with results
containing an array of DiscountCode
Query Parameters:
where
- Query Predicate - Optionalsort
- Sort - Optionalexpand
- Expansion - Optionallimit
- Number - Optionaloffset
- Number - Optional
Create a DiscountCode
Endpoint: /{projectKey}/discount-codes
Method: POST
OAuth 2.0 Scopes: manage_discount_codes:{projectKey}
(or, deprecated: manage_orders:{projectKey}
)
Request Representation: DiscountCodeDraft
Response Representation: DiscountCode
Update DiscountCode
Endpoint: /{projectKey}/discount-codes/{id}
Method: POST
OAuth 2.0 Scopes: manage_discount_codes:{projectKey}
(or, deprecated: manage_orders:{projectKey}
)
Response Representation: DiscountCode
Fields:
version
- Number - Required
The expected version of the channel on which the changes should be applied. If the expected version does not match the actual version, a 409 Conflict will be returned.actions
- Array of UpdateAction - Required
The list of update actions to be performed on the discount code.
Update actions
Set Name
action
- String -"setName"
name
- LocalizedString
If thename
parameter is not included, the field will be emptied.
Set Description
action
- String -"setDescription"
description
- LocalizedString - Optional
If thedescription
parameter is not included, the field will be emptied.
Set Cart Predicate
action
- String -"setCartPredicate"
cartPredicate
- Cart predicate - Optional
If thecartPredicate
parameter is not included, the field will be emptied.
Set Max Applications
action
- String -"setMaxApplications"
maxApplications
- Number - Optional
If themaxApplications
parameter is not included, the field will be emptied.
Set Max Applications Per Customer
action
- String -"setMaxApplicationsPerCustomer"
maxApplicationsPerCustomer
- Number - Optional
If themaxApplicationsPerCustomer
parameter is not included, the field will be emptied.
Set Custom Type
This action sets or removes the custom type for an existing discount code. If present, this action overwrites any existing custom type and fields.
action
- String -"setCustomType"
type
- ResourceIdentifier of a Type - Optional
If absent, the custom type and any existing CustomFields are removed.fields
- * - Optional
A valid JSON object, based on the FieldDefinitions of the Type. Sets the custom fields to this value.
Set Custom Field
action
- String -"setCustomField"
name
- String - Requiredvalue
- Value - Optional
Ifvalue
is absent ornull
, this field will be removed if it exists. Trying to remove a field that does not exist will fail with an InvalidOperation error. Ifvalue
is provided, set thevalue
of the field defined by thename
.
Change CartDiscounts
action
- String -"changeCartDiscounts"
cartDiscounts
- Array of Reference to a CartDiscount - Required
The number of cart discounts in a discount code is limited to 10.
Change Groups
action
- String -"changeGroups"
groups
- Array of String - Required
The groups to which this discount code shall belong to. Use empty array to remove the code from all groups.
Change IsActive
action
- String -"changeIsActive"
isActive
- Boolean - Required
Set Valid From
Sets the time from which the discount can be applied on a cart. Before that time the code is invalid.
action
- String -"setValidFrom"
validFrom
- DateTime - Optional
If absent, the field with the value is removed in case a value was set before.
Set Valid Until
Sets the time until the discount can be applied on a cart. After that time the code is invalid.
action
- String -"setValidUntil"
validUntil
- DateTime - Optional
If absent, the field with the value is removed in case a value was set before.
Set Valid From and Until
Sets the time period the discount can be applied on a cart. Outside of that time period the code is invalid.
Delete DiscountCode
Note: No check is made if a linked cart-discount, cart, or order exists.
Endpoint: /{projectKey}/discount-codes/{id}
Method: DELETE
OAuth 2.0 Scopes: manage_discount_codes:{projectKey}
(or, deprecated: manage_orders:{projectKey}
)
Query Parameters:
version
- Number - RequireddataErasure
- Boolean - Optional, defaults tofalse