# Look up a code (v2) (https://docs.loybox.com.ar/en/api-reference/beneficios/consultar-codigo-v2)



<Endpoint method="GET" path="/v2/benefits/preview/{client_benefit_code}" auth="api-key" />

It does the same as
[version 1](https://docs.loybox.com.ar/api-reference/beneficios/consultar-codigo), 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
<Fields>
  <Field name="client_benefit_code" type="string" location="path" required="true">
    The redemption code the member holds.
  </Field>
</Fields>

## Response
A [Benefit (v2)](https://docs.loybox.com.ar/api-reference/objetos#beneficio-v2) object.

```bash
curl https://loybox-public-api-752998171300.southamerica-west1.run.app/v2/benefits/preview/887766 \
  -H "Authorization: Bearer $LOYBOX_API_KEY"
```

```json
// 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`](https://docs.loybox.com.ar/api-reference/beneficios/canjear). 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.                      |
