Saltar al contenido
tablezio

Fidelización

Reglas y premios de fidelización

Las reglas describen mapeos disparador → premio (recuento de visitas, umbral de gasto, cumpleaños, win-back). Cuando una regla se dispara, Tablezio crea un loyalty_reward asociado al cliente.

List loyalty rules

GET /v1/loyalty_rules Permiso: loyalty:read

Rules that automatically issue rewards based on customer activity.

Solicitud

curl https://api.tablezio.com/v1/loyalty_rules -H 'X-API-Key: tbz_…'

Respuesta

application/json
{ "object": "list", "data": [ /* loyalty_rule */ ], "has_more": false, "next_cursor": null, "previous_cursor": null, "url": "/v1/loyalty_rules" }

Create a loyalty rule

POST /v1/loyalty_rules Permiso: loyalty:write

Defines a trigger → reward mapping. When the trigger fires for a customer, a loyalty_reward is created automatically.

Parámetros del cuerpo

namestringObligatorio

Display name in the dashboard.

trigger_typestringObligatorio

What event awards the reward.

visit_milestonespend_milestonebirthdayanniversarypoints_thresholdwin_back
trigger_valuenumberOpcional

Threshold (visits, cents spent, points). Required for milestone triggers.

win_back_daysintegerOpcional

For win_back triggers: number of days of inactivity before firing.

reward_typestringObligatorio

Kind of reward.

pointsdiscount_percentagediscount_fixedfree_item
reward_valuenumberObligatorio

Amount of points, percentage (0..100), or fixed cents.

reward_descriptionstringOpcional

Guest-facing description.

is_activebooleanOpcional

Default true.

Solicitud

curl -X POST https://api.tablezio.com/v1/loyalty_rules \
  -H 'X-API-Key: tbz_…' -H 'Content-Type: application/json' \
  -d '{
    "name": "Welcome bonus",
    "trigger_type": "visit_milestone",
    "trigger_value": 1,
    "reward_type": "points",
    "reward_value": 100
  }'

Respuesta

application/json
{
  "id": "loy_8b2c3d4e5f6a7b8c9d0e1f20",
  "object": "loyalty_rule",
  "created": 1716730000,
  "updated": 1716730000,
  "name": "Welcome bonus",
  "trigger_type": "visit_milestone",
  "trigger_value": 1,
  "win_back_days": null,
  "reward_type": "points",
  "reward_value": 100,
  "reward_description": "100 points on first visit",
  "is_active": true,
  "times_triggered": 42
}

List loyalty rewards

GET /v1/loyalty_rewards Permiso: loyalty:read

Rewards that have been issued (not yet redeemed, redeemed, or expired).

Parámetros de consulta

customerstringOpcional

Filter to a single customer (cus_…).

statusstringOpcional

Filter by status.

pendingredeemedexpired
expandstring[]Opcional

customer.

Solicitud

curl 'https://api.tablezio.com/v1/loyalty_rewards?status=pending' -H 'X-API-Key: tbz_…'

Respuesta

application/json
{ "object": "list", "data": [ /* loyalty_reward */ ], "has_more": false, "next_cursor": null, "previous_cursor": null, "url": "/v1/loyalty_rewards" }

Retrieve a loyalty reward

GET /v1/loyalty_rewards/{id} Permiso: loyalty:read

Fetch a single reward.

Parámetros de ruta

idstringObligatorio

Reward ID (loytx_…).

Parámetros de consulta

expandstring[]Opcional

customer.

Solicitud

curl https://api.tablezio.com/v1/loyalty_rewards/loytx_… -H 'X-API-Key: tbz_…'

Respuesta

application/json
{
  "id": "loytx_8b2c3d4e5f6a7b8c9d0e1f20",
  "object": "loyalty_reward",
  "created": 1716730000,
  "updated": 1716730000,
  "customer": "cus_…",
  "rule": "loy_…",
  "reward_type": "discount_percentage",
  "reward_value": 10,
  "description": "10% off next visit",
  "status": "pending",
  "redeemed_at": null,
  "expires_at": null
}

Redeem a loyalty reward

POST /v1/loyalty_rewards/{id}/redeem Permiso: loyalty:write

Marks a pending reward as redeemed. Returns the updated reward.

Parámetros de ruta

idstringObligatorio

Reward ID.

Solicitud

curl -X POST https://api.tablezio.com/v1/loyalty_rewards/loytx_…/redeem -H 'X-API-Key: tbz_…'

Respuesta

application/json
{
  "id": "loytx_8b2c3d4e5f6a7b8c9d0e1f20",
  "object": "loyalty_reward",
  "created": 1716730000,
  "updated": 1716730000,
  "customer": "cus_…",
  "rule": "loy_…",
  "reward_type": "discount_percentage",
  "reward_value": 10,
  "description": "10% off next visit",
  "status": "pending",
  "redeemed_at": null,
  "expires_at": null
}

Retrieve a loyalty rule

GET /v1/loyalty_rules/{id} Permiso: loyalty:read

Returns a single earn or burn rule. Rules are what the programme is made of, so reading one back is how you confirm the terms a guest is actually being scored against.

Parámetros de ruta

idstringObligatorio

Loyalty rule id (lrule_…).

Solicitud

curl 'https://api.tablezio.com/v1/loyalty_rules/lrule_5a1b2c3d4e5f6a7b8c9d0e1f' \
  -H 'X-API-Key: tbz_…'

Update a loyalty rule

PATCH /v1/loyalty_rules/{id} Permiso: loyalty:write

Updates the rule in place. Changing a rule changes how future activity is scored; points already awarded under the old terms are not recalculated.

Parámetros de ruta

idstringObligatorio

Loyalty rule id (lrule_…).

Parámetros del cuerpo

namestringOpcional

Optional. Same meaning as on create.

trigger_typestringOpcional

Optional. Same meaning as on create.

trigger_valuenumberOpcional

Optional. Same meaning as on create.

win_back_daysintegerOpcional

Optional. Same meaning as on create.

reward_typestringOpcional

Optional. Same meaning as on create.

reward_valuenumberOpcional

Optional. Same meaning as on create.

reward_descriptionstringOpcional

Optional. Same meaning as on create.

is_activebooleanOpcional

Optional. Same meaning as on create.

Solicitud

curl -X PATCH 'https://api.tablezio.com/v1/loyalty_rules/lrule_5a1b2c3d4e5f6a7b8c9d0e1f' \
  -H 'X-API-Key: tbz_…' \
  -H 'Content-Type: application/json' \
  -d '{"active": false}'

Delete a loyalty rule

DELETE /v1/loyalty_rules/{id} Permiso: loyalty:write

Retires the rule. Prefer deactivating it if you may want the terms back — a deleted rule cannot be restored from the API.

Parámetros de ruta

idstringObligatorio

Loyalty rule id (lrule_…).

Solicitud

curl -X DELETE 'https://api.tablezio.com/v1/loyalty_rules/lrule_5a1b2c3d4e5f6a7b8c9d0e1f' \
  -H 'X-API-Key: tbz_…'