Skip to content
  1. Home
  2. Docs
  3. WooRewards
  4. REST API
  5. Unlock a reward for a user

Unlock a reward for a user

Consume the points of a user to grant him a reward from a loyalty system

This API route allows you to grant a reward to a user. The points of the user will be consumed in the point pool used by the loyalty system the reward belong to. It requires the user writing permission.

PUT
/wp-json/woorewards/v1/pools/<pool_id>/rewards/<reward_id>/unlock/<user_email>

Available parameters

  • pool_id (string) : A loyalty system identifier as read from previous API route.
  • reward_id (int) : A reward identifier as read from previous API route.
  • user_email (string) : A user email.

Response

The JSON response is a status object. That object contains at least the following properties:

  • points : A status object with the following properties:
    • id : The loyalty system identifier as set in the parameters.
    • points : The identifier of the points pool (since several loyalty system can share the same points pool).
    • value : The new user points amount in this points pool.
    • rewards : The unlocked reward count. Must be 1.
  • reward : A reward object with at least the following properties:
    • id : The unlocked reward identifier as set in the parameters.
    • cost : The amount of point required (and consumed) to purchase the reward.
    • title : The public reward title.
    • description : The plain text reward description.

Error cases

A 404 error is raised if the user cannot be found by email.

A 404 error is raised if the loyalty system identifier cannot be found.

A 404 error is raised if the reward identifier cannot be found in the loyalty system.

A 410 error is raised if the pool is not active.

A 409 error is raised if the user does not fulfill the conditions (point amount, user role restriction, etc.)

Was this article helpful to you? Yes No

How can we help?

Scroll To Top