You can use this API request to award a badge to a user as a result of an action they performed.
/services/v2/award/[awardTypeId]/action/[actionId].json
You should use this request method to complement the award policy of installed AwardRunners. AwardRunner still needs to recognize the type of action specified with a request parameter actionId.
Additionally, the system still respects the mode of the AwardType.
- For example: If a user can only receive an AwardType once and that user already received that AwardType, then invoking this service method does not have any effect. On the other hand, if they do not have the award yet, then the user receives the new award.
-Additional Use Case/Example: You can use this endpoint to grant awards for actions outside of the application. If you wrote a plugin where you wanted to track a badge inside AH when someone got an applause emoji in slack, you would make a "SlackApplause" action and an "applause received" award runner; then you would have to make a slack bot somewhere that listened for that emoji and called that award through an API call.
You can use the following parameters in your award a badge to a user for an action 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 actionId are placeholders for the actual identifier of the AwardType and Action, respectively.
You should format both as valid integer numbers (digit characters only).
- The AwardType with the corresponding identifier should already be installed in the system.
- The actionId should be a valid identifier of an action capturing a persistent system event.
- The system extracts the user that receives the award from the Action.user property.
We added this request in version 1.6.3.
Sample Request
A POST award a badge to a user for an action request to award the Editor award (awardTypeId: 507), to the user that made the edit action (actionId: 1125) 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/507/action/1125.json" -v
Community User Interface Result
You should see users who received the editor award
The user receives the editor award (awardTypeId:507) for the edit action (actionId:1125).