--- displayed_sidebar: jsClientSidebar slug: /references/js-client/AdminDiscountsResource --- import ParameterTypes from "@site/src/components/ParameterTypes" # AdminDiscountsResource This class is used to send requests to [Admin Discount API Routes](https://docs.medusajs.com/api/admin#discounts). All its method are available in the JS Client under the `medusa.admin.discounts` property. All methods in this class require [user authentication](AdminAuthResource.mdx#createsession). Admins can create discounts with conditions and rules, providing them with advanced settings for variety of cases. The methods in this class can be used to manage discounts, their conditions, resources, and more. Related Guide: [How to manage discounts](https://docs.medusajs.com/modules/discounts/admin/manage-discounts). ## Methods ### addConditionResourceBatch Add a batch of resources to a discount condition. The type of resource depends on the type of discount condition. For example, if the discount condition's type is `products`, the resources being added should be products. #### Example To add resources to a discount condition: ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.discounts .addConditionResourceBatch(discountId, conditionId, { resources: [{ id: itemId }], }) .then(({ discount }) => { console.log(discount.id) }) ``` To specify relations to include in the returned discount: ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.discounts .addConditionResourceBatch( discountId, conditionId, { resources: [{ id: itemId }], }, { expand: "rule", } ) .then(({ discount }) => { console.log(discount.id) }) ``` #### Parameters `", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `", "description": "An optional key-value map with additional details", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "parent_discount", "type": "[Discount](../internal/classes/internal.Discount-1.mdx)", "description": "The details of the parent discount that this discount was created from.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "parent_discount_id", "type": "`string`", "description": "The Discount that the discount was created from. This will always be a dynamic discount", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "regions", "type": "[Region](../internal/classes/internal.Region.mdx)[]", "description": "The details of the regions in which the Discount can be used.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "rule", "type": "[DiscountRule](../internal/classes/internal.internal.DiscountRule.mdx)", "description": "The details of the discount rule that defines how the discount will be applied to a cart..", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "rule_id", "type": "`string`", "description": "The ID of the discount rule that defines how the discount will be applied to a cart.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "starts_at", "type": "`Date`", "description": "The time at which the discount can be used.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "updated_at", "type": "`Date`", "description": "The date with timezone at which the resource was updated.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "usage_count", "type": "`number`", "description": "The number of times a discount has been used.", "optional": false, "defaultValue": "0", "expandable": false, "children": [] }, { "name": "usage_limit", "type": "``null`` \\| `number`", "description": "The maximum number of times that a discount can be used.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "valid_duration", "type": "``null`` \\| `string`", "description": "Duration the discount runs between", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] } ] } ]} /> ___ ### addRegion Add a Region to the list of Regions a Discount can be used in. #### Example ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.discounts.addRegion(discountId, regionId).then(({ discount }) => { console.log(discount.id) }) ``` #### Parameters `", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `", "description": "An optional key-value map with additional details", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "parent_discount", "type": "[Discount](../internal/classes/internal.Discount-1.mdx)", "description": "The details of the parent discount that this discount was created from.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "parent_discount_id", "type": "`string`", "description": "The Discount that the discount was created from. This will always be a dynamic discount", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "regions", "type": "[Region](../internal/classes/internal.Region.mdx)[]", "description": "The details of the regions in which the Discount can be used.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "rule", "type": "[DiscountRule](../internal/classes/internal.internal.DiscountRule.mdx)", "description": "The details of the discount rule that defines how the discount will be applied to a cart..", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "rule_id", "type": "`string`", "description": "The ID of the discount rule that defines how the discount will be applied to a cart.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "starts_at", "type": "`Date`", "description": "The time at which the discount can be used.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "updated_at", "type": "`Date`", "description": "The date with timezone at which the resource was updated.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "usage_count", "type": "`number`", "description": "The number of times a discount has been used.", "optional": false, "defaultValue": "0", "expandable": false, "children": [] }, { "name": "usage_limit", "type": "``null`` \\| `number`", "description": "The maximum number of times that a discount can be used.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "valid_duration", "type": "``null`` \\| `string`", "description": "Duration the discount runs between", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] } ] } ]} /> ___ ### create Create a discount with a given set of rules that defines how the discount is applied. #### Example ```ts import Medusa from "@medusajs/medusa-js" import { AllocationType, DiscountRuleType } from "@medusajs/medusa" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.discounts .create({ code: "TEST", rule: { type: DiscountRuleType.FIXED, value: 10, allocation: AllocationType.ITEM, }, regions: ["reg_XXXXXXXX"], is_dynamic: false, is_disabled: false, }) .then(({ discount }) => { console.log(discount.id) }) ``` #### Parameters `", "description": "An optional set of key-value pairs to hold additional information.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "regions", "type": "`string`[]", "description": "A list of region IDs representing the Regions in which the Discount can be used.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "rule", "type": "[AdminPostDiscountsDiscountRule](../internal/classes/internal.AdminPostDiscountsDiscountRule.mdx)", "description": "The discount rule that defines how discounts are calculated", "optional": false, "defaultValue": "", "expandable": false, "children": [ { "name": "allocation", "type": "[AllocationType](../internal/enums/internal.internal.AllocationType.mdx)", "description": "The discount rule's allocation.", "optional": false, "defaultValue": "", "expandable": false, "children": [ { "name": "ITEM", "type": "``\"item\"``", "description": "The discount should be applied to applicable items in the cart.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "TOTAL", "type": "``\"total\"``", "description": "The discount should be applied to the checkout total.", "optional": true, "defaultValue": "", "expandable": false, "children": [] } ] }, { "name": "conditions", "type": "[AdminCreateCondition](../internal/classes/internal.internal.AdminCreateCondition.mdx)[]", "description": "The discount rule's conditions.", "optional": true, "defaultValue": "", "expandable": false, "children": [ { "name": "customer_groups", "type": "`string`[]", "description": "The customer groups associated with the discount condition, if the discount condition's type is `customer_groups`.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "operator", "type": "[DiscountConditionOperator](../internal/enums/internal.DiscountConditionOperator.mdx)", "description": "The operator of the discount condition.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "product_collections", "type": "`string`[]", "description": "The product collections associated with the discount condition, if the discount condition's type is `product_collections`.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "product_tags", "type": "`string`[]", "description": "The product tags associated with the discount condition, if the discount condition's type is `product_tags`.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "product_types", "type": "`string`[]", "description": "The product types associated with the discount condition, if the discount condition's type is `product_types`.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "products", "type": "`string`[]", "description": "The products associated with the discount condition, if the discount condition's type is `products`.", "optional": true, "defaultValue": "", "expandable": false, "children": [] } ] }, { "name": "description", "type": "`string`", "description": "The discount rule's description.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "type", "type": "[DiscountRuleType](../internal/enums/internal.internal.DiscountRuleType.mdx)", "description": "The discount rule's type.", "optional": false, "defaultValue": "", "expandable": false, "children": [ { "name": "FIXED", "type": "``\"fixed\"``", "description": "Discounts that reduce the price by a fixed amount.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "FREE_SHIPPING", "type": "``\"free_shipping\"``", "description": "Discounts that sets the shipping price to `0`.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "PERCENTAGE", "type": "``\"percentage\"``", "description": "Discounts that reduce the price by a percentage reduction.", "optional": true, "defaultValue": "", "expandable": false, "children": [] } ] }, { "name": "value", "type": "`number`", "description": "The discount rule's value.", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] }, { "name": "starts_at", "type": "`Date`", "description": "The date and time at which the discount should be available.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "usage_limit", "type": "`number`", "description": "Maximum number of times the discount can be used", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "valid_duration", "type": "`string`", "description": "The duration the discount runs between", "optional": true, "defaultValue": "", "expandable": false, "children": [] } ] }, { "name": "customHeaders", "type": "`Record`", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `", "description": "An optional key-value map with additional details", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "parent_discount", "type": "[Discount](../internal/classes/internal.Discount-1.mdx)", "description": "The details of the parent discount that this discount was created from.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "parent_discount_id", "type": "`string`", "description": "The Discount that the discount was created from. This will always be a dynamic discount", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "regions", "type": "[Region](../internal/classes/internal.Region.mdx)[]", "description": "The details of the regions in which the Discount can be used.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "rule", "type": "[DiscountRule](../internal/classes/internal.internal.DiscountRule.mdx)", "description": "The details of the discount rule that defines how the discount will be applied to a cart..", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "rule_id", "type": "`string`", "description": "The ID of the discount rule that defines how the discount will be applied to a cart.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "starts_at", "type": "`Date`", "description": "The time at which the discount can be used.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "updated_at", "type": "`Date`", "description": "The date with timezone at which the resource was updated.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "usage_count", "type": "`number`", "description": "The number of times a discount has been used.", "optional": false, "defaultValue": "0", "expandable": false, "children": [] }, { "name": "usage_limit", "type": "``null`` \\| `number`", "description": "The maximum number of times that a discount can be used.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "valid_duration", "type": "``null`` \\| `string`", "description": "Duration the discount runs between", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] } ] } ]} /> ___ ### createCondition Create a discount condition. Only one of `products`, `product_types`, `product_collections`, `product_tags`, and `customer_groups` should be provided in the `payload` parameter, based on the type of discount condition. For example, if the discount condition's type is `products`, the `products` field should be provided in the `payload` parameter. #### Example To create a condition in a discount: ```ts import Medusa from "@medusajs/medusa-js" import { DiscountConditionOperator } from "@medusajs/medusa" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.discounts .createCondition(discountId, { operator: DiscountConditionOperator.IN, products: [productId], }) .then(({ discount }) => { console.log(discount.id) }) ``` To specify relations that should be retrieved as part of the response: ```ts import Medusa from "@medusajs/medusa-js" import { DiscountConditionOperator } from "@medusajs/medusa" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.discounts .createCondition( discountId, { operator: DiscountConditionOperator.IN, products: [productId], }, { expand: "rule", } ) .then(({ discount }) => { console.log(discount.id) }) ``` #### Parameters `", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `", "description": "An optional key-value map with additional details", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "parent_discount", "type": "[Discount](../internal/classes/internal.Discount-1.mdx)", "description": "The details of the parent discount that this discount was created from.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "parent_discount_id", "type": "`string`", "description": "The Discount that the discount was created from. This will always be a dynamic discount", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "regions", "type": "[Region](../internal/classes/internal.Region.mdx)[]", "description": "The details of the regions in which the Discount can be used.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "rule", "type": "[DiscountRule](../internal/classes/internal.internal.DiscountRule.mdx)", "description": "The details of the discount rule that defines how the discount will be applied to a cart..", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "rule_id", "type": "`string`", "description": "The ID of the discount rule that defines how the discount will be applied to a cart.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "starts_at", "type": "`Date`", "description": "The time at which the discount can be used.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "updated_at", "type": "`Date`", "description": "The date with timezone at which the resource was updated.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "usage_count", "type": "`number`", "description": "The number of times a discount has been used.", "optional": false, "defaultValue": "0", "expandable": false, "children": [] }, { "name": "usage_limit", "type": "``null`` \\| `number`", "description": "The maximum number of times that a discount can be used.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "valid_duration", "type": "``null`` \\| `string`", "description": "Duration the discount runs between", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] } ] } ]} /> ___ ### createDynamicCode Create a dynamic unique code that can map to a parent discount. This is useful if you want to automatically generate codes with the same rules and conditions. #### Example ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.discounts .createDynamicCode(discountId, { code: "TEST", usage_limit: 1, }) .then(({ discount }) => { console.log(discount.id) }) ``` #### Parameters `", "description": "An optional set of key-value pairs to hold additional information.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "usage_limit", "type": "`number`", "description": "Maximum number of times the discount code can be used", "optional": false, "defaultValue": "1", "expandable": false, "children": [] } ] }, { "name": "customHeaders", "type": "`Record`", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `", "description": "An optional key-value map with additional details", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "parent_discount", "type": "[Discount](../internal/classes/internal.Discount-1.mdx)", "description": "The details of the parent discount that this discount was created from.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "parent_discount_id", "type": "`string`", "description": "The Discount that the discount was created from. This will always be a dynamic discount", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "regions", "type": "[Region](../internal/classes/internal.Region.mdx)[]", "description": "The details of the regions in which the Discount can be used.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "rule", "type": "[DiscountRule](../internal/classes/internal.internal.DiscountRule.mdx)", "description": "The details of the discount rule that defines how the discount will be applied to a cart..", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "rule_id", "type": "`string`", "description": "The ID of the discount rule that defines how the discount will be applied to a cart.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "starts_at", "type": "`Date`", "description": "The time at which the discount can be used.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "updated_at", "type": "`Date`", "description": "The date with timezone at which the resource was updated.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "usage_count", "type": "`number`", "description": "The number of times a discount has been used.", "optional": false, "defaultValue": "0", "expandable": false, "children": [] }, { "name": "usage_limit", "type": "``null`` \\| `number`", "description": "The maximum number of times that a discount can be used.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "valid_duration", "type": "``null`` \\| `string`", "description": "Duration the discount runs between", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] } ] } ]} /> ___ ### delete Delete a discount. Deleting the discount will make it unavailable for customers to use. #### Example ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.discounts.delete(discountId).then(({ id, object, deleted }) => { console.log(id) }) ``` #### Parameters `", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns ___ ### deleteCondition Delete a discount condition. This doesn't delete resources associated to the discount condition. #### Example ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.discounts .deleteCondition(discountId, conditionId) .then(({ id, object, deleted }) => { console.log(id) }) ``` #### Parameters `", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns ___ ### deleteConditionResourceBatch Remove a batch of resources from a discount condition. This will only remove the association between the resource and the discount condition, not the resource itself. #### Example ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.discounts .deleteConditionResourceBatch(discountId, conditionId, { resources: [{ id: itemId }], }) .then(({ discount }) => { console.log(discount.id) }) ``` #### Parameters `", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `", "description": "An optional key-value map with additional details", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "parent_discount", "type": "[Discount](../internal/classes/internal.Discount-1.mdx)", "description": "The details of the parent discount that this discount was created from.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "parent_discount_id", "type": "`string`", "description": "The Discount that the discount was created from. This will always be a dynamic discount", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "regions", "type": "[Region](../internal/classes/internal.Region.mdx)[]", "description": "The details of the regions in which the Discount can be used.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "rule", "type": "[DiscountRule](../internal/classes/internal.internal.DiscountRule.mdx)", "description": "The details of the discount rule that defines how the discount will be applied to a cart..", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "rule_id", "type": "`string`", "description": "The ID of the discount rule that defines how the discount will be applied to a cart.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "starts_at", "type": "`Date`", "description": "The time at which the discount can be used.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "updated_at", "type": "`Date`", "description": "The date with timezone at which the resource was updated.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "usage_count", "type": "`number`", "description": "The number of times a discount has been used.", "optional": false, "defaultValue": "0", "expandable": false, "children": [] }, { "name": "usage_limit", "type": "``null`` \\| `number`", "description": "The maximum number of times that a discount can be used.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "valid_duration", "type": "``null`` \\| `string`", "description": "Duration the discount runs between", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] } ] } ]} /> ___ ### deleteDynamicCode Delete a dynamic code from a discount. #### Example ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.discounts .deleteDynamicCode(discountId, code) .then(({ discount }) => { console.log(discount.id) }) ``` #### Parameters `", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `", "description": "An optional key-value map with additional details", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "parent_discount", "type": "[Discount](../internal/classes/internal.Discount-1.mdx)", "description": "The details of the parent discount that this discount was created from.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "parent_discount_id", "type": "`string`", "description": "The Discount that the discount was created from. This will always be a dynamic discount", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "regions", "type": "[Region](../internal/classes/internal.Region.mdx)[]", "description": "The details of the regions in which the Discount can be used.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "rule", "type": "[DiscountRule](../internal/classes/internal.internal.DiscountRule.mdx)", "description": "The details of the discount rule that defines how the discount will be applied to a cart..", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "rule_id", "type": "`string`", "description": "The ID of the discount rule that defines how the discount will be applied to a cart.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "starts_at", "type": "`Date`", "description": "The time at which the discount can be used.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "updated_at", "type": "`Date`", "description": "The date with timezone at which the resource was updated.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "usage_count", "type": "`number`", "description": "The number of times a discount has been used.", "optional": false, "defaultValue": "0", "expandable": false, "children": [] }, { "name": "usage_limit", "type": "``null`` \\| `number`", "description": "The maximum number of times that a discount can be used.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "valid_duration", "type": "``null`` \\| `string`", "description": "Duration the discount runs between", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] } ] } ]} /> ___ ### getCondition Retrieve a Discount Condition's details. #### Example A simple example that retrieves a discount condition by its ID: ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.discounts .getCondition(discountId, conditionId) .then(({ discount_condition }) => { console.log(discount_condition.id) }) ``` To specify relations that should be retrieved: ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.discounts .getCondition(discountId, conditionId, { expand: "discount_rule", }) .then(({ discount_condition }) => { console.log(discount_condition.id) }) ``` #### Parameters `", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `", "description": "An optional key-value map with additional details", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "operator", "type": "[DiscountConditionOperator](../internal/enums/internal.DiscountConditionOperator.mdx)", "description": "The operator of the condition. `in` indicates that discountable resources are within the specified resources. `not\\_in` indicates that discountable resources are everything but the specified resources.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "product_collections", "type": "[ProductCollection](../internal/classes/internal.ProductCollection.mdx)[]", "description": "Product collections associated with this condition if `type` is `product\\_collections`.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "product_tags", "type": "[ProductTag](../internal/classes/internal.ProductTag.mdx)[]", "description": "Product tags associated with this condition if `type` is `product\\_tags`.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "product_types", "type": "[ProductType](../internal/classes/internal.ProductType.mdx)[]", "description": "Product types associated with this condition if `type` is `product\\_types`.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "products", "type": "[Product](../internal/classes/internal.Product.mdx)[]", "description": "products associated with this condition if `type` is `products`.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "type", "type": "[DiscountConditionType](../internal/enums/internal.internal.DiscountConditionType.mdx)", "description": "The type of the condition. The type affects the available resources associated with the condition. For example, if the type is `products`, that means the `products` relation will hold the products associated with this condition and other relations will be empty.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "updated_at", "type": "`Date`", "description": "The date with timezone at which the resource was updated.", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] } ] } ]} /> ___ ### list Retrieve a list of Discounts. The discounts can be filtered by fields such as `rule` or `is_dynamic`. The discounts can also be paginated. #### Example To list discounts: ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.discounts.list().then(({ discounts, limit, offset, count }) => { console.log(discounts.id) }) ``` To specify relations that should be retrieved within the discounts: ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.discounts .list({ expand: "rule", }) .then(({ discounts, limit, offset, count }) => { console.log(discounts.id) }) ``` By default, only the first `20` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties: ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.discounts .list({ expand: "rule", limit, offset, }) .then(({ discounts, limit, offset, count }) => { console.log(discounts.id) }) ``` #### Parameters `", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `", "description": "An optional key-value map with additional details", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "parent_discount", "type": "[Discount](../internal/classes/internal.Discount-1.mdx)", "description": "The details of the parent discount that this discount was created from.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "parent_discount_id", "type": "`string`", "description": "The Discount that the discount was created from. This will always be a dynamic discount", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "regions", "type": "[Region](../internal/classes/internal.Region.mdx)[]", "description": "The details of the regions in which the Discount can be used.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "rule", "type": "[DiscountRule](../internal/classes/internal.internal.DiscountRule.mdx)", "description": "The details of the discount rule that defines how the discount will be applied to a cart..", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "rule_id", "type": "`string`", "description": "The ID of the discount rule that defines how the discount will be applied to a cart.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "starts_at", "type": "`Date`", "description": "The time at which the discount can be used.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "updated_at", "type": "`Date`", "description": "The date with timezone at which the resource was updated.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "usage_count", "type": "`number`", "description": "The number of times a discount has been used.", "optional": false, "defaultValue": "0", "expandable": false, "children": [] }, { "name": "usage_limit", "type": "``null`` \\| `number`", "description": "The maximum number of times that a discount can be used.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "valid_duration", "type": "``null`` \\| `string`", "description": "Duration the discount runs between", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] } ] } ]} /> ___ ### removeRegion Remove a Region from the list of Regions that a Discount can be used in. This does not delete a region, only the association between it and the discount. #### Example ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.discounts .removeRegion(discountId, regionId) .then(({ discount }) => { console.log(discount.id) }) ``` #### Parameters `", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `", "description": "An optional key-value map with additional details", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "parent_discount", "type": "[Discount](../internal/classes/internal.Discount-1.mdx)", "description": "The details of the parent discount that this discount was created from.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "parent_discount_id", "type": "`string`", "description": "The Discount that the discount was created from. This will always be a dynamic discount", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "regions", "type": "[Region](../internal/classes/internal.Region.mdx)[]", "description": "The details of the regions in which the Discount can be used.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "rule", "type": "[DiscountRule](../internal/classes/internal.internal.DiscountRule.mdx)", "description": "The details of the discount rule that defines how the discount will be applied to a cart..", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "rule_id", "type": "`string`", "description": "The ID of the discount rule that defines how the discount will be applied to a cart.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "starts_at", "type": "`Date`", "description": "The time at which the discount can be used.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "updated_at", "type": "`Date`", "description": "The date with timezone at which the resource was updated.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "usage_count", "type": "`number`", "description": "The number of times a discount has been used.", "optional": false, "defaultValue": "0", "expandable": false, "children": [] }, { "name": "usage_limit", "type": "``null`` \\| `number`", "description": "The maximum number of times that a discount can be used.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "valid_duration", "type": "``null`` \\| `string`", "description": "Duration the discount runs between", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] } ] } ]} /> ___ ### retrieve Retrieve a discount. #### Example ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.discounts.retrieve(discountId).then(({ discount }) => { console.log(discount.id) }) ``` #### Parameters `", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `", "description": "An optional key-value map with additional details", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "parent_discount", "type": "[Discount](../internal/classes/internal.Discount-1.mdx)", "description": "The details of the parent discount that this discount was created from.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "parent_discount_id", "type": "`string`", "description": "The Discount that the discount was created from. This will always be a dynamic discount", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "regions", "type": "[Region](../internal/classes/internal.Region.mdx)[]", "description": "The details of the regions in which the Discount can be used.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "rule", "type": "[DiscountRule](../internal/classes/internal.internal.DiscountRule.mdx)", "description": "The details of the discount rule that defines how the discount will be applied to a cart..", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "rule_id", "type": "`string`", "description": "The ID of the discount rule that defines how the discount will be applied to a cart.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "starts_at", "type": "`Date`", "description": "The time at which the discount can be used.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "updated_at", "type": "`Date`", "description": "The date with timezone at which the resource was updated.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "usage_count", "type": "`number`", "description": "The number of times a discount has been used.", "optional": false, "defaultValue": "0", "expandable": false, "children": [] }, { "name": "usage_limit", "type": "``null`` \\| `number`", "description": "The maximum number of times that a discount can be used.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "valid_duration", "type": "``null`` \\| `string`", "description": "Duration the discount runs between", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] } ] } ]} /> ___ ### retrieveByCode Retrieve a discount's details by its discount code. #### Example ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.discounts.retrieveByCode(code).then(({ discount }) => { console.log(discount.id) }) ``` #### Parameters `", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `", "description": "An optional key-value map with additional details", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "parent_discount", "type": "[Discount](../internal/classes/internal.Discount-1.mdx)", "description": "The details of the parent discount that this discount was created from.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "parent_discount_id", "type": "`string`", "description": "The Discount that the discount was created from. This will always be a dynamic discount", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "regions", "type": "[Region](../internal/classes/internal.Region.mdx)[]", "description": "The details of the regions in which the Discount can be used.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "rule", "type": "[DiscountRule](../internal/classes/internal.internal.DiscountRule.mdx)", "description": "The details of the discount rule that defines how the discount will be applied to a cart..", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "rule_id", "type": "`string`", "description": "The ID of the discount rule that defines how the discount will be applied to a cart.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "starts_at", "type": "`Date`", "description": "The time at which the discount can be used.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "updated_at", "type": "`Date`", "description": "The date with timezone at which the resource was updated.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "usage_count", "type": "`number`", "description": "The number of times a discount has been used.", "optional": false, "defaultValue": "0", "expandable": false, "children": [] }, { "name": "usage_limit", "type": "``null`` \\| `number`", "description": "The maximum number of times that a discount can be used.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "valid_duration", "type": "``null`` \\| `string`", "description": "Duration the discount runs between", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] } ] } ]} /> ___ ### update Update a discount with a given set of rules that define how the discount is applied. #### Example ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.discounts .update(discountId, { code: "TEST", }) .then(({ discount }) => { console.log(discount.id) }) ``` #### Parameters `", "description": "An object containing metadata of the discount", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "regions", "type": "`string`[]", "description": "A list of region IDs representing the Regions in which the Discount can be used.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "rule", "type": "[AdminUpdateDiscountRule](../internal/classes/internal.AdminUpdateDiscountRule.mdx)", "description": "The discount rule that defines how discounts are calculated", "optional": true, "defaultValue": "", "expandable": false, "children": [ { "name": "allocation", "type": "[AllocationType](../internal/enums/internal.internal.AllocationType.mdx)", "description": "The discount rule's allocation.", "optional": true, "defaultValue": "", "expandable": false, "children": [ { "name": "ITEM", "type": "``\"item\"``", "description": "The discount should be applied to applicable items in the cart.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "TOTAL", "type": "``\"total\"``", "description": "The discount should be applied to the checkout total.", "optional": true, "defaultValue": "", "expandable": false, "children": [] } ] }, { "name": "conditions", "type": "[AdminUpsertCondition](../internal/classes/internal.internal.AdminUpsertCondition.mdx)[]", "description": "The discount rule's discount conditions.", "optional": true, "defaultValue": "", "expandable": false, "children": [ { "name": "customer_groups", "type": "`string`[]", "description": "The customer groups associated with the discount condition, if the discount condition's type is `customer_groups`.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "id", "type": "`string`", "description": "The discount condition's ID.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "operator", "type": "[DiscountConditionOperator](../internal/enums/internal.DiscountConditionOperator.mdx)", "description": "The discount condition's operator.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "product_collections", "type": "`string`[]", "description": "The product collections associated with the discount condition, if the discount condition's type is `product_collections`.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "product_tags", "type": "`string`[]", "description": "The product tags associated with the discount condition, if the discount condition's type is `product_tags`.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "product_types", "type": "`string`[]", "description": "The product types associated with the discount condition, if the discount condition's type is `product_types`.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "products", "type": "`string`[]", "description": "The products associated with the discount condition, if the discount condition's type is `products`.", "optional": true, "defaultValue": "", "expandable": false, "children": [] } ] }, { "name": "description", "type": "`string`", "description": "The discount rule's description.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "id", "type": "`string`", "description": "The discount rule's ID.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "value", "type": "`number`", "description": "The discount rule's value.", "optional": true, "defaultValue": "", "expandable": false, "children": [] } ] }, { "name": "starts_at", "type": "`Date`", "description": "The date and time at which the discount should be available.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "usage_limit", "type": "``null`` \\| `number`", "description": "Maximum number of times the discount can be used", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "valid_duration", "type": "``null`` \\| `string`", "description": "The duration the discount runs between", "optional": true, "defaultValue": "", "expandable": false, "children": [] } ] }, { "name": "customHeaders", "type": "`Record`", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `", "description": "An optional key-value map with additional details", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "parent_discount", "type": "[Discount](../internal/classes/internal.Discount-1.mdx)", "description": "The details of the parent discount that this discount was created from.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "parent_discount_id", "type": "`string`", "description": "The Discount that the discount was created from. This will always be a dynamic discount", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "regions", "type": "[Region](../internal/classes/internal.Region.mdx)[]", "description": "The details of the regions in which the Discount can be used.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "rule", "type": "[DiscountRule](../internal/classes/internal.internal.DiscountRule.mdx)", "description": "The details of the discount rule that defines how the discount will be applied to a cart..", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "rule_id", "type": "`string`", "description": "The ID of the discount rule that defines how the discount will be applied to a cart.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "starts_at", "type": "`Date`", "description": "The time at which the discount can be used.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "updated_at", "type": "`Date`", "description": "The date with timezone at which the resource was updated.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "usage_count", "type": "`number`", "description": "The number of times a discount has been used.", "optional": false, "defaultValue": "0", "expandable": false, "children": [] }, { "name": "usage_limit", "type": "``null`` \\| `number`", "description": "The maximum number of times that a discount can be used.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "valid_duration", "type": "``null`` \\| `string`", "description": "Duration the discount runs between", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] } ] } ]} /> ___ ### updateCondition Update a discount condition. Only one of `products`, `product_types`, `product_collections`, `product_tags`, and `customer_groups` should be provided in the `payload` parameter, based on the type of discount condition. For example, if the discount condition's type is `products`, the `products` field should be provided in the `payload` parameter. #### Example To update a condition in a discount: ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.discounts .updateCondition(discountId, conditionId, { products: [productId], }) .then(({ discount }) => { console.log(discount.id) }) ``` To specify relations that should be retrieved as part of the response: ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.discounts .updateCondition( discountId, conditionId, { products: [productId], ], }, { expand: "rule", } ) .then(({ discount }) => { console.log(discount.id) }) ``` #### Parameters `", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `", "description": "An optional key-value map with additional details", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "parent_discount", "type": "[Discount](../internal/classes/internal.Discount-1.mdx)", "description": "The details of the parent discount that this discount was created from.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "parent_discount_id", "type": "`string`", "description": "The Discount that the discount was created from. This will always be a dynamic discount", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "regions", "type": "[Region](../internal/classes/internal.Region.mdx)[]", "description": "The details of the regions in which the Discount can be used.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "rule", "type": "[DiscountRule](../internal/classes/internal.internal.DiscountRule.mdx)", "description": "The details of the discount rule that defines how the discount will be applied to a cart..", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "rule_id", "type": "`string`", "description": "The ID of the discount rule that defines how the discount will be applied to a cart.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "starts_at", "type": "`Date`", "description": "The time at which the discount can be used.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "updated_at", "type": "`Date`", "description": "The date with timezone at which the resource was updated.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "usage_count", "type": "`number`", "description": "The number of times a discount has been used.", "optional": false, "defaultValue": "0", "expandable": false, "children": [] }, { "name": "usage_limit", "type": "``null`` \\| `number`", "description": "The maximum number of times that a discount can be used.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "valid_duration", "type": "``null`` \\| `string`", "description": "Duration the discount runs between", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] } ] } ]} />