Skip to main content
POST
/
v1
/
discounts
TypeScript SDK
import { Solifyn } from 'solifyn';

const solifyn = new Solifyn({ apiKey: 'your_private_api_key_here' });

// Create a new discount code
const discount = await solifyn.discounts.create({
  code: 'SUMMER25',
  name: 'Summer Sale',
  type: 'percentage',
  amount: 25
});
console.log('Discount Created:', discount);
{
  "id": "disc_cs8f67sd7f6fw3fs",
  "discount_id": "disc_cs8f67sd7f6fw3fs",
  "code": "<string>",
  "amount": 123,
  "usageLimit": 123,
  "timesUsed": 123,
  "expiresAt": "2023-11-07T05:31:56Z",
  "businessId": "<string>",
  "createdAt": "2023-11-07T05:31:56Z",
  "updatedAt": "2023-11-07T05:31:56Z",
  "name": "<string>"
}

Authorizations

Authorization
string
header
required

Authenticate requests using your standard bearer API key (e.g. YOUR_API_KEY).

Body

application/json
code
string
required

Unique discount code string (will be automatically capitalized).

type
enum<string>
required

Calculation type: percentage or fixed_amount.

Available options:
percentage,
fixed_amount
amount
number
required

The discount value. If percentage, enter value like 10 for 10%. If fixed_amount, enter value like 10 for $10.00.

name
string

Customer-facing name of the discount.

usage_limit
integer | null

Maximum number of redemptions allowed.

expires_at
string<date-time> | null

Expiration timestamp for the discount.

subscription_cycles
integer | null

Number of subscription cycles this discount applies to.

restricted_to
string[]

List of product IDs this discount is restricted to.

preserve_on_plan_change
boolean

Whether to preserve the discount when subscription plan changes.

metadata
object

Custom metadata for the discount.

Response

201 - application/json

Discount created successfully.

Represents a discount code created under your business, containing type, amount, usage limits, and expiration details.

id
string
required

The unique prefix-based identifier of the discount (e.g., disc_cs8f67sd7f6fw3fs).

Example:

"disc_cs8f67sd7f6fw3fs"

discount_id
string
required

Alias for the unique identifier of the discount.

Example:

"disc_cs8f67sd7f6fw3fs"

code
string
required

The unique discount code (e.g. SAVE10) used during checkout.

type
enum<string>
required

The discount calculation type: percentage or fixed_amount.

Available options:
percentage,
fixed_amount
amount
integer
required

The discount value. For percentage type, it is in basis points (e.g. 1000 = 10.00%). For fixed_amount type, it is in cents (e.g. 1000 = $10.00).

usageLimit
integer | null
required

Maximum number of times this discount code can be redeemed. Null represents unlimited usage.

timesUsed
integer
required

The number of times this discount code has been successfully redeemed.

expiresAt
string<date-time> | null
required

The expiration timestamp after which the discount code is no longer valid.

status
enum<string>
required

The current status of the discount.

Available options:
active,
expired
businessId
string
required

The unique identifier associated with the business this discount belongs to.

createdAt
string<date-time>
required

Timestamp indicating exactly when the discount was created.

updatedAt
string<date-time>
required

Timestamp indicating when the discount was last updated.

name
string

The customer-facing name of the discount code (e.g. Summer Sale).