Retrieve discount rules for automated document discounts.
GraphQL
query GetDiscountRule($id: ID) {
DiscountRule(id: $id) {
id
label
active
target
origin { id label }
started_at
ended_at
intervals { id interval_start_type interval_start_value discount_type discount_value }
start_date_condition
end_date_condition
product_tags_condition { id label }
customer_tags_condition { id label }
seasons_condition { id label }
}
}
GraphQL
query DiscountRules(
$where: QueryDiscountRulesWhereWhereConditions,
$orderBy: [QueryDiscountRulesOrderByOrderByClause!],
$search: String
) {
DiscountRules(
where: $where
orderBy: $orderBy
search: $search
) {
id
label
active
target
started_at
ended_at
start_date_condition
end_date_condition
}
}
JSON
{
"where": {
"AND": [
{ "column": "ACTIVE", "operator": "EQ", "value": true }
]
},
"orderBy": [
{ "column": "LABEL", "order": "ASC" }
],
"search": "discount rule name"
}
Field Type Description idInt Unique identifier of the discount rule. labelString Label of the discount rule. activeBoolean Whether the discount rule is active. targetTarget Target of the discount rule (document, product, shipping_cost). originDiscountRule Original discount rule this rule is based on. started_atDate Start date of the discount rule. ended_atDate End date of the discount rule. intervals[DiscountInterval] Discount intervals for the rule. start_date_conditionDate Start date condition for the discount. end_date_conditionDate End date condition for the discount. product_tags_condition[ProductTag] Product tags that must match for the discount. customer_tags_condition[CustomerTag] Customer tags that must match for the discount. seasons_condition[Season] Seasons that must match for the discount.
You can create filters based on following fields
id - Int Example: { "column": "ID", "operator": "EQ", "value": 100012 }
label - String Example: { "column": "LABEL", "operator": "LIKE", "value": "%discount%" }
origin_id - ID Example: { "column": "ORIGIN_ID", "operator": "EQ", "value": 100001 }
active - Boolean Example: { "column": "ACTIVE", "operator": "EQ", "value": true }
target - Target Example: { "column": "TARGET", "operator": "EQ", "value": "product" }
started_at - Date Example: { "column": "STARTED_AT", "operator": "GTE", "value": "2025-01-01" }
ended_at - Date Example: { "column": "ENDED_AT", "operator": "LTE", "value": "2025-12-31" }
condition_start_date - Date Example: { "column": "CONDITION_START_DATE", "operator": "GTE", "value": "2025-01-01" }
condition_end_date - Date Example: { "column": "CONDITION_END_DATE", "operator": "LTE", "value": "2025-12-31" }
You can sort data based on following fields: id, label, condition_start_date, condition_end_date
GraphQL
query SortDiscountRules(
$where: QueryDiscountRulesWhereWhereConditions
) {
DiscountRules(
where: $where
orderBy: [{ column: LABEL, order: ASC }]
) {
id
label
active
target
started_at
ended_at
}
}
JSON
{
"data": {
"DiscountRules": [
{
"id": 100001,
"label": "Summer Sale 2025",
"active": true,
"target": "product",
"started_at": "2025-06-01",
"ended_at": "2025-08-31",
"start_date_condition": "2025-06-01",
"end_date_condition": "2025-08-31"
},
{
"id": 100002,
"label": "Bulk Discount",
"active": true,
"target": "document",
"started_at": null,
"ended_at": null,
"start_date_condition": null,
"end_date_condition": null
}
]
}
}
Field Type Description idInt Interval ID. interval_start_typeIntervalStartType Type of interval start (amount, quantity). interval_start_valueFloat Value for the interval start. discount_typeDiscountType Type of discount (amount, percentage). discount_valueFloat Value of the discount.
Field Type Description idInt Discount rule ID. labelString Rule label. activeBoolean Whether active.
Field Type Description idInt Interval ID. interval_start_typeIntervalStartType Type of interval start. interval_start_valueFloat Value for the interval start. discount_typeDiscountType Type of discount. discount_valueFloat Value of the discount.
Value Description documentDiscount applies to the entire document. productDiscount applies to specific products. shipping_costDiscount applies to shipping costs.
Value Description salesRule applies to sales documents only. purchasesRule applies to purchase documents only. bothRule applies to both sales and purchases.