Criar um novo cupom
curl --request POST \
--url https://v4pay-api.vercel.app/coupons \
--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"
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.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,
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', 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",
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,
'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"
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("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://v4pay-api.vercel.app/coupons")
.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")
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 \"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"
}Cupons
Criar um novo cupom
POST
/
coupons
Criar um novo cupom
curl --request POST \
--url https://v4pay-api.vercel.app/coupons \
--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"
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.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,
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', 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",
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,
'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"
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("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://v4pay-api.vercel.app/coupons")
.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")
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 \"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"
}Authorizations
Token JWT obtido em /auth/login, enviado no cabeçalho Authorization no formato Bearer <token>.
Body
application/json
Dados para criação de um cupom de desconto.
Código do cupom.
Example:
"BEMVINDO10"
Tipo do desconto (ex. percentual ou valor fixo).
Example:
"percent"
Valor do desconto (percentual ou em reais, conforme o tipo).
Example:
10
Example:
"Cupom de boas-vindas"
Número máximo de utilizações do cupom.
Example:
100
Example:
"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.
Example:
false
Response
Cupom criado com sucesso.
Objeto representando um cupom de desconto.
Show child attributes
Show child attributes