Manually Award a Badge to a User

You can use this API request to manually award a badge to a user.

/services/v2/award/[awardTypeId]/user/[userId].json

The system installs AwardTypes by having a plugin contribute an implementation of AwardRunner.

Using this request method by-passes the award policy of the AwardRunner and also the mode of the AwardType. If an AwardType is set up in an AwardType.mode that prevents it from assigning more than once to a single user when actions trigger, that policy can be overridden by this method.

  • For example: The system may give a user multiple awards of that same type even if the AwardType says it cannot.

    • Note: Consider this when designing client applications. A possible design-pattern is for the client application to first, check how many awards of that type the user has, before deciding to give a new award.

You can use the following parameters in your manually award a badge to a user request:

Other options: wrap

🚧

Permissions & Notes:

  • You must have the Award bonus reputation permission under Moderation Roles in the Advanced Editor to use this request.

  • The URI/URL parameters awardTypeId and userId are placeholders for the actual identifier of the AwardType and User, respectively.

  • You should format both as valid integer numbers (digit characters only).

    • The system should have already installed the AwardType with the corresponding identifier.
    • The userId should also be a valid identifier of a user registered in the system.

Sample Request

📘

PRO TIP:

Make a GET request to retrieve the user list and the award list to get the ID for each.

A POST manually award a badge to a user request to award the Bright Idea award (awardTypeId: 501) to the Answerhub user (userId: 97) on https://apidocs.cloud.answerhub.com using a human-readable Username/Password (answerhub/test123) would look like this:

curl 
-u answerhub:test123
-H "Accept: application/json" 
-H "Content-type: application/json" 
-X POST "https://apidocs.cloud.answerhub.com/services/v2/award/501/user/97.json" -v

Expected Response

Successful Response:

  • HTTP Status 200 - OK

Community User Interface Result

You will see the user called demo3 (userId:97) awarded the Bright Idea award (awardTypeId:501)

You can also see the list of awards given to the user demo3 from their profile, at the bottom of the page, labeled Badges

Language
Authorization
Basic
base64
:
Click Try It! to start a request and see the response here!