POST
/
discounts
import DodoPayments from 'dodopayments';

const client = new DodoPayments({
  bearerToken: process.env['DODO_PAYMENTS_API_KEY'], // This is the default and can be omitted
});

async function main() {
  const discount = await client.discounts.create({ amount: 0, type: 'percentage' });

  console.log(discount.business_id);
}

main();
{
  "amount": 123,
  "business_id": "<string>",
  "code": "<string>",
  "created_at": "2023-11-07T05:31:56Z",
  "discount_id": "<string>",
  "expires_at": "2023-11-07T05:31:56Z",
  "name": "<string>",
  "restricted_to": [
    "<string>"
  ],
  "times_used": 123,
  "type": "percentage",
  "usage_limit": 123
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

Request body for creating a discount.

code is optional; if not provided, we generate a random 16-char code.

amount
integer
required

The discount amount.

  • If discount_type is not percentage, amount is in USD cents. For example, 100 means $1.00. Only USD is allowed.
  • If discount_type is percentage, amount is in basis points. For example, 540 means 5.4%.

Must be at least 1.

type
enum<string>
required
Available options:
percentage
code
string | null

Optionally supply a code (will be uppercased).

  • Must be at least 3 characters if provided.
  • If omitted, a random 16-character code is generated.
expires_at
string | null

When the discount expires, if ever.

name
string | null
restricted_to
string[] | null

List of product IDs to restrict usage (if any).

usage_limit
integer | null

How many times this discount can be used (if any). Must be >= 1 if provided.

Response

200 - application/json
Created discount
amount
integer
required

The discount amount.

  • If discount_type is percentage, this is in basis points (e.g., 540 => 5.4%).
  • Otherwise, this is USD cents (e.g., 100 => $1.00).
business_id
string
required

The business this discount belongs to.

code
string
required

The discount code (up to 16 chars).

created_at
string
required

Timestamp when the discount is created

discount_id
string
required

The unique discount ID

restricted_to
string[]
required

List of product IDs to which this discount is restricted.

times_used
integer
required

How many times this discount has been used.

type
enum<string>
required
Available options:
percentage
expires_at
string | null

Optional date/time after which discount is expired.

name
string | null

Name for the Discount

usage_limit
integer | null

Usage limit for this discount, if any.