# Objects (https://docs.loybox.com.ar/en/api-reference/objetos)



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](https://docs.loybox.com.ar/api-reference/consumos/crear-por-codigo), [looking up a client](https://docs.loybox.com.ar/api-reference/clientes/obtener) |
| `benefit_id`          | A **catalog benefit**, the one the commerce created.                  | [Looking up a benefit](https://docs.loybox.com.ar/api-reference/beneficios/obtener), [buying it](https://docs.loybox.com.ar/api-reference/mi-cuenta/comprar-beneficio)          |
| `client_benefit_code` | A benefit **already bought** by a specific member.                    | [Looking up the code](https://docs.loybox.com.ar/api-reference/beneficios/consultar-codigo), [redeeming it](https://docs.loybox.com.ar/api-reference/beneficios/canjear)        |

<Callout title="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.
</Callout>

## Client
Appears in [listing clients](https://docs.loybox.com.ar/api-reference/clientes/listar) and
[looking up a client](https://docs.loybox.com.ar/api-reference/clientes/obtener).

<Fields>
  <Field name="code" type="integer" required="true">
    The member's code.
  </Field>

  <Field name="username" type="string" required="true">
    The member's name.
  </Field>

  <Field name="email" type="string" required="true">
    The member's email.
  </Field>

  <Field name="points" type="integer | null">
    Points they hold at the commerce.
  </Field>
</Fields>

## Benefit
The catalog benefit. Appears in almost every response of
[Benefits](https://docs.loybox.com.ar/api-reference/beneficios), [Clients](https://docs.loybox.com.ar/api-reference/clientes),
[My account](https://docs.loybox.com.ar/api-reference/mi-cuenta) and [Public](https://docs.loybox.com.ar/api-reference/publico).

<Fields>
  <Field name="id" type="string" required="true">
    The `benefit_id`.
  </Field>

  <Field name="type" type="string" required="true">
    What kind of reward it is: `percentage_discount`, `absolute_discount` or
    `free_product`.
  </Field>

  <Field name="description" type="string" required="true">
    Description of the benefit.
  </Field>

  <Field name="cost" type="number" required="true">
    How many points it costs to buy.
  </Field>

  <Field name="expiration" type="date-time | null" required="true">
    How long it stays valid. `null` if it does not expire.
  </Field>

  <Field name="benefit_type" type="string">
    `normal` for catalog ones; `welcome`, `birthday`, `monthly_top` or `level` for
    the automatic rewards. Defaults to `normal`.
  </Field>

  <Field name="color" type="string | null">
    The commerce's brand color, in hexadecimal.
  </Field>

  <Field name="buy_limit" type="integer | null">
    Total number of redemptions allowed for this benefit. `0` means no limit.
  </Field>

  <Field name="prize" type="Prize | null">
    The reward's detail. See [Prize](#premio).
  </Field>

  <Field name="tiendanube_coupon" type="Tiendanube coupon | null">
    The coupon, if the benefit applies in a Tiendanube store. See
    [Tiendanube coupon](#cupón-de-tiendanube).
  </Field>
</Fields>

### Benefit (v2)
[`GET /v2/benefits/preview/{client_benefit_code}`](https://docs.loybox.com.ar/api-reference/beneficios/consultar-codigo-v2)
returns a version with three extra fields, which save you from digging into
`prize` for the basics:

<Fields>
  <Field name="title" type="string" required="true">
    The benefit's title. In v1 it only lived inside `prize`.
  </Field>

  <Field name="value" type="number | null">
    The discount's value: the percentage if it is `percentage_discount`, the
    amount if it is `absolute_discount`.
  </Field>

  <Field name="product" type="Product | null">
    The product, if it is `free_product`. See [Product](#producto).
  </Field>
</Fields>

Every other field is the same as in [Benefit](#beneficio).

## Redeemable benefit
A benefit a member already bought. Appears in
[purchased benefits](https://docs.loybox.com.ar/api-reference/clientes/beneficios-comprados),
[my benefits](https://docs.loybox.com.ar/api-reference/mi-cuenta/mis-beneficios) and as the response of
[buying a benefit](https://docs.loybox.com.ar/api-reference/mi-cuenta/comprar-beneficio).

<Fields>
  <Field name="client_benefit_code" type="integer" required="true">
    The redemption code. It is what the member presents at the commerce, and also
    the coupon code in an online store.
  </Field>

  <Field name="issue_date" type="date-time" required="true">
    When they bought it.
  </Field>

  <Field name="due_date" type="date-time | null">
    How long they have to redeem it. `null` if it does not expire.
  </Field>

  <Field name="used" type="boolean">
    Whether it was already redeemed. Defaults to `false`.
  </Field>

  <Field name="benefit" type="Benefit" required="true">
    The benefit bought. See [Benefit](#beneficio).
  </Field>
</Fields>

## Prize
The detail of what the member wins. It lives inside `prize`.

<Fields>
  <Field name="type" type="string" required="true">
    `percentage_discount`, `absolute_discount` or `free_product`.
  </Field>

  <Field name="title" type="string | null">
    The reward's title.
  </Field>

  <Field name="description" type="string | null">
    The reward's description.
  </Field>

  <Field name="value" type="number | null">
    The discount's percentage or amount, depending on the `type`.
  </Field>

  <Field name="product" type="Product | null">
    The gift product. See [Product](#producto).
  </Field>

  <Field name="expiration" type="date-time | null">
    The reward's expiration.
  </Field>

  <Field name="image" type="string | null">
    URL of the reward's image.
  </Field>
</Fields>

## Product
<Fields>
  <Field name="id" type="integer | string | null">
    The product's id in Loybox.
  </Field>

  <Field name="name" type="string | null">
    The product's name.
  </Field>

  <Field name="external_id" type="string | null">
    The product's id in the commerce's own system.
  </Field>
</Fields>

## Commerce
The program's branding data. Appears in
[commerce data](https://docs.loybox.com.ar/api-reference/publico/comercio) and inside
[my account](https://docs.loybox.com.ar/api-reference/mi-cuenta/obtener).

<Fields>
  <Field name="id" type="integer" required="true">
    The `commerce_id`, the same one that goes in the `X-Commerce-Id` header.
  </Field>

  <Field name="name" type="string" required="true">
    The commerce's name.
  </Field>

  <Field name="logo" type="string | null">
    URL of the logo.
  </Field>

  <Field name="color" type="string | null">
    Brand color in hexadecimal, for the program's UI.
  </Field>

  <Field name="category_name" type="string | null">
    The commerce's category, for example `Tienda de comics`.
  </Field>

  <Field name="currency" type="string | null">
    The commerce's currency.
  </Field>
</Fields>

## My account
The response of [`GET /v1/me`](https://docs.loybox.com.ar/api-reference/mi-cuenta/obtener).

<Fields>
  <Field name="username" type="string | null">
    The user's name.
  </Field>

  <Field name="email" type="string | null">
    The user's email.
  </Field>

  <Field name="phone" type="string | null">
    The user's phone.
  </Field>

  <Field name="points" type="integer">
    The user's points at this commerce. Defaults to `0`.
  </Field>

  <Field name="subscribed" type="boolean">
    Whether the user is subscribed to this commerce's program. Defaults to
    `false`.
  </Field>

  <Field name="commerce" type="Commerce | null">
    The commerce's data, to paint the program's branding. See
    [Commerce](#comercio).
  </Field>

  <Field name="points_expiration" type="Points expiration | null">
    Points about to expire. See
    [Points expiration](#vencimiento-de-puntos).
  </Field>
</Fields>

## Points expiration
<Fields>
  <Field name="points" type="integer">
    Points about to expire. Defaults to `0`.
  </Field>

  <Field name="expiration_date" type="date-time | null">
    When they expire.
  </Field>

  <Field name="days_left" type="integer | null">
    Days remaining.
  </Field>

  <Field name="months_left" type="integer | null">
    Months remaining.
  </Field>

  <Field name="mode" type="string | null">
    How points expire at this commerce: `none`, `rolling` or `accumulated`.
    `none` means they do not expire.
  </Field>
</Fields>

<Callout type="info" title="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](https://docs.loybox.com.ar/puntos-y-premios/expiracion) for the detail of the modes.
</Callout>

## Tier
The response of [`GET /v1/me/level`](https://docs.loybox.com.ar/api-reference/mi-cuenta/nivel).

<Callout type="info">
  The endpoint and its fields say `level`; this documentation says "tier", which is
  the product's term in English. It is the same thing.
</Callout>

<Fields>
  <Field name="name" type="string | null">
    The tier's name.
  </Field>

  <Field name="rank" type="integer | null">
    The tier's position in the ladder.
  </Field>

  <Field name="points_multiplier" type="number | null">
    The points multiplier the tier grants.
  </Field>

  <Field name="icon_url" type="string | null">
    URL of the tier's icon.
  </Field>

  <Field name="reached_at" type="date-time | null">
    When they reached the tier.
  </Field>

  <Field name="expiration_date" type="date-time | null">
    When the tier expires.
  </Field>

  <Field name="is_expired" type="boolean | null">
    Whether the tier already expired.
  </Field>

  <Field name="next_level" type="Next tier | null">
    The next tier and what is missing to reach it. See
    [Next tier](#próximo-nivel).
  </Field>

  <Field name="total_earned_points" type="integer | null">
    Points earned in total, the lifetime accumulated figure.
  </Field>

  <Field name="total_spent_amount" type="number | null">
    Amount spent in total.
  </Field>

  <Field name="total_consumptions_count" type="integer | null">
    Number of consumptions recorded.
  </Field>
</Fields>

### Next tier
<Fields>
  <Field name="name" type="string | null">
    The next tier's name.
  </Field>

  <Field name="rank" type="integer | null">
    The next tier's position.
  </Field>

  <Field name="threshold_type" type="string | null">
    What the threshold is measured in: accumulated points or amount spent.
  </Field>

  <Field name="threshold" type="number | null">
    The threshold value to reach.
  </Field>
</Fields>

## Activity item
Each item of [my history](https://docs.loybox.com.ar/api-reference/mi-cuenta/historial).

<Fields>
  <Field name="type" type="string" required="true">
    What 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).
  </Field>

  <Field name="date" type="date-time | null">
    When it happened.
  </Field>

  <Field name="points" type="integer | null">
    Points the item added or subtracted.
  </Field>

  <Field name="benefit" type="Benefit | null">
    The benefit involved, on benefit items. See
    [Benefit](#beneficio).
  </Field>

  <Field name="amount" type="number | null">
    The purchase amount, on `consumption` items.
  </Field>

  <Field name="event" type="string | null">
    The event that triggered the reward, on `points_special_reward` items.
  </Field>

  <Field name="additional_note" type="string | null">
    Additional note on the item.
  </Field>
</Fields>

## Automatic reward
Each item of [program rewards](https://docs.loybox.com.ar/api-reference/mi-cuenta/recompensas).

<Fields>
  <Field name="event" type="string" required="true">
    The event that triggers it: `welcome`, `birthday` or `monthly_top`.
  </Field>

  <Field name="reward_type" type="string" required="true">
    `benefit` if it delivers a benefit, `points` if it delivers points.
  </Field>

  <Field name="benefit" type="Benefit | null">
    The benefit it delivers, when `reward_type` is `benefit`. See
    [Benefit](#beneficio).
  </Field>

  <Field name="points" type="integer | null">
    The points it delivers, when `reward_type` is `points`.
  </Field>
</Fields>

## Session
The response of
[verifying the code](https://docs.loybox.com.ar/api-reference/autenticacion/verificar-codigo).

<Fields>
  <Field name="access" type="string" required="true">
    Access token. Sent as `Authorization: Bearer {access}` on the My account
    endpoints.
  </Field>

  <Field name="refresh" type="string" required="true">
    Refresh token, to get a new `access` without asking for another code.
  </Field>

  <Field name="expires_in" type="integer" required="true">
    Seconds the access token stays valid.
  </Field>

  <Field name="user_id" type="integer" required="true">
    The user's id.
  </Field>

  <Field name="username" type="string | null">
    The user's name.
  </Field>

  <Field name="email" type="string | null">
    The user's email.
  </Field>

  <Field name="phone" type="string | null">
    The user's phone.
  </Field>
</Fields>

## Tiendanube coupon
Lives inside `tiendanube_coupon` when the benefit applies in a
[Tiendanube](https://docs.loybox.com.ar/integraciones/tiendanube) store.

<Fields>
  <Field name="type" type="string" required="true">
    `percentage`, `absolute` or `shipping`.
  </Field>

  <Field name="value" type="number" required="true">
    The coupon's value.
  </Field>

  <Field name="category" type="string | null">
    Id of the Tiendanube category the coupon applies to.
  </Field>

  <Field name="category_name" type="string | null">
    That category's name.
  </Field>

  <Field name="end_date" type="date-time | null">
    How long the coupon is valid for.
  </Field>

  <Field name="product" type="Tiendanube product | null">
    The product the coupon applies to, if it applies to a single one. See
    [Tiendanube product](#producto-de-tiendanube).
  </Field>
</Fields>

### Tiendanube product
<Fields>
  <Field name="tiendanube_id" type="integer | null">
    The product's id in Tiendanube.
  </Field>

  <Field name="name" type="string | null">
    The product's name.
  </Field>

  <Field name="url" type="string | null">
    URL of the product in the store.
  </Field>

  <Field name="available" type="boolean | null">
    Whether it is in stock.
  </Field>

  <Field name="published" type="boolean | null">
    Whether it is published in the store.
  </Field>

  <Field name="brand" type="string | null">
    The product's brand.
  </Field>

  <Field name="categories" type="array of categories">
    The product's categories, each with `id` and `name`. Empty by default.
  </Field>
</Fields>
