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 true if the object exists in a production environment or the value false if 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

{
  "object": "discount",
  "id": "disc_0yejjs3V3DfgTCMZdtKIu7",
  "live": false,
  "created_at": 1750000000000,
  "updated_at": 1750000000000,
  "deleted": false,
  "name": "10% off",
  "amount_off": null,
  "percent_off": 10,
  "promotion_code": "SAVE10",
  "applies_to": null,
  "metadata": {}
}

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

const discount = await bias.discounts.create({
  name: "10% off",
  percent_off: 10,
  promotion_code: "SAVE10",
  applies_to: null,
  metadata: {}
});

Response example

{
  "object": "discount",
  "id": "disc_0yejjs3V3DfgTCMZdtKIu7",
  "live": false,
  "created_at": 1750000000000,
  "updated_at": 1750000000000,
  "deleted": false,
  "name": "10% off",
  "amount_off": null,
  "percent_off": 10,
  "promotion_code": "SAVE10",
  "applies_to": null,
  "metadata": {}
}

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

const discount = await bias.discounts.get("id");

Response example

{
  "object": "discount",
  "id": "disc_0yejjs3V3DfgTCMZdtKIu7",
  "live": false,
  "created_at": 1750000000000,
  "updated_at": 1750000000000,
  "deleted": false,
  "name": "10% off",
  "amount_off": null,
  "percent_off": 10,
  "promotion_code": "SAVE10",
  "applies_to": null,
  "metadata": {}
}

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

const discount = await bias.discounts.update("id", {
  name: "Summer discount",
  promotion_code: "SUMMER10"
});

Response example

{
  "object": "discount",
  "id": "disc_0yejjs3V3DfgTCMZdtKIu7",
  "live": false,
  "created_at": 1750000000000,
  "updated_at": 1750000000000,
  "deleted": false,
  "name": "10% off",
  "amount_off": null,
  "percent_off": 10,
  "promotion_code": "SAVE10",
  "applies_to": null,
  "metadata": {}
}

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_before is 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_after is 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 and and or.
Properties

Returns

Returns a list of discount objects.

List all discounts

const discount = await bias.discounts.list();

Response example

{
  "object": "list",
  "items": {
    "object": "discount",
    "id": "disc_0yejjs3V3DfgTCMZdtKIu7",
    "live": false,
    "created_at": 1750000000000,
    "updated_at": 1750000000000,
    "deleted": false,
    "name": "10% off",
    "amount_off": null,
    "percent_off": 10,
    "promotion_code": "SAVE10",
    "applies_to": null,
    "metadata": {}
  },
  "has_more": false
}

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.

Delete a discount

const discount = await bias.discounts.delete("id");

Response example

{
  "object": "discount",
  "id": "disc_0yejjs3V3DfgTCMZdtKIu7",
  "deleted": true
}