curl --request POST \
--url https://api.creem.io/v1/discounts \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"name": "Holiday Sale",
"code": "HOLIDAY2024",
"amount": 20,
"currency": "USD",
"percentage": 15,
"expiry_date": "2024-12-31T23:59:59Z",
"max_redemptions": 100,
"duration": "repeating",
"duration_in_months": 6,
"applies_to_products": [
"prod_123",
"prod_456"
],
"applies_to_product_external_ids": [
"pro-monthly"
],
"external_id": "spring-2026"
}
'import requests
url = "https://api.creem.io/v1/discounts"
payload = {
"name": "Holiday Sale",
"code": "HOLIDAY2024",
"amount": 20,
"currency": "USD",
"percentage": 15,
"expiry_date": "2024-12-31T23:59:59Z",
"max_redemptions": 100,
"duration": "repeating",
"duration_in_months": 6,
"applies_to_products": ["prod_123", "prod_456"],
"applies_to_product_external_ids": ["pro-monthly"],
"external_id": "spring-2026"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Holiday Sale',
code: 'HOLIDAY2024',
amount: 20,
currency: 'USD',
percentage: 15,
expiry_date: '2024-12-31T23:59:59Z',
max_redemptions: 100,
duration: 'repeating',
duration_in_months: 6,
applies_to_products: ['prod_123', 'prod_456'],
applies_to_product_external_ids: ['pro-monthly'],
external_id: 'spring-2026'
})
};
fetch('https://api.creem.io/v1/discounts', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.creem.io/v1/discounts",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Holiday Sale',
'code' => 'HOLIDAY2024',
'amount' => 20,
'currency' => 'USD',
'percentage' => 15,
'expiry_date' => '2024-12-31T23:59:59Z',
'max_redemptions' => 100,
'duration' => 'repeating',
'duration_in_months' => 6,
'applies_to_products' => [
'prod_123',
'prod_456'
],
'applies_to_product_external_ids' => [
'pro-monthly'
],
'external_id' => 'spring-2026'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.creem.io/v1/discounts"
payload := strings.NewReader("{\n \"name\": \"Holiday Sale\",\n \"code\": \"HOLIDAY2024\",\n \"amount\": 20,\n \"currency\": \"USD\",\n \"percentage\": 15,\n \"expiry_date\": \"2024-12-31T23:59:59Z\",\n \"max_redemptions\": 100,\n \"duration\": \"repeating\",\n \"duration_in_months\": 6,\n \"applies_to_products\": [\n \"prod_123\",\n \"prod_456\"\n ],\n \"applies_to_product_external_ids\": [\n \"pro-monthly\"\n ],\n \"external_id\": \"spring-2026\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.creem.io/v1/discounts")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Holiday Sale\",\n \"code\": \"HOLIDAY2024\",\n \"amount\": 20,\n \"currency\": \"USD\",\n \"percentage\": 15,\n \"expiry_date\": \"2024-12-31T23:59:59Z\",\n \"max_redemptions\": 100,\n \"duration\": \"repeating\",\n \"duration_in_months\": 6,\n \"applies_to_products\": [\n \"prod_123\",\n \"prod_456\"\n ],\n \"applies_to_product_external_ids\": [\n \"pro-monthly\"\n ],\n \"external_id\": \"spring-2026\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.creem.io/v1/discounts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Holiday Sale\",\n \"code\": \"HOLIDAY2024\",\n \"amount\": 20,\n \"currency\": \"USD\",\n \"percentage\": 15,\n \"expiry_date\": \"2024-12-31T23:59:59Z\",\n \"max_redemptions\": 100,\n \"duration\": \"repeating\",\n \"duration_in_months\": 6,\n \"applies_to_products\": [\n \"prod_123\",\n \"prod_456\"\n ],\n \"applies_to_product_external_ids\": [\n \"pro-monthly\"\n ],\n \"external_id\": \"spring-2026\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"mode": "test",
"object": "discount",
"status": "active",
"name": "Holiday Sale",
"code": "HOLIDAY2024",
"type": "percentage",
"external_id": "spring-2026",
"write_result": {
"result": "updated",
"dry_run": false,
"changes": [
{
"path": "expiry_date",
"from": null,
"to": "2026-12-31T23:59:59.000Z"
}
],
"warnings": [
{
"code": "field_not_writable",
"path": "code",
"key": "<string>"
}
]
},
"amount": 20,
"currency": "USD",
"percentage": 15,
"expiry_date": "2024-12-31T23:59:59Z",
"max_redemptions": 100,
"duration": "repeating",
"duration_in_months": 6,
"applies_to_products": [
"prod_123",
"prod_456"
],
"redeem_count": 15
}{
"trace_id": "<string>",
"status": 429,
"error": "Too Many Requests",
"message": [
"A discount create with this idempotency key is already in progress. Please retry."
],
"timestamp": 123
}Creates a discount, or updates the one with the same external_id
Create promotional discount codes for products. Set percentage or fixed amount discounts with expiration dates. With an external_id the call is an upsert: it creates the discount when the key is new and updates the discount that holds the key otherwise. It matches by external_id only, never by code. Only the fields you send change, each with the meaning PATCH /v1/discounts/{id} gives it; the code cannot change, and a different code is ignored with a field_not_writable warning (a difference only in case is no change). A request that changes nothing answers unchanged and writes nothing, so retrying after a timeout is safe. The discount comes back with write_result. Send If-None-Match: * to create only.
curl --request POST \
--url https://api.creem.io/v1/discounts \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"name": "Holiday Sale",
"code": "HOLIDAY2024",
"amount": 20,
"currency": "USD",
"percentage": 15,
"expiry_date": "2024-12-31T23:59:59Z",
"max_redemptions": 100,
"duration": "repeating",
"duration_in_months": 6,
"applies_to_products": [
"prod_123",
"prod_456"
],
"applies_to_product_external_ids": [
"pro-monthly"
],
"external_id": "spring-2026"
}
'import requests
url = "https://api.creem.io/v1/discounts"
payload = {
"name": "Holiday Sale",
"code": "HOLIDAY2024",
"amount": 20,
"currency": "USD",
"percentage": 15,
"expiry_date": "2024-12-31T23:59:59Z",
"max_redemptions": 100,
"duration": "repeating",
"duration_in_months": 6,
"applies_to_products": ["prod_123", "prod_456"],
"applies_to_product_external_ids": ["pro-monthly"],
"external_id": "spring-2026"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Holiday Sale',
code: 'HOLIDAY2024',
amount: 20,
currency: 'USD',
percentage: 15,
expiry_date: '2024-12-31T23:59:59Z',
max_redemptions: 100,
duration: 'repeating',
duration_in_months: 6,
applies_to_products: ['prod_123', 'prod_456'],
applies_to_product_external_ids: ['pro-monthly'],
external_id: 'spring-2026'
})
};
fetch('https://api.creem.io/v1/discounts', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.creem.io/v1/discounts",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Holiday Sale',
'code' => 'HOLIDAY2024',
'amount' => 20,
'currency' => 'USD',
'percentage' => 15,
'expiry_date' => '2024-12-31T23:59:59Z',
'max_redemptions' => 100,
'duration' => 'repeating',
'duration_in_months' => 6,
'applies_to_products' => [
'prod_123',
'prod_456'
],
'applies_to_product_external_ids' => [
'pro-monthly'
],
'external_id' => 'spring-2026'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.creem.io/v1/discounts"
payload := strings.NewReader("{\n \"name\": \"Holiday Sale\",\n \"code\": \"HOLIDAY2024\",\n \"amount\": 20,\n \"currency\": \"USD\",\n \"percentage\": 15,\n \"expiry_date\": \"2024-12-31T23:59:59Z\",\n \"max_redemptions\": 100,\n \"duration\": \"repeating\",\n \"duration_in_months\": 6,\n \"applies_to_products\": [\n \"prod_123\",\n \"prod_456\"\n ],\n \"applies_to_product_external_ids\": [\n \"pro-monthly\"\n ],\n \"external_id\": \"spring-2026\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.creem.io/v1/discounts")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Holiday Sale\",\n \"code\": \"HOLIDAY2024\",\n \"amount\": 20,\n \"currency\": \"USD\",\n \"percentage\": 15,\n \"expiry_date\": \"2024-12-31T23:59:59Z\",\n \"max_redemptions\": 100,\n \"duration\": \"repeating\",\n \"duration_in_months\": 6,\n \"applies_to_products\": [\n \"prod_123\",\n \"prod_456\"\n ],\n \"applies_to_product_external_ids\": [\n \"pro-monthly\"\n ],\n \"external_id\": \"spring-2026\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.creem.io/v1/discounts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Holiday Sale\",\n \"code\": \"HOLIDAY2024\",\n \"amount\": 20,\n \"currency\": \"USD\",\n \"percentage\": 15,\n \"expiry_date\": \"2024-12-31T23:59:59Z\",\n \"max_redemptions\": 100,\n \"duration\": \"repeating\",\n \"duration_in_months\": 6,\n \"applies_to_products\": [\n \"prod_123\",\n \"prod_456\"\n ],\n \"applies_to_product_external_ids\": [\n \"pro-monthly\"\n ],\n \"external_id\": \"spring-2026\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"mode": "test",
"object": "discount",
"status": "active",
"name": "Holiday Sale",
"code": "HOLIDAY2024",
"type": "percentage",
"external_id": "spring-2026",
"write_result": {
"result": "updated",
"dry_run": false,
"changes": [
{
"path": "expiry_date",
"from": null,
"to": "2026-12-31T23:59:59.000Z"
}
],
"warnings": [
{
"code": "field_not_writable",
"path": "code",
"key": "<string>"
}
]
},
"amount": 20,
"currency": "USD",
"percentage": 15,
"expiry_date": "2024-12-31T23:59:59Z",
"max_redemptions": 100,
"duration": "repeating",
"duration_in_months": 6,
"applies_to_products": [
"prod_123",
"prod_456"
],
"redeem_count": 15
}{
"trace_id": "<string>",
"status": 429,
"error": "Too Many Requests",
"message": [
"A discount create with this idempotency key is already in progress. Please retry."
],
"timestamp": 123
}Authorizations
Headers
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.
Query Parameters
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
Discount creation payload. name, type and duration are required when creating a discount; an update by external_id may leave them out.
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.
percentage, fixed 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.
"spring-2026"
Response
Successfully created or updated the discount