Assinaturas
Adicionar Item
POST
/v1/subscriptions/:subscriptionId/itemsBase URL Produção:
https://api.validapay.com.brBase URL Sandbox:
https://sandbox.validapay.com.brAutenticação
bearerAuthorizationstring · header · obrigatório
Envie no header:
Authorization: Bearer {{token}}Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| subscriptionId | string | Required | Subscriptionid |
Adiciona um novo produto ou serviço a uma assinatura já existente.
Adicionar item à assinatura
| Campo | Obrig. | Tipo | Descrição |
|---|---|---|---|
priceId | ✅ | string | Preço do item |
quantity | ❌ | number | ≥ 1 (default 1) |
type | ❌ | string | RECURRING ONE_TIME (default RECURRING) |
boletoInstructions | ❌ | object | Para assinaturas boleto |
expirationAfterDueDate | ❌ | number | 0–60 |
Body
application/json
Content-Type:application/json
{
"priceId": "price_xxx",
"quantity": 1,
"type": "RECURRING",
"boletoInstructions": {
"fine": 2.0,
"interest": 1.0
},
"expirationAfterDueDate": 30
}Schema
| Field | Type | Required | Description |
|---|---|---|---|
priceId | string | - | - |
quantity | number | - | - |
type | string | - | - |
boletoInstructions | object | - | - |
expirationAfterDueDate | number | - | - |
Headers
| Name | Type | Value | Required |
|---|---|---|---|
| Content-Type | - | application/json | Optional |
const url = 'https://sandbox.validapay.com.br/v1/subscriptions/:subscriptionId/items';
const options = {
method: 'POST',
headers: {
'Authorization': 'Bearer {{token}}',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"priceId": "price_xxx",
"quantity": 1,
"type": "RECURRING",
"boletoInstructions": {
"fine": 2.0,
"interest": 1.0
},
"expirationAfterDueDate": 30
})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));Response Examples
200200 cartão
{
"success": true,
"type": "ADD_ITEM",
"chargeId": "cha_xxx",
"amount": 49.9,
"newAmount": 149.8
}200200 PIX
{
"success": true,
"type": "ADD_ITEM",
"paymentMethod": "PIX",
"chargeId": "cha_xxx",
"payment": {
"emvQrCode": "..."
}
}402402
{
"code": "PAYMENT_DECLINED",
"error": "Cartão recusado"
}400400
{
"code": "SUBSCRIPTION_NOT_ACTIVE"
}