Update discount
curl --request PATCH \
--url https://api.lojou.app/v1/discounts/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "<string>",
"type": "<string>",
"value": 1.01,
"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/{id}"
payload = {
"code": "<string>",
"type": "<string>",
"value": 1.01,
"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.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
code: '<string>',
type: '<string>',
value: 1.01,
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/{id}', 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/{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' => '<string>',
'type' => '<string>',
'value' => 1.01,
'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/{id}"
payload := strings.NewReader("{\n \"code\": \"<string>\",\n \"type\": \"<string>\",\n \"value\": 1.01,\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("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))
}HttpResponse<String> response = Unirest.patch("https://api.lojou.app/v1/discounts/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"<string>\",\n \"type\": \"<string>\",\n \"value\": 1.01,\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/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"code\": \"<string>\",\n \"type\": \"<string>\",\n \"value\": 1.01,\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 updated successfully.",
"discount": {
"id": 9,
"code": "LANCAMENTO25",
"type": "percent",
"value": 25,
"status": "active",
"product_ids": [
272,
305
],
"uses_limit": 100,
"used_count": 34,
"available_uses": 66,
"single_use": false,
"never_expires": false,
"expires_at": "2026-12-31T23:59:59.000000Z",
"created_at": "2026-08-01T08:00:00.000000Z",
"updated_at": "2026-08-31T16:35: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": "Resource not found."
}{
"status": "error",
"message": "A discount with this code already exists."
}{
"status": "error",
"message": "Validation failed.",
"errors": {
"amount": [
"The amount field is required."
]
}
}Discounts
Update discount
PATCH
/
v1
/
discounts
/
{id}
Update discount
curl --request PATCH \
--url https://api.lojou.app/v1/discounts/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "<string>",
"type": "<string>",
"value": 1.01,
"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/{id}"
payload = {
"code": "<string>",
"type": "<string>",
"value": 1.01,
"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.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
code: '<string>',
type: '<string>',
value: 1.01,
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/{id}', 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/{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' => '<string>',
'type' => '<string>',
'value' => 1.01,
'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/{id}"
payload := strings.NewReader("{\n \"code\": \"<string>\",\n \"type\": \"<string>\",\n \"value\": 1.01,\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("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))
}HttpResponse<String> response = Unirest.patch("https://api.lojou.app/v1/discounts/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"<string>\",\n \"type\": \"<string>\",\n \"value\": 1.01,\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/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"code\": \"<string>\",\n \"type\": \"<string>\",\n \"value\": 1.01,\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 updated successfully.",
"discount": {
"id": 9,
"code": "LANCAMENTO25",
"type": "percent",
"value": 25,
"status": "active",
"product_ids": [
272,
305
],
"uses_limit": 100,
"used_count": 34,
"available_uses": 66,
"single_use": false,
"never_expires": false,
"expires_at": "2026-12-31T23:59:59.000000Z",
"created_at": "2026-08-01T08:00:00.000000Z",
"updated_at": "2026-08-31T16:35: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": "Resource not found."
}{
"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.
Parâmetros de caminho
Resource identifier.
Corpo
application/json
fixed|amount|percent|percentage|percentual|%
Intervalo necessário:
x >= 0.01Intervalo necessário:
x >= 1Opções disponíveis:
active, inactive, enabled, disabled, published, unpublished Resposta
Success
The response is of type object.
