Cupons
Validar Cupom
POST
/v1/coupons/:couponId/validateBase URL Produção:
https://api.validapay.com.brBase URL Sandbox:
https://sandbox.validapay.com.brAutenticação
noauthnoauthstring · header · obrigatório
Nenhuma autenticação via header — credenciais enviadas no body da requisição.
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| couponId | string | Required | Couponid |
Verifica se um cupom pode ser usado e retorna o valor do desconto que será aplicado.
Validar cupom (público)
Auth: nenhuma. :id = código do cupom.
| Campo | Obrig. | Tipo | Descrição |
|---|---|---|---|
amount | ❌ | number | Valor para validar contra minAmount |
productIds | ❌ | string[] | Produtos do carrinho |
chargeType | ❌ | string | RECURRING ONE_TIME (default RECURRING) |
customerDocument | ❌ | string | Para validar firstTimeOnly |
Body
application/json
Content-Type:application/json
{
"amount": 99.9,
"productIds": [
"prod_xxx"
],
"chargeType": "RECURRING",
"customerDocument": "12345678901"
}Schema
| Field | Type | Required | Description |
|---|---|---|---|
amount | number | - | - |
productIds[1] | array | - | - |
chargeType | string | - | - |
customerDocument | string | - | - |
Headers
| Name | Type | Value | Required |
|---|---|---|---|
| Content-Type | - | application/json | Optional |
const url = 'https://sandbox.validapay.com.br/v1/coupons/:couponId/validate';
const options = {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
"amount": 99.9,
"productIds": [
"prod_xxx"
],
"chargeType": "RECURRING",
"customerDocument": "12345678901"
})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));Response Examples
200200 válido
{
"valid": true,
"coupon": {
"code": "PROMO10",
"discountType": "PERCENTAGE",
"discountValue": 10
}
}200200 inválido
{
"valid": false,
"reason": "COUPON_NOT_FOUND"
}