curl --request PUT \
--url https://v4pay-api.vercel.app/coupons/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "BEMVINDO10",
"type": "percent",
"value": 10,
"description": "Cupom de boas-vindas",
"max_uses": 100,
"expires_at": "2026-12-31T23:59:59Z",
"is_active": false
}
'import requests
url = "https://v4pay-api.vercel.app/coupons/{id}"
payload = {
"code": "BEMVINDO10",
"type": "percent",
"value": 10,
"description": "Cupom de boas-vindas",
"max_uses": 100,
"expires_at": "2026-12-31T23:59:59Z",
"is_active": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
code: 'BEMVINDO10',
type: 'percent',
value: 10,
description: 'Cupom de boas-vindas',
max_uses: 100,
expires_at: '2026-12-31T23:59:59Z',
is_active: false
})
};
fetch('https://v4pay-api.vercel.app/coupons/{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://v4pay-api.vercel.app/coupons/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'code' => 'BEMVINDO10',
'type' => 'percent',
'value' => 10,
'description' => 'Cupom de boas-vindas',
'max_uses' => 100,
'expires_at' => '2026-12-31T23:59:59Z',
'is_active' => false
]),
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://v4pay-api.vercel.app/coupons/{id}"
payload := strings.NewReader("{\n \"code\": \"BEMVINDO10\",\n \"type\": \"percent\",\n \"value\": 10,\n \"description\": \"Cupom de boas-vindas\",\n \"max_uses\": 100,\n \"expires_at\": \"2026-12-31T23:59:59Z\",\n \"is_active\": false\n}")
req, _ := http.NewRequest("PUT", 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.put("https://v4pay-api.vercel.app/coupons/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"BEMVINDO10\",\n \"type\": \"percent\",\n \"value\": 10,\n \"description\": \"Cupom de boas-vindas\",\n \"max_uses\": 100,\n \"expires_at\": \"2026-12-31T23:59:59Z\",\n \"is_active\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://v4pay-api.vercel.app/coupons/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"code\": \"BEMVINDO10\",\n \"type\": \"percent\",\n \"value\": 10,\n \"description\": \"Cupom de boas-vindas\",\n \"max_uses\": 100,\n \"expires_at\": \"2026-12-31T23:59:59Z\",\n \"is_active\": false\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"user_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"code": "BEMVINDO10",
"type": "percent",
"value": 10,
"description": "<string>",
"max_uses": 100,
"used_count": 12,
"expires_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z"
}
}{
"error": {
"message": "<string>"
}
}{
"error": "Token JWT ou chave de API ausente"
}{
"error": {
"message": "<string>"
}
}Atualizar cupom
Atualiza apenas os campos enviados no corpo da requisição.
curl --request PUT \
--url https://v4pay-api.vercel.app/coupons/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "BEMVINDO10",
"type": "percent",
"value": 10,
"description": "Cupom de boas-vindas",
"max_uses": 100,
"expires_at": "2026-12-31T23:59:59Z",
"is_active": false
}
'import requests
url = "https://v4pay-api.vercel.app/coupons/{id}"
payload = {
"code": "BEMVINDO10",
"type": "percent",
"value": 10,
"description": "Cupom de boas-vindas",
"max_uses": 100,
"expires_at": "2026-12-31T23:59:59Z",
"is_active": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
code: 'BEMVINDO10',
type: 'percent',
value: 10,
description: 'Cupom de boas-vindas',
max_uses: 100,
expires_at: '2026-12-31T23:59:59Z',
is_active: false
})
};
fetch('https://v4pay-api.vercel.app/coupons/{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://v4pay-api.vercel.app/coupons/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'code' => 'BEMVINDO10',
'type' => 'percent',
'value' => 10,
'description' => 'Cupom de boas-vindas',
'max_uses' => 100,
'expires_at' => '2026-12-31T23:59:59Z',
'is_active' => false
]),
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://v4pay-api.vercel.app/coupons/{id}"
payload := strings.NewReader("{\n \"code\": \"BEMVINDO10\",\n \"type\": \"percent\",\n \"value\": 10,\n \"description\": \"Cupom de boas-vindas\",\n \"max_uses\": 100,\n \"expires_at\": \"2026-12-31T23:59:59Z\",\n \"is_active\": false\n}")
req, _ := http.NewRequest("PUT", 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.put("https://v4pay-api.vercel.app/coupons/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"BEMVINDO10\",\n \"type\": \"percent\",\n \"value\": 10,\n \"description\": \"Cupom de boas-vindas\",\n \"max_uses\": 100,\n \"expires_at\": \"2026-12-31T23:59:59Z\",\n \"is_active\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://v4pay-api.vercel.app/coupons/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"code\": \"BEMVINDO10\",\n \"type\": \"percent\",\n \"value\": 10,\n \"description\": \"Cupom de boas-vindas\",\n \"max_uses\": 100,\n \"expires_at\": \"2026-12-31T23:59:59Z\",\n \"is_active\": false\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"user_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"code": "BEMVINDO10",
"type": "percent",
"value": 10,
"description": "<string>",
"max_uses": 100,
"used_count": 12,
"expires_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z"
}
}{
"error": {
"message": "<string>"
}
}{
"error": "Token JWT ou chave de API ausente"
}{
"error": {
"message": "<string>"
}
}Authorizations
Token JWT obtido em /auth/login, enviado no cabeçalho Authorization no formato Bearer <token>.
Path Parameters
Body
Dados para criação de um cupom de desconto.
Código do cupom.
"BEMVINDO10"
Tipo do desconto (ex. percentual ou valor fixo).
"percent"
Valor do desconto (percentual ou em reais, conforme o tipo).
10
"Cupom de boas-vindas"
Número máximo de utilizações do cupom.
100
"2026-12-31T23:59:59Z"
false desativa o cupom: ele é recusado no checkout e no /coupons/validate, sem apagar o histórico. É a alternativa à exclusão quando o cupom tem referências demais (ver o 409 do DELETE). Só tem efeito na atualização (PUT); na criação todo cupom nasce ativo.
false
Response
Cupom atualizado com sucesso.
Objeto representando um cupom de desconto.
Show child attributes
Show child attributes