Look up a code (v2)
Version 2 of the code lookup, with the title and the discount's value at the top level.
GET/v2/benefits/preview/{client_benefit_code}Commerce API key
It does the same as version 1, returning information about the benefit from the code the member holds to redeem it, but it returns three extra fields at the root of the object.
For a new integration, use this one.
What changes
| Field | In v1 | In v2 |
|---|---|---|
title | Only inside prize | At the root, and always present |
value | Only inside prize | At the root |
product | Only inside prize | At the root |
In practice: to apply the discount you no longer need to dig into prize or check
that it exists. Every other field is the same.
Parameters
client_benefit_codestringpathrequiredThe redemption code the member holds.
Response
A Benefit (v2) object.
curl https://loybox-public-api-752998171300.southamerica-west1.run.app/v2/benefits/preview/887766 \
-H "Authorization: Bearer $LOYBOX_API_KEY"// 200 OK
{
"id": "b_9f2a",
"type": "percentage_discount",
"value": 20,
"title": "20% off",
"description": "Válido en toda la tienda",
"product": null,
"cost": 250,
"expiration": "2026-12-31T23:59:59Z",
"benefit_type": "normal",
"color": "#f1a10d",
"buy_limit": 0,
"prize": null,
"tiendanube_coupon": null
}What to read depending on the type:
type | What to do |
|---|---|
percentage_discount | Apply the percentage in value. |
absolute_discount | Subtract the amount in value. |
free_product | Add the product in product. |
How it is redeemed
The same as in v1: with
POST /v1/benefits/redeem. Redemption has no
version 2: the same code works for both.
Errors
| Code | When |
|---|---|
400 | The benefit was already used. |
401 | The API key is invalid: it has no commerce attached. |
404 | The benefit does not exist. |
422 | The code is not a valid format. |