# Join the program (https://docs.loybox.com.ar/en/api-reference/mi-cuenta/adherirme)



<Endpoint method="POST" path="/v1/me/subscription" auth="user-token" />

Subscribes the user to the commerce's loyalty program. If the commerce configured a
welcome reward, it comes back in `welcome_benefit` or `welcome_points`.

<Callout type="info" title="Verifying the code already subscribes the user">
  [Verifying a code](https://docs.loybox.com.ar/api-reference/autenticacion/verificar-codigo) already leaves the
  user subscribed, so this endpoint is **mostly for re-joining after opting out**.
</Callout>

## Headers
<Fields>
  <Field name="X-Commerce-Id" type="integer" location="header" required="true">
    Id of the commerce integrating the API. Every response is scoped to this
    commerce.
  </Field>
</Fields>

It carries no body.

## Response
<Fields>
  <Field name="message" type="string" required="true">
    The operation's result.
  </Field>

  <Field name="welcome_benefit" type="Benefit | null">
    The welcome benefit, if the commerce configured one and the user just joined.
    See [Benefit](https://docs.loybox.com.ar/api-reference/objetos#beneficio).
  </Field>

  <Field name="welcome_points" type="integer | null">
    Welcome points, if the commerce configured points instead of a benefit.
  </Field>
</Fields>

```bash
curl -X POST https://loybox-public-api-752998171300.southamerica-west1.run.app/v1/me/subscription \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "X-Commerce-Id: 87"
```

```json
// 200 OK
{
  "message": "Subscribed successfully",
  "welcome_benefit": {
    "id": "b_4c81",
    "type": "free_product",
    "description": "Café de regalo",
    "cost": 0,
    "expiration": null,
    "benefit_type": "welcome",
    "color": "#f1a10d",
    "buy_limit": 1,
    "prize": null,
    "tiendanube_coupon": null
  },
  "welcome_points": null
}
```

The two welcome fields are mutually exclusive: one or the other comes back,
depending on what the commerce configured. If it configured nothing, both come back
`null`.

This is a good moment to show a welcome screen: if `welcome_benefit` came, the
reward; if `welcome_points` came, the points they just earned.

## Errors
| Code  | When                                                                     |
| ----- | ------------------------------------------------------------------------ |
| `401` | The access token is missing, expired, or does not belong to an end user. |
| `404` | The commerce does not exist.                                             |
| `422` | The `X-Commerce-Id` header is missing.                                   |
