Skip to main content

Check Voucher Balance

Check the current balance and status of a voucher by its code. This is a read-only operation useful for displaying voucher information to customers.

Endpointโ€‹

POST /v1/vouchers/balance

Authenticationโ€‹

Requires an API key with the promotions:read scope.

Request Bodyโ€‹

FieldTypeRequiredDescription
codestringYesVoucher code to check

Example Requestโ€‹

curl -X POST "https://app.equipdash.com/api/v1/vouchers/balance" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"code": "GFT-ABCD-1234"
}'

Success Response (200 OK)โ€‹

{
"data": {
"code": "GFT-ABCD-1234",
"original_value": 100.00,
"remaining_value": 45.00,
"currency": "USD",
"status": "active",
"is_redeemable": true,
"is_expired": false,
"is_paid": true,
"valid_from": "2026-01-01T00:00:00+00:00",
"valid_until": "2026-12-31T23:59:59+00:00",
"times_used": 2,
"total_redeemed": 55.00
},
"meta": {
"request_id": "req_abc123",
"timestamp": "2026-02-01T10:00:00+00:00"
}
}

Response Fieldsโ€‹

FieldTypeDescription
codestringVoucher code
original_valuenumberOriginal voucher value
remaining_valuenumberCurrent remaining balance
currencystringCurrency code (e.g., USD, EUR, GBP)
statusstringVoucher status: active, redeemed, expired
is_redeemablebooleanWhether the voucher can currently be used
is_expiredbooleanWhether the voucher has passed its expiry date
is_paidbooleanWhether payment has been received for the voucher
valid_fromstringISO 8601 datetime when voucher becomes valid (null if immediate)
valid_untilstringISO 8601 datetime when voucher expires (null if no expiry)
times_usedintegerNumber of times the voucher has been partially redeemed
total_redeemednumberTotal amount redeemed from the voucher

Status Valuesโ€‹

StatusDescription
activeVoucher has remaining balance and is within validity period
redeemedVoucher has been fully used (zero balance)
expiredVoucher has passed its expiry date

Redeemabilityโ€‹

A voucher is redeemable (is_redeemable: true) when all of the following are true:

  • Status is active
  • Remaining value is greater than zero
  • is_paid is true (payment has been recorded)
  • Current date is within valid_from and valid_until range

Error Responsesโ€‹

Invalid Voucher Code (422)โ€‹

{
"error": {
"code": "validation_error",
"message": "The given data was invalid.",
"details": [
{
"field": "code",
"message": "Invalid voucher code."
}
]
},
"meta": {
"request_id": "req_abc123"
}
}

Missing Code (422)โ€‹

{
"error": {
"code": "validation_error",
"message": "The given data was invalid.",
"details": [
{
"field": "code",
"message": "The code field is required."
}
]
},
"meta": {
"request_id": "req_abc123"
}
}

Errorsโ€‹

StatusCodeDescription
401authentication_requiredNo API key provided
401invalid_api_keyInvalid API key
403insufficient_scopeAPI key lacks promotions:read scope
422validation_errorInvalid or missing voucher code

Use Casesโ€‹

Display Balance to Customerโ€‹

Show customers their remaining voucher balance before checkout:

async function checkVoucherBalance(code) {
const response = await fetch('https://app.equipdash.com/api/v1/vouchers/balance', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({ code })
});

const data = await response.json();

if (response.ok) {
console.log(`Balance: $${data.data.remaining_value}`);
console.log(`Redeemable: ${data.data.is_redeemable}`);
} else {
console.error('Invalid voucher code');
}
}

Check Before Applying to Bookingโ€‹

Verify a voucher before applying it:

async function canApplyVoucher(code, bookingTotal) {
const response = await fetch('https://app.equipdash.com/api/v1/vouchers/balance', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({ code })
});

const { data } = await response.json();

if (!data.is_redeemable) {
return { canApply: false, reason: 'Voucher is not redeemable' };
}

const applicableAmount = Math.min(data.remaining_value, bookingTotal);
return { canApply: true, applicableAmount };
}

Notesโ€‹

  • This endpoint is read-only and does not modify the voucher
  • Use Validate Voucher to check if a voucher can be used for a specific booking amount
  • The times_used count increments each time a partial redemption occurs
  • Vouchers can be partially redeemed multiple times until the balance reaches zero