Objects
The objects the API returns, field by field, and the difference between a benefit and a redeemable benefit.
This page is the API's dictionary: every object that shows up in a response, with all of its fields. Endpoint pages link here instead of repeating the lists.
The three codes
First of all, this: the API handles three similar-looking identifiers, and mixing them up is the most common mistake when integrating.
| Code | What it identifies | Where it is used |
|---|---|---|
client_code | A member. It is the number every person registered in Loybox has. | Recording a consumption, looking up a client |
benefit_id | A catalog benefit, the one the commerce created. | Looking up a benefit, buying it |
client_benefit_code | A benefit already bought by a specific member. | Looking up the code, redeeming it |
A benefit and a redeemable benefit are not the same
The commerce creates benefits, and each one has a benefit_id. When a member
buys one with their points they receive a redeemable benefit with its own
client_benefit_code.
The benefit_id is only good for looking up information. The
client_benefit_code is good for looking up and for redeeming: it is the code
the member presents in the store, or pastes at the online store's checkout.
Client
Appears in listing clients and looking up a client.
codeintegerrequiredThe member's code.
usernamestringrequiredThe member's name.
emailstringrequiredThe member's email.
pointsinteger | nullPoints they hold at the commerce.
Benefit
The catalog benefit. Appears in almost every response of Benefits, Clients, My account and Public.
idstringrequiredThe benefit_id.
typestringrequiredWhat kind of reward it is: percentage_discount, absolute_discount or
free_product.
descriptionstringrequiredDescription of the benefit.
costnumberrequiredHow many points it costs to buy.
expirationdate-time | nullrequiredHow long it stays valid. null if it does not expire.
benefit_typestringnormal for catalog ones; welcome, birthday, monthly_top or level for
the automatic rewards. Defaults to normal.
colorstring | nullThe commerce's brand color, in hexadecimal.
buy_limitinteger | nullTotal number of redemptions allowed for this benefit. 0 means no limit.
prizePrize | nullThe reward's detail. See Prize.
tiendanube_couponTiendanube coupon | nullThe coupon, if the benefit applies in a Tiendanube store. See Tiendanube coupon.
Benefit (v2)
GET /v2/benefits/preview/{client_benefit_code}
returns a version with three extra fields, which save you from digging into
prize for the basics:
titlestringrequiredThe benefit's title. In v1 it only lived inside prize.
valuenumber | nullThe discount's value: the percentage if it is percentage_discount, the
amount if it is absolute_discount.
productProduct | nullThe product, if it is free_product. See Product.
Every other field is the same as in Benefit.
Redeemable benefit
A benefit a member already bought. Appears in purchased benefits, my benefits and as the response of buying a benefit.
client_benefit_codeintegerrequiredThe redemption code. It is what the member presents at the commerce, and also the coupon code in an online store.
issue_datedate-timerequiredWhen they bought it.
due_datedate-time | nullHow long they have to redeem it. null if it does not expire.
usedbooleanWhether it was already redeemed. Defaults to false.
benefitBenefitrequiredThe benefit bought. See Benefit.
Prize
The detail of what the member wins. It lives inside prize.
typestringrequiredpercentage_discount, absolute_discount or free_product.
titlestring | nullThe reward's title.
descriptionstring | nullThe reward's description.
valuenumber | nullThe discount's percentage or amount, depending on the type.
productProduct | nullThe gift product. See Product.
expirationdate-time | nullThe reward's expiration.
imagestring | nullURL of the reward's image.
Product
idinteger | string | nullThe product's id in Loybox.
namestring | nullThe product's name.
external_idstring | nullThe product's id in the commerce's own system.
Commerce
The program's branding data. Appears in commerce data and inside my account.
idintegerrequiredThe commerce_id, the same one that goes in the X-Commerce-Id header.
namestringrequiredThe commerce's name.
logostring | nullURL of the logo.
colorstring | nullBrand color in hexadecimal, for the program's UI.
category_namestring | nullThe commerce's category, for example Tienda de comics.
currencystring | nullThe commerce's currency.
My account
The response of GET /v1/me.
usernamestring | nullThe user's name.
emailstring | nullThe user's email.
phonestring | nullThe user's phone.
pointsintegerThe user's points at this commerce. Defaults to 0.
subscribedbooleanWhether the user is subscribed to this commerce's program. Defaults to
false.
commerceCommerce | nullThe commerce's data, to paint the program's branding. See Commerce.
points_expirationPoints expiration | nullPoints about to expire. See Points expiration.
Points expiration
pointsintegerPoints about to expire. Defaults to 0.
expiration_datedate-time | nullWhen they expire.
days_leftinteger | nullDays remaining.
months_leftinteger | nullMonths remaining.
modestring | nullHow points expire at this commerce: none, rolling or accumulated.
none means they do not expire.
When points do not expire
If the commerce does not expire points, the object comes back with
mode: "none" and points: 0, not as null. See
Point expiration for the detail of the modes.
Tier
The response of GET /v1/me/level.
The endpoint and its fields say level; this documentation says "tier", which is
the product's term in English. It is the same thing.
namestring | nullThe tier's name.
rankinteger | nullThe tier's position in the ladder.
points_multipliernumber | nullThe points multiplier the tier grants.
icon_urlstring | nullURL of the tier's icon.
reached_atdate-time | nullWhen they reached the tier.
expiration_datedate-time | nullWhen the tier expires.
is_expiredboolean | nullWhether the tier already expired.
next_levelNext tier | nullThe next tier and what is missing to reach it. See Next tier.
total_earned_pointsinteger | nullPoints earned in total, the lifetime accumulated figure.
total_spent_amountnumber | nullAmount spent in total.
total_consumptions_countinteger | nullNumber of consumptions recorded.
Next tier
namestring | nullThe next tier's name.
rankinteger | nullThe next tier's position.
threshold_typestring | nullWhat the threshold is measured in: accumulated points or amount spent.
thresholdnumber | nullThe threshold value to reach.
Activity item
Each item of my history.
typestringrequiredWhat happened: consumption (a purchase that earned points),
benefit_exchange (they bought a benefit with points), benefit_usage (they
redeemed a benefit) or points_special_reward (an automatic reward gave them
points).
datedate-time | nullWhen it happened.
pointsinteger | nullPoints the item added or subtracted.
benefitBenefit | nullThe benefit involved, on benefit items. See Benefit.
amountnumber | nullThe purchase amount, on consumption items.
eventstring | nullThe event that triggered the reward, on points_special_reward items.
additional_notestring | nullAdditional note on the item.
Automatic reward
Each item of program rewards.
eventstringrequiredThe event that triggers it: welcome, birthday or monthly_top.
reward_typestringrequiredbenefit if it delivers a benefit, points if it delivers points.
benefitBenefit | nullThe benefit it delivers, when reward_type is benefit. See
Benefit.
pointsinteger | nullThe points it delivers, when reward_type is points.
Session
The response of verifying the code.
accessstringrequiredAccess token. Sent as Authorization: Bearer {access} on the My account
endpoints.
refreshstringrequiredRefresh token, to get a new access without asking for another code.
expires_inintegerrequiredSeconds the access token stays valid.
user_idintegerrequiredThe user's id.
usernamestring | nullThe user's name.
emailstring | nullThe user's email.
phonestring | nullThe user's phone.
Tiendanube coupon
Lives inside tiendanube_coupon when the benefit applies in a
Tiendanube store.
typestringrequiredpercentage, absolute or shipping.
valuenumberrequiredThe coupon's value.
categorystring | nullId of the Tiendanube category the coupon applies to.
category_namestring | nullThat category's name.
end_datedate-time | nullHow long the coupon is valid for.
productTiendanube product | nullThe product the coupon applies to, if it applies to a single one. See Tiendanube product.
Tiendanube product
tiendanube_idinteger | nullThe product's id in Tiendanube.
namestring | nullThe product's name.
urlstring | nullURL of the product in the store.
availableboolean | nullWhether it is in stock.
publishedboolean | nullWhether it is published in the store.
brandstring | nullThe product's brand.
categoriesarray of categoriesThe product's categories, each with id and name. Empty by default.