Join the program

Subscribes the user to the commerce's loyalty program and returns the welcome reward.

POST/v1/me/subscriptionEnd-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.

Verifying the code already subscribes the user

Verifying a code already leaves the user subscribed, so this endpoint is mostly for re-joining after opting out.

Headers

X-Commerce-Idintegerheaderrequired

Id of the commerce integrating the API. Every response is scoped to this commerce.

It carries no body.

Response

messagestringrequired

The operation's result.

welcome_benefitBenefit | null

The welcome benefit, if the commerce configured one and the user just joined. See Benefit.

welcome_pointsinteger | null

Welcome points, if the commerce configured points instead of a benefit.

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"
// 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

CodeWhen
401The access token is missing, expired, or does not belong to an end user.
404The commerce does not exist.
422The X-Commerce-Id header is missing.