Create discount
curl --request POST \
--url https://api.lojou.app/v1/discounts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "BEMVINDO10",
"type": "percent",
"value": 10,
"product_ids": [
123
],
"uses_limit": 2,
"single_use": true,
"expires_at": "2023-11-07T05:31:56Z",
"never_expires": true
}
'import requests
url = "https://api.lojou.app/v1/discounts"
payload = {
"code": "BEMVINDO10",
"type": "percent",
"value": 10,
"product_ids": [123],
"uses_limit": 2,
"single_use": True,
"expires_at": "2023-11-07T05:31:56Z",
"never_expires": True
}
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: 'BEMVINDO10',
type: 'percent',
value: 10,
product_ids: [123],
uses_limit: 2,
single_use: true,
expires_at: '2023-11-07T05:31:56Z',
never_expires: true
})
};
fetch('https://api.lojou.app/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.lojou.app/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([
'code' => 'BEMVINDO10',
'type' => 'percent',
'value' => 10,
'product_ids' => [
123
],
'uses_limit' => 2,
'single_use' => true,
'expires_at' => '2023-11-07T05:31:56Z',
'never_expires' => 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.lojou.app/v1/discounts"
payload := strings.NewReader("{\n \"code\": \"BEMVINDO10\",\n \"type\": \"percent\",\n \"value\": 10,\n \"product_ids\": [\n 123\n ],\n \"uses_limit\": 2,\n \"single_use\": true,\n \"expires_at\": \"2023-11-07T05:31:56Z\",\n \"never_expires\": true\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.lojou.app/v1/discounts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"BEMVINDO10\",\n \"type\": \"percent\",\n \"value\": 10,\n \"product_ids\": [\n 123\n ],\n \"uses_limit\": 2,\n \"single_use\": true,\n \"expires_at\": \"2023-11-07T05:31:56Z\",\n \"never_expires\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.lojou.app/v1/discounts")
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\": \"BEMVINDO10\",\n \"type\": \"percent\",\n \"value\": 10,\n \"product_ids\": [\n 123\n ],\n \"uses_limit\": 2,\n \"single_use\": true,\n \"expires_at\": \"2023-11-07T05:31:56Z\",\n \"never_expires\": true\n}"
response = http.request(request)
puts response.read_body{
"status": "success",
"message": "Discount created successfully.",
"discount": {
"id": 10,
"code": "BEMVINDO10",
"type": "percent",
"value": 10,
"status": "active",
"product_ids": [],
"uses_limit": null,
"used_count": 0,
"available_uses": null,
"single_use": false,
"never_expires": true,
"expires_at": null,
"created_at": "2026-08-31T16:30:00.000000Z",
"updated_at": "2026-08-31T16:30:00.000000Z"
}
}{
"status": "error",
"message": "Unauthorized user."
}{
"status": "error",
"message": "Permission denied for this endpoint.",
"error_code": "insufficient_scope",
"required_scopes": [
"orders.read"
],
"missing_scopes": [
"orders.read"
],
"granted_scopes": [
"products.read",
"products.write"
]
}{
"status": "error",
"message": "A discount with this code already exists."
}{
"status": "error",
"message": "Validation failed.",
"errors": {
"amount": [
"The amount field is required."
]
}
}Discounts
Create discount
POST
/
v1
/
discounts
Create discount
curl --request POST \
--url https://api.lojou.app/v1/discounts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "BEMVINDO10",
"type": "percent",
"value": 10,
"product_ids": [
123
],
"uses_limit": 2,
"single_use": true,
"expires_at": "2023-11-07T05:31:56Z",
"never_expires": true
}
'import requests
url = "https://api.lojou.app/v1/discounts"
payload = {
"code": "BEMVINDO10",
"type": "percent",
"value": 10,
"product_ids": [123],
"uses_limit": 2,
"single_use": True,
"expires_at": "2023-11-07T05:31:56Z",
"never_expires": True
}
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: 'BEMVINDO10',
type: 'percent',
value: 10,
product_ids: [123],
uses_limit: 2,
single_use: true,
expires_at: '2023-11-07T05:31:56Z',
never_expires: true
})
};
fetch('https://api.lojou.app/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.lojou.app/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([
'code' => 'BEMVINDO10',
'type' => 'percent',
'value' => 10,
'product_ids' => [
123
],
'uses_limit' => 2,
'single_use' => true,
'expires_at' => '2023-11-07T05:31:56Z',
'never_expires' => 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.lojou.app/v1/discounts"
payload := strings.NewReader("{\n \"code\": \"BEMVINDO10\",\n \"type\": \"percent\",\n \"value\": 10,\n \"product_ids\": [\n 123\n ],\n \"uses_limit\": 2,\n \"single_use\": true,\n \"expires_at\": \"2023-11-07T05:31:56Z\",\n \"never_expires\": true\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.lojou.app/v1/discounts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"BEMVINDO10\",\n \"type\": \"percent\",\n \"value\": 10,\n \"product_ids\": [\n 123\n ],\n \"uses_limit\": 2,\n \"single_use\": true,\n \"expires_at\": \"2023-11-07T05:31:56Z\",\n \"never_expires\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.lojou.app/v1/discounts")
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\": \"BEMVINDO10\",\n \"type\": \"percent\",\n \"value\": 10,\n \"product_ids\": [\n 123\n ],\n \"uses_limit\": 2,\n \"single_use\": true,\n \"expires_at\": \"2023-11-07T05:31:56Z\",\n \"never_expires\": true\n}"
response = http.request(request)
puts response.read_body{
"status": "success",
"message": "Discount created successfully.",
"discount": {
"id": 10,
"code": "BEMVINDO10",
"type": "percent",
"value": 10,
"status": "active",
"product_ids": [],
"uses_limit": null,
"used_count": 0,
"available_uses": null,
"single_use": false,
"never_expires": true,
"expires_at": null,
"created_at": "2026-08-31T16:30:00.000000Z",
"updated_at": "2026-08-31T16:30:00.000000Z"
}
}{
"status": "error",
"message": "Unauthorized user."
}{
"status": "error",
"message": "Permission denied for this endpoint.",
"error_code": "insufficient_scope",
"required_scopes": [
"orders.read"
],
"missing_scopes": [
"orders.read"
],
"granted_scopes": [
"products.read",
"products.write"
]
}{
"status": "error",
"message": "A discount with this code already exists."
}{
"status": "error",
"message": "Validation failed.",
"errors": {
"amount": [
"The amount field is required."
]
}
}Autorizações
Send an API key or an OAuth access token in the Authorization header
as a Bearer token. See Authentication for details.
Corpo
application/json
Exemplo:
"BEMVINDO10"
fixed|amount|percent|percentage|percentual|%
Exemplo:
"percent"
Intervalo necessário:
x >= 0.01Exemplo:
10
Intervalo necessário:
x >= 1Opções disponíveis:
active, inactive, enabled, disabled, published, unpublished Resposta
Discount created
The response is of type object.
