Unlock a reward
Unlock a reward

Knowledge Base

This documentation is for the WooRewards plugin

Use this API route to grant a reward to a user. It requires only the user writing permission.

This operation will consume the points set in the points and rewards system. Therefore, the user must have enough points to unlock the reward.

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

Available parameters

  • pool_id : (string) – A points and rewards 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 points and rewards system identifier as set in the parameters.
    • points : The identifier of the points reserve (since several points and rewards systems can share the same points reserve).
    • value : The new user points amount in this points reserve.
    • 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 unlock 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 points and rewards system identifier cannot be found.

A 404 error is raised if the reward identifier cannot be found in the points and rewards 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?
Dislike 0
Views: 158

Continue reading

Previous: Add/Subtract Points