Skip to main content
POST
Creates a discount, or updates the one with the same external_id.

Authorizations

x-api-key
string
header
required

API key for authentication. You can find your API key in the Creem dashboard under Settings > API Keys.

Headers

Idempotency-Key
string

Deprecated: send an external_id, which makes a retry an update of the discount the first call created. Without an external_id, a retry with the same key returns the originally created discount instead of creating a duplicate; reusing a key with a different body returns the first result, and a key lasts 24 hours. After a failed create whose outcome is unclear, the key answers 429 for up to 5 minutes. With an external_id the header is ignored.

If-None-Match
string

Send * to create only: when a discount of the store already has the external_id, the call answers 412 (precondition_failed) and writes nothing. Only * is accepted on a request with an external_id; without one the header is ignored.

Query Parameters

dry_run
boolean

Send true to preview the write: the request runs as it would and is rolled back, so nothing is written, no Stripe API is called, and Idempotency-Key is neither read nor stored. The answer is the one the real call would give: the same status and errors, and the discount with write_result.dry_run true. The id of a new discount is never stored: a GET of it answers 404. A key in applies_to_product_external_ids that names no product is a reference_not_found warning (path, key) instead of a 400: a new discount leaves that product out, and an existing one keeps its stored products. false or no parameter is a real call; any other value answers 400.

Body

application/json

Discount creation payload. name, type and duration are required when creating a discount; an update by external_id may leave them out.

name
string

The name of the discount. Required when creating a discount.

Example:

"Holiday Sale"

code
string

Optional discount code, case-insensitive (stored upper-cased). If left empty, a code will be generated. The code of an existing discount cannot change: a different code sent with its external_id is ignored with a field_not_writable warning.

Example:

"HOLIDAY2024"

type
enum<string>

The type of the discount. Fixed once the discount has been redeemed, or while a checkout confirmed with it in the last 7 days holds it (409 discount_redeemed); the same applies to amount, percentage, currency, duration and duration_in_months. Changing it needs the new amount or percentage.

Available options:
percentage,
fixed
amount
number

The fixed value for the discount. Only applicable if the type is "fixed".

Example:

20

currency
string

The currency of the discount. Only required if type is "fixed".

Example:

"USD"

percentage
number

The percentage value for the discount. Only applicable if the type is "percentage".

Example:

15

expiry_date
string<date-time>

The expiry date of the discount.

Example:

"2024-12-31T23:59:59Z"

max_redemptions
number

The maximum number of redemptions for the discount.

Example:

100

duration
enum<string>

The duration type. Fixed once the discount has been redeemed.

Available options:
forever,
once,
repeating
Example:

"repeating"

duration_in_months
number

The number of months the discount is valid for. Only applicable if the duration is "repeating" and the product is a subscription.

Example:

6

applies_to_products
string[]

The list of product IDs to which this discount applies. The discount covers these products and the ones in applies_to_product_external_ids; at least one product is required across both lists.

Example:
applies_to_product_external_ids
string[]

Products this discount applies to, named by their external_id, at most 100. Combined with applies_to_products; a key no product of your store has answers 400 with code reference_not_found.

Example:
external_id
string

Your own key for the discount, unique in your store: 1 to 255 characters: letters, digits, _, -, . and :. Case-sensitive. With a key the call is an upsert: a new key creates the discount, and a key a discount of your store holds updates that discount. Deleting a discount frees its key.

Example:

"spring-2026"

Response

Successfully created or updated the discount

id
string
required

Unique identifier for the object.

mode
enum<string>
required

String representing the environment.

Available options:
test,
prod,
sandbox
object
string
required

A string representing the object’s type. Objects of the same type share the same value.

Example:

"discount"

status
enum<string>
required

The status of the discount (e.g., active, inactive).

Available options:
deleted,
active,
draft,
expired,
scheduled
Example:

"active"

name
string
required

The name of the discount.

Example:

"Holiday Sale"

code
string
required

The discount code. A unique identifier for the discount.

Example:

"HOLIDAY2024"

type
enum<string>
required

The type of the discount, either "percentage" or "fixed".

Available options:
percentage,
fixed
Example:

"percentage"

external_id
string | null
required

Your own key for the discount, unique in your store. null when the discount has none.

Example:

"spring-2026"

write_result
object
required

What the write did.

amount
number

The amount of the discount. Can be a percentage or a fixed amount.

Example:

20

currency
string

The currency of the discount. Only required if type is "fixed".

Example:

"USD"

percentage
number

The percentage of the discount. Only applicable if type is "percentage".

Example:

15

expiry_date
string<date-time>

The expiry date of the discount.

Example:

"2024-12-31T23:59:59Z"

max_redemptions
number

The maximum number of redemptions allowed for the discount.

Example:

100

duration
enum<string>

The duration type for the discount.

Available options:
forever,
once,
repeating
Example:

"repeating"

duration_in_months
number

The number of months the discount is valid for. Only applicable if the duration is "repeating" and the product is a subscription.

Example:

6

applies_to_products
string[]

The list of product IDs to which this discount applies.

Example:
redeem_count
number

The number of times this discount has been redeemed.

Example:

15