This article was created from a community discussion.
Badges in Higher Logic Vanilla are a great way to recognize and reward community members for their engagement, contributions, and milestones. Whether you're automating onboarding, integrating with an LMS, or connecting to an external CRM or event system, you might want to programmatically assign badges to users. Thankfully, Vanilla's API makes this easy.
We’ll walk through how to assign a badge to a user using the Vanilla API from an external system.
Prerequisites
Before you begin, make sure you have:
- Admin access to your Vanilla community.
- A valid API token with appropriate permissions.
- The ID of the user to whom you want to assign the badge.
- The ID of the badge you want to assign.
Endpoint Overview
To assign a badge to a user, you’ll use the following endpoint:
POST /api/v2/users/{userID}/badges
This endpoint allows you to associate a badge with a specific user.
Authentication
Vanilla uses a Bearer token to authentication for API. You'll need to include the token in the Authorization
header of your request.
Authorization: Bearer YOUR_TOKEN
If you don’t yet have a token, read the following to learn how to get one:
https://success.vanillaforums.com/kb/articles/41-authenticating-apiv2-calls-with-personal-access-tokens#generate-an-access-token
Request Body
Here’s the JSON payload you’ll need to send in your POST
request:
{ "badgeID": 123}
Replace 123
with the actual ID of the badge you want to assign.
Example Request
Here’s an example using curl
:
curl -X POST https://yourcommunity.vanillacommunities.com/api/v2/users/456/badges \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{"badgeID": 123}'
This command assigns the badge with ID 123
to the user with ID 456
.
How to Find Badge and User IDs
- User IDs: You can retrieve user IDs using the
GET /api/v2/users
endpoint or based on email/username queries. - Badge IDs: You can list all badges using
GET /api/v2/badges
.
Conclusion
Assigning badges via the Vanilla API enables powerful integrations and automation opportunities to keep your community experience dynamic and rewarding. By using the /users/{userID}/badges
endpoint, you can seamlessly recognize users from any external system, making badges more than just flair, but a part of your customer engagement strategy.