Coupons
Create coupon
Creates a coupon for the authenticated shop.
POST
/
dev
/
v1
/
coupons
Create coupon
curl --request POST \
--url https://api.shoppex.io/dev/v1/coupons \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "SAVE10",
"discount_value": 10,
"discount_type": "PERCENTAGE",
"max_uses": 100,
"products_bound": [
"prod_1"
],
"min_order_amount": 20,
"max_discount": 50,
"valid_from": "2026-04-01T00:00:00.000Z",
"valid_until": "2026-05-01T00:00:00.000Z"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
code: 'SAVE10',
discount_value: 10,
discount_type: 'PERCENTAGE',
max_uses: 100,
products_bound: ['prod_1'],
min_order_amount: 20,
max_discount: 50,
valid_from: '2026-04-01T00:00:00.000Z',
valid_until: '2026-05-01T00:00:00.000Z'
})
};
fetch('https://api.shoppex.io/dev/v1/coupons', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.shoppex.io/dev/v1/coupons"
payload = {
"code": "SAVE10",
"discount_value": 10,
"discount_type": "PERCENTAGE",
"max_uses": 100,
"products_bound": ["prod_1"],
"min_order_amount": 20,
"max_discount": 50,
"valid_from": "2026-04-01T00:00:00.000Z",
"valid_until": "2026-05-01T00:00:00.000Z"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.shoppex.io/dev/v1/coupons",
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' => 'SAVE10',
'discount_value' => 10,
'discount_type' => 'PERCENTAGE',
'max_uses' => 100,
'products_bound' => [
'prod_1'
],
'min_order_amount' => 20,
'max_discount' => 50,
'valid_from' => '2026-04-01T00:00:00.000Z',
'valid_until' => '2026-05-01T00:00:00.000Z'
]),
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.shoppex.io/dev/v1/coupons"
payload := strings.NewReader("{\n \"code\": \"SAVE10\",\n \"discount_value\": 10,\n \"discount_type\": \"PERCENTAGE\",\n \"max_uses\": 100,\n \"products_bound\": [\n \"prod_1\"\n ],\n \"min_order_amount\": 20,\n \"max_discount\": 50,\n \"valid_from\": \"2026-04-01T00:00:00.000Z\",\n \"valid_until\": \"2026-05-01T00:00:00.000Z\"\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))
}{
"data": {
"id": "coupon_db_1",
"uniqid": "coupon_1",
"shop_id": "shop_1",
"type": "PERCENTAGE",
"code": "save10",
"discount": 10,
"used": 0,
"max_uses": 100,
"min_order_amount": 20,
"max_discount": 50,
"valid_from": 1711929600,
"valid_until": 1714521600,
"is_active": true,
"created_at": 1711929600,
"updated_at": 1711929600,
"products_bound": [
"prod_1"
],
"products_count": 1
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"details": [
{
"field": "<string>",
"message": "<string>"
}
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"details": [
{
"field": "<string>",
"message": "<string>"
}
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"details": [
{
"field": "<string>",
"message": "<string>"
}
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"details": [
{
"field": "<string>",
"message": "<string>"
}
]
}
}Authorizations
Use your Shoppex API key in the Authorization header.
Body
application/jsonmultipart/form-datatext/plain
Required string length:
1 - 64Required range:
x >= 1e-9Available options:
PERCENTAGE Response
Successful response
Show child attributes
Show child attributes
Previous
Validate coupon by codeValidates a coupon server-side by code. Use `product_id` for single-product checks or `cart` with a JSON string payload for cart validation.
Next
⌘I
Create coupon
curl --request POST \
--url https://api.shoppex.io/dev/v1/coupons \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "SAVE10",
"discount_value": 10,
"discount_type": "PERCENTAGE",
"max_uses": 100,
"products_bound": [
"prod_1"
],
"min_order_amount": 20,
"max_discount": 50,
"valid_from": "2026-04-01T00:00:00.000Z",
"valid_until": "2026-05-01T00:00:00.000Z"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
code: 'SAVE10',
discount_value: 10,
discount_type: 'PERCENTAGE',
max_uses: 100,
products_bound: ['prod_1'],
min_order_amount: 20,
max_discount: 50,
valid_from: '2026-04-01T00:00:00.000Z',
valid_until: '2026-05-01T00:00:00.000Z'
})
};
fetch('https://api.shoppex.io/dev/v1/coupons', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.shoppex.io/dev/v1/coupons"
payload = {
"code": "SAVE10",
"discount_value": 10,
"discount_type": "PERCENTAGE",
"max_uses": 100,
"products_bound": ["prod_1"],
"min_order_amount": 20,
"max_discount": 50,
"valid_from": "2026-04-01T00:00:00.000Z",
"valid_until": "2026-05-01T00:00:00.000Z"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.shoppex.io/dev/v1/coupons",
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' => 'SAVE10',
'discount_value' => 10,
'discount_type' => 'PERCENTAGE',
'max_uses' => 100,
'products_bound' => [
'prod_1'
],
'min_order_amount' => 20,
'max_discount' => 50,
'valid_from' => '2026-04-01T00:00:00.000Z',
'valid_until' => '2026-05-01T00:00:00.000Z'
]),
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.shoppex.io/dev/v1/coupons"
payload := strings.NewReader("{\n \"code\": \"SAVE10\",\n \"discount_value\": 10,\n \"discount_type\": \"PERCENTAGE\",\n \"max_uses\": 100,\n \"products_bound\": [\n \"prod_1\"\n ],\n \"min_order_amount\": 20,\n \"max_discount\": 50,\n \"valid_from\": \"2026-04-01T00:00:00.000Z\",\n \"valid_until\": \"2026-05-01T00:00:00.000Z\"\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))
}{
"data": {
"id": "coupon_db_1",
"uniqid": "coupon_1",
"shop_id": "shop_1",
"type": "PERCENTAGE",
"code": "save10",
"discount": 10,
"used": 0,
"max_uses": 100,
"min_order_amount": 20,
"max_discount": 50,
"valid_from": 1711929600,
"valid_until": 1714521600,
"is_active": true,
"created_at": 1711929600,
"updated_at": 1711929600,
"products_bound": [
"prod_1"
],
"products_count": 1
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"details": [
{
"field": "<string>",
"message": "<string>"
}
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"details": [
{
"field": "<string>",
"message": "<string>"
}
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"details": [
{
"field": "<string>",
"message": "<string>"
}
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"details": [
{
"field": "<string>",
"message": "<string>"
}
]
}
}