Coupons
Update coupon
Updates a coupon for the authenticated shop.
PATCH
/
dev
/
v1
/
coupons
/
{id}
Update coupon
curl --request PATCH \
--url https://api.shoppex.io/dev/v1/coupons/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "SAVE15",
"discount_value": 15,
"products_bound": [
"prod_1",
"prod_2"
],
"used_count": 4,
"is_active": true
}
'const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
code: 'SAVE15',
discount_value: 15,
products_bound: ['prod_1', 'prod_2'],
used_count: 4,
is_active: true
})
};
fetch('https://api.shoppex.io/dev/v1/coupons/{id}', 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/{id}"
payload = {
"code": "SAVE15",
"discount_value": 15,
"products_bound": ["prod_1", "prod_2"],
"used_count": 4,
"is_active": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(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/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'code' => 'SAVE15',
'discount_value' => 15,
'products_bound' => [
'prod_1',
'prod_2'
],
'used_count' => 4,
'is_active' => true
]),
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/{id}"
payload := strings.NewReader("{\n \"code\": \"SAVE15\",\n \"discount_value\": 15,\n \"products_bound\": [\n \"prod_1\",\n \"prod_2\"\n ],\n \"used_count\": 4,\n \"is_active\": true\n}")
req, _ := http.NewRequest("PATCH", 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": "save15",
"discount": 15,
"used": 4,
"max_uses": 100,
"min_order_amount": 20,
"max_discount": 50,
"valid_from": 1711929600,
"valid_until": 1714521600,
"is_active": true,
"created_at": 1711929600,
"updated_at": 1711936800,
"products_bound": [
"prod_1",
"prod_2"
],
"products_count": 2
}
}{
"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>"
}
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"details": [
{
"field": "<string>",
"message": "<string>"
}
]
}
}Authorizations
Use your Shoppex API key in the Authorization header.
Path Parameters
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
⌘I
Update coupon
curl --request PATCH \
--url https://api.shoppex.io/dev/v1/coupons/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "SAVE15",
"discount_value": 15,
"products_bound": [
"prod_1",
"prod_2"
],
"used_count": 4,
"is_active": true
}
'const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
code: 'SAVE15',
discount_value: 15,
products_bound: ['prod_1', 'prod_2'],
used_count: 4,
is_active: true
})
};
fetch('https://api.shoppex.io/dev/v1/coupons/{id}', 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/{id}"
payload = {
"code": "SAVE15",
"discount_value": 15,
"products_bound": ["prod_1", "prod_2"],
"used_count": 4,
"is_active": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(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/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'code' => 'SAVE15',
'discount_value' => 15,
'products_bound' => [
'prod_1',
'prod_2'
],
'used_count' => 4,
'is_active' => true
]),
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/{id}"
payload := strings.NewReader("{\n \"code\": \"SAVE15\",\n \"discount_value\": 15,\n \"products_bound\": [\n \"prod_1\",\n \"prod_2\"\n ],\n \"used_count\": 4,\n \"is_active\": true\n}")
req, _ := http.NewRequest("PATCH", 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": "save15",
"discount": 15,
"used": 4,
"max_uses": 100,
"min_order_amount": 20,
"max_discount": 50,
"valid_from": 1711929600,
"valid_until": 1714521600,
"is_active": true,
"created_at": 1711929600,
"updated_at": 1711936800,
"products_bound": [
"prod_1",
"prod_2"
],
"products_count": 2
}
}{
"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>"
}
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"details": [
{
"field": "<string>",
"message": "<string>"
}
]
}
}