Create Discount
curl --request POST \
--url https://api.launchmystore.io/api/v1/discounts.json \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "<string>",
"type": "<string>",
"value": 123,
"minimum_amount": 123,
"usage_limit": 123,
"once_per_customer": true,
"product_ids": [
{}
],
"starts_at": "<string>",
"ends_at": "<string>"
}
'import requests
url = "https://api.launchmystore.io/api/v1/discounts.json"
payload = {
"code": "<string>",
"type": "<string>",
"value": 123,
"minimum_amount": 123,
"usage_limit": 123,
"once_per_customer": True,
"product_ids": [{}],
"starts_at": "<string>",
"ends_at": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
code: '<string>',
type: '<string>',
value: 123,
minimum_amount: 123,
usage_limit: 123,
once_per_customer: true,
product_ids: [{}],
starts_at: '<string>',
ends_at: '<string>'
})
};
fetch('https://api.launchmystore.io/api/v1/discounts.json', 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.launchmystore.io/api/v1/discounts.json",
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([
'code' => '<string>',
'type' => '<string>',
'value' => 123,
'minimum_amount' => 123,
'usage_limit' => 123,
'once_per_customer' => true,
'product_ids' => [
[
]
],
'starts_at' => '<string>',
'ends_at' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.launchmystore.io/api/v1/discounts.json"
payload := strings.NewReader("{\n \"code\": \"<string>\",\n \"type\": \"<string>\",\n \"value\": 123,\n \"minimum_amount\": 123,\n \"usage_limit\": 123,\n \"once_per_customer\": true,\n \"product_ids\": [\n {}\n ],\n \"starts_at\": \"<string>\",\n \"ends_at\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.launchmystore.io/api/v1/discounts.json")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"<string>\",\n \"type\": \"<string>\",\n \"value\": 123,\n \"minimum_amount\": 123,\n \"usage_limit\": 123,\n \"once_per_customer\": true,\n \"product_ids\": [\n {}\n ],\n \"starts_at\": \"<string>\",\n \"ends_at\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.launchmystore.io/api/v1/discounts.json")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"code\": \"<string>\",\n \"type\": \"<string>\",\n \"value\": 123,\n \"minimum_amount\": 123,\n \"usage_limit\": 123,\n \"once_per_customer\": true,\n \"product_ids\": [\n {}\n ],\n \"starts_at\": \"<string>\",\n \"ends_at\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyDiscounts
Create Discount
Create a new discount code
POST
/
api
/
v1
/
discounts.json
Create Discount
curl --request POST \
--url https://api.launchmystore.io/api/v1/discounts.json \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "<string>",
"type": "<string>",
"value": 123,
"minimum_amount": 123,
"usage_limit": 123,
"once_per_customer": true,
"product_ids": [
{}
],
"starts_at": "<string>",
"ends_at": "<string>"
}
'import requests
url = "https://api.launchmystore.io/api/v1/discounts.json"
payload = {
"code": "<string>",
"type": "<string>",
"value": 123,
"minimum_amount": 123,
"usage_limit": 123,
"once_per_customer": True,
"product_ids": [{}],
"starts_at": "<string>",
"ends_at": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
code: '<string>',
type: '<string>',
value: 123,
minimum_amount: 123,
usage_limit: 123,
once_per_customer: true,
product_ids: [{}],
starts_at: '<string>',
ends_at: '<string>'
})
};
fetch('https://api.launchmystore.io/api/v1/discounts.json', 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.launchmystore.io/api/v1/discounts.json",
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([
'code' => '<string>',
'type' => '<string>',
'value' => 123,
'minimum_amount' => 123,
'usage_limit' => 123,
'once_per_customer' => true,
'product_ids' => [
[
]
],
'starts_at' => '<string>',
'ends_at' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.launchmystore.io/api/v1/discounts.json"
payload := strings.NewReader("{\n \"code\": \"<string>\",\n \"type\": \"<string>\",\n \"value\": 123,\n \"minimum_amount\": 123,\n \"usage_limit\": 123,\n \"once_per_customer\": true,\n \"product_ids\": [\n {}\n ],\n \"starts_at\": \"<string>\",\n \"ends_at\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.launchmystore.io/api/v1/discounts.json")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"<string>\",\n \"type\": \"<string>\",\n \"value\": 123,\n \"minimum_amount\": 123,\n \"usage_limit\": 123,\n \"once_per_customer\": true,\n \"product_ids\": [\n {}\n ],\n \"starts_at\": \"<string>\",\n \"ends_at\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.launchmystore.io/api/v1/discounts.json")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"code\": \"<string>\",\n \"type\": \"<string>\",\n \"value\": 123,\n \"minimum_amount\": 123,\n \"usage_limit\": 123,\n \"once_per_customer\": true,\n \"product_ids\": [\n {}\n ],\n \"starts_at\": \"<string>\",\n \"ends_at\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyCreate Discount
Creates a new discount code in the store. Requires thewrite_discounts scope.
Request
curl -X POST "https://api.launchmystore.io/api/v1/discounts.json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"code": "SUMMER20",
"type": "percentage",
"value": 20,
"usage_limit": 500,
"once_per_customer": true,
"minimum_amount": 50,
"starts_at": "2024-06-01T00:00:00Z",
"ends_at": "2024-08-31T23:59:59Z"
}'
const response = await fetch('https://api.launchmystore.io/api/v1/discounts.json', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify({
code: 'SUMMER20',
type: 'percentage',
value: 20,
usage_limit: 500,
once_per_customer: true,
minimum_amount: 50,
starts_at: '2024-06-01T00:00:00Z',
ends_at: '2024-08-31T23:59:59Z'
})
});
Body Parameters
string
required
Unique discount code. A discount with an existing code is rejected.
string
required
Discount type. One of
percentage, fixed_amount, free_shipping,
buy_x_get_y.number
required
Discount value. For
percentage, enter 20 for 20%. For fixed_amount,
enter the amount in the store’s currency (e.g. 20 for 20.00). Ignored for
free_shipping.number
Minimum order total required for the discount to apply.
integer
Maximum number of times the discount can be used across all customers.
Defaults to
0 (unlimited) when omitted.boolean
default:"false"
When
true, limits the discount to one use per customer.array
Array of product IDs the discount is restricted to. Omit to apply the
discount store-wide.
string
Start date (ISO 8601). Omit for no start constraint.
string
End date (ISO 8601). Omit for no expiration.
The merchant dashboard supports additional discount capabilities —
minimum quantity, buy-X-get-Y quantities and free-item rewards, and
new-customer eligibility. These are configured through the merchant
surface and are not part of the OAuth App-API create body; any extra
fields sent here are ignored.
Response
The created discount is returned underdata.discount in the standard
response envelope.
{
"status": 201,
"state": "success",
"message": null,
"data": {
"discount": {
"couponId": "9f1c2e7a-3b4d-4f5a-8c6b-1d2e3f4a5b6c",
"code": "SUMMER20",
"type": "Percentage",
"status": "Active",
"discountPercentage": 20,
"discountAmount": null,
"minOrderTotal": 50,
"startDate": "2024-06-01T00:00:00Z",
"endDate": "2024-08-31T23:59:59Z",
"totalCoupons": 500,
"usesPerCustomer": 1,
"applyOnProducts": [],
"storeId": "1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d",
"createdAt": "2024-05-15T10:00:00Z",
"updatedAt": "2024-05-15T10:00:00Z"
}
},
"count": null,
"pagination": null
}
Errors
| Status | state | Message |
|---|---|---|
422 | error | Body-validation failure — missing code, invalid type, negative value, etc. Returned as { "errors": { ... } } (class-validator maps to 422). |
400 | error | Discount with this code already exists (service-level conflict) |
401 | error | Invalid or missing access token |
403 | error | App is missing the write_discounts scope |