Discounts
Discounts allow you to offer promotional pricing to your customers. They can be either a fixed amount discount or a percentage discount, and can apply to all products or specific products only. Discounts can be associated with promotion codes that customers can redeem during checkout.
The Discount object
- Name
object
- Type
- "discount",
- Description
- Literal representing the object’s type.
- Name
id
- Type
- string,
- Description
- Unique identifier for the object.
- Name
live
- Type
- boolean,
- Description
- Has the value
trueif the object exists in a production environment or the valuefalseif the object exists in a sandbox environment.
- Name
created_at
- Type
- integer,
- Description
- Time at which the object was created. Measured in milliseconds since the Unix epoch.
- Name
amount_off
- Type
- integer or null,
- Description
- The flat rate discount amount in cents
- Name
applies_to
- Type
- array of Products or null or null,
- Description
- Expandable. The products this discount applies to. When null, applies to all products.
- Name
deleted
- Type
- boolean,
- Description
- Whether the discount has been deleted.
- Name
metadata
- Type
- object,
- Description
- A key-value store that is attached to the object. Useful for storing miscellaneous structured data for your integration’s internal use.
- Name
name
- Type
- string,
- Description
- The discount’s name as shown to customers.
- Name
percent_off
- Type
- number or null,
- Description
- The percentage discount amount (e.g. 15 for 15%)
- Name
promotion_code
- Type
- string or null,
- Description
- Customer-redeemable code that can be used to apply this coupon to an order.
- Name
updated_at
- Type
- integer,
- Description
- Time at which the object was last updated. Measured in milliseconds since the Unix epoch.
The Discount object
Create a discount
Creates a new discount. You must specify either amount_off or percent_off, but not both.
Required parameters
- Name
name
- Type
- string,
- Description
- The discount’s name as shown to customers.
Optional parameters
- Name
amount_off
- Type
- integer or null,
- Description
- The flat rate discount amount in cents
- Name
percent_off
- Type
- number or null,
- Description
- The percentage discount amount (e.g. 15 for 15%)
- Name
promotion_code
- Type
- string or null,
- Description
- Customer-redeemable code that can be used to apply this coupon to an order.
- Name
applies_to
- Type
- array of string or null,
- Description
- Expandable. The products this discount applies to. When null, applies to all products.
- Name
metadata
- Type
- object or null,
- Description
- A key-value store that is attached to the object. Useful for storing miscellaneous structured data for your integration’s internal use.
Returns
Returns the discount object.
Create a discount
Response example
Get a discount
Retrieve a discount by its ID.
Optional parameters
- Name
expand
- Type
- object,
- Description
- Optional object that allows you to expand certain ID fields to include related resources.
- Properties
Returns
Returns the discount object.
Retrieve a discount
Response example
Update a discount
Updates the specified discount by setting the values of the parameters passed.
Optional parameters
- Name
name
- Type
- string,
- Description
- The discount’s name as shown to customers.
- Name
promotion_code
- Type
- string or null,
- Description
- Customer-redeemable code that can be used to apply this coupon to an order.
- Name
metadata
- Type
- object or null,
- Description
- A key-value store that is attached to the object. Useful for storing miscellaneous structured data for your integration’s internal use.
Returns
Returns the updated discount object.
Update a discount
Response example
List all discounts
Returns a list of your discounts. Discounts are returned in reverse chronological order, with the most recently created discounts appearing first.
Optional parameters
- Name
expand
- Type
- object,
- Description
- Optional object that allows you to expand certain ID fields to include related resources.
- Properties
- Name
ending_before
- Type
- string,
- Description
- A cursor for use in pagination.
ending_beforeis an object ID that results will end before. Used to move backward through the list.
- Name
starting_after
- Type
- string,
- Description
- A cursor for use in pagination.
starting_afteris an object ID that results will start after. Used to move forward through the list.
- Name
limit
- Type
- number, at least 1, at most 1000, default is 50
- Description
- Maximum number of objects to return.
- Name
filters
- Type
- object, object, or object,
- Description
- Filters to apply to the list. Combine multiple conditions with
andandor. - Properties
Returns
Returns a list of discount objects.
List all discounts
Response example
Delete a discount
Deletes a discount. Deleted discounts cannot be retrieved or used for new purchases, but existing line items and checkout sessions using the discount will continue to work.
Returns
A deleted object stub.