Criar cupom
curl --request POST \
--url https://api.upag.io/v1/coupons \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"type": "<string>",
"name": "<string>",
"code": "<string>",
"appliesTo": "<string>"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({type: '<string>', name: '<string>', code: '<string>', appliesTo: '<string>'})
};
fetch('https://api.upag.io/v1/coupons', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const url = 'https://api.upag.io/v1/coupons';
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({type: '<string>', name: '<string>', code: '<string>', appliesTo: '<string>'})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));Cupons
Criar cupom
Cria um cupom de desconto percentual ou fixo
POST
https://api.upag.io
/
v1
/
coupons
Criar cupom
curl --request POST \
--url https://api.upag.io/v1/coupons \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"type": "<string>",
"name": "<string>",
"code": "<string>",
"appliesTo": "<string>"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({type: '<string>', name: '<string>', code: '<string>', appliesTo: '<string>'})
};
fetch('https://api.upag.io/v1/coupons', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const url = 'https://api.upag.io/v1/coupons';
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({type: '<string>', name: '<string>', code: '<string>', appliesTo: '<string>'})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));Permissão:
coupon.write (chave secreta; chave publicável não é aceita).
Endpoint
curl -X POST https://api.upag.dev/v1/coupons \
-H "Authorization: Bearer sk_test_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"type": "percentage",
"name": "Black Friday",
"code": "BLACK20",
"percentOff": 20,
"maxUses": 100,
"expiresAt": "2026-12-01T00:00:00.000Z",
"appliesTo": "all"
}'
import { Upag } from 'upag';
const upag = new Upag('sk_test_your_api_key');
const coupon = await upag.coupons.create({
type: 'percentage',
name: 'Black Friday',
code: 'BLACK20',
percentOff: 20,
maxUses: 100,
expiresAt: '2026-12-01T00:00:00.000Z',
appliesTo: 'all',
});
// Cupom fixo, só para produtos específicos
await upag.coupons.create({
type: 'fixed',
name: 'R$ 10 off',
code: 'DEZ',
amountOff: 1000,
currency: 'brl',
appliesTo: 'specific',
appliesToProducts: ['0b9c1f3e-6a4d-4c1e-9d55-3f1f6a7c2e10'],
});
Em produção use
https://api.upag.io/v1 com sk_live_....Parâmetros
string
required
percentage ou fixed.string
required
Nome interno (mínimo 3 caracteres).
string
required
Código do cupom (mínimo 3 caracteres). Único por conta; guardado em maiúsculas.
string
required
all ou specific.string[]
UUIDs de produtos. Obrigatório (não vazio) quando
appliesTo é specific.integer
Obrigatório quando
type é percentage. Inteiro de 1 a 100.integer
Obrigatório quando
type é fixed. Valor em centavos (≥ 1).string
Obrigatório quando
type é fixed: brl ou usd.string
Descrição (mínimo 3 caracteres). Padrão
null.boolean
default:"true"
Se o cupom pode ser usado.
integer
Máximo de usos (≥ 1). Padrão
null (ilimitado).string (ISO 8601)
Data de expiração. Padrão
null (não expira).Resposta
201 Created
Response
{
"id": "a3c4d5e6-7f80-4912-8abc-0d1e2f3a4b5c",
"name": "Black Friday",
"description": null,
"active": true,
"type": "percentage",
"code": "BLACK20",
"currency": null,
"amountOff": null,
"percentOff": 20,
"uses": 0,
"maxUses": 100,
"appliesTo": "all",
"appliesToProducts": null,
"expiresAt": "2026-12-01T00:00:00.000Z",
"createdAt": "2026-03-18T11:10:00.000Z",
"updatedAt": "2026-03-18T11:10:00.000Z"
}
400(COUPON_ALREADY_EXISTS) — já existe um cupom com essecodena conta.422— validação (por exemplo,percentOfffora de 1–100 ouspecificsem produtos).