getAllDiscounts
Get all discounts.
Description
Fetches discounts with pagination and an optional type filter. Resolves to an IDiscountsResponse: the discounts are in items, the count in total.
.getAllDiscounts(
,
,
,
);
Parameters schema
Schema
langCode: string
Language code. Default: the langCode passed to defineOneEntry ("en_US" if none).
example: "en_US"
offset: number
Number of records to skip. Default: 0. offset + limit must not exceed 200; a larger window is rejected with 400.
example: 0
limit: number
Maximum number of records to return. Default: 30.
example: 30
type: IDiscountType
Discount type to filter by: DISCOUNT, BONUS or PERSONAL_DISCOUNT.
Record limit. If the user group's permission for this method allows only restricted reading, the API returns at most the number of records set in the project settings (10 by default), whatever limit you pass. With full read access, limit works as usual. See Module permissions (opens in a new tab).
Examples
Minimal example
const response = await Discounts.getAllDiscounts();
Example with optional parameters
const response = await Discounts.getAllDiscounts('en_US', 0, 30);
Example response
{
"items": [
{
"id": 1,
"type": "DISCOUNT",
"attributeSetId": 31,
"conditionLogic": "AND",
"discountValue": {
"value": 10,
"maxAmount": 5,
"discountType": "FIXED_AMOUNT",
"applicability": "TO_PRODUCT"
},
"exclusions": null,
"gifts": null,
"giftsReplaceCartItems": false,
"userGroups": null,
"userExclusions": null,
"localizeInfos": {
"title": "Example discount"
},
"version": 0,
"identifier": "example_discount",
"startDate": "2026-03-14T14:55:19.928Z",
"endDate": "2026-07-31T13:55:24.647Z",
"attributeValues": {
"example_discount": {
"type": "string",
"value": "test value",
"isIcon": false,
"position": 0,
"additionalFields": {},
"isProductPreview": false
}
},
"conditions": [],
"bonusEvent": null,
"position": 1
},
{
"id": 2,
"type": "PERSONAL_DISCOUNT",
"attributeSetId": null,
"conditionLogic": "AND",
"discountValue": {
"value": 15,
"maxAmount": null,
"discountType": "FIXED_AMOUNT",
"applicability": "TO_ORDER"
},
"exclusions": null,
"gifts": null,
"giftsReplaceCartItems": false,
"userGroups": null,
"userExclusions": null,
"localizeInfos": {
"title": "Personal discount"
},
"version": 2,
"identifier": "personal_discount",
"startDate": "2026-04-21T18:26:19.815Z",
"endDate": "2028-03-21T19:26:24.741Z",
"attributeValues": {},
"conditions": [],
"bonusEvent": null,
"position": 2
}
],
"total": 2
}
Response schema
Schema: IDiscountsResponse
items: IDiscountsEntity[]
Discounts in this response.
items.id: number
ID of the discount.
items.attributeSetId: number | null
ID of the attribute set linked to the discount, or null when no set is linked.
items.localizeInfos: ILocalizeInfo
Localized name of the discount.
items.version: number
Version number of the discount.
items.identifier: string
Marker of the discount.
items.type: IDiscountType
The type of the discount.
items.startDate: string
The start date of the discount.
items.endDate: string
End date of the discount.
items.discountValue: IDiscountValue
Discount value with its type and amount limits.
items.conditionLogic: string
How the conditions combine: AND or OR.
items.conditions: IDiscountCondition[]
Conditions of the discount.
items.exclusions: Record<string, unknown> | null
Exclusions of the discount.
items.gifts: Record<string, unknown> | null
Gifts of the discount.
items.giftsReplaceCartItems: boolean
Whether the gifts replace cart items.
items.userGroups: Record<string, unknown> | null
User groups the discount applies to.
items.userExclusions: Record<string, unknown> | null
Users excluded from the discount.
items.attributeValues: IAttributeValues
Attribute values of the discount.
items.attributeSetIdentifier: string
Marker of the attribute set.
items.bonusEvent: Record<string, unknown>
Bonus event configuration.
items.position: number
Position used for sorting.
example: 1
items.total: number | string
Internal row count that the API returns by mistake ("1" on a single discount). Don't rely on it.
example: "1"
items.distance: number
Cosine distance to the query. Returned on every item by the semantic (vector) search endpoint.
example: 0.12
total: number
Total number of discounts.