import { TrophyApiClient } from '@trophyso/node';
const trophy = new TrophyApiClient({
apiKey: 'YOUR_API_KEY'
});
const response = await trophy.achievements.complete("achievement-key", {
user: {
id: "user-id",
}
});
{
"completionId": "0040fe51-6bce-4b44-b0ad-bddc4e123534",
"achievement": {
"id": "5100fe51-6bce-6j44-b0hs-bddc4e123682",
"trigger": "api",
"name": "Finish onboarding",
"description": "Complete the onboarding process.",
"badgeUrl": "https://example.com/badge.png",
"key": "finish-onboarding",
"achievedAt": "2021-01-01T00:00:00Z"
},
"points": {
"points-system-key": {
"id": "0040fe51-6bce-4b44-b0ad-bddc4e123534",
"name": "XP",
"description": null,
"badgeUrl": null,
"total": 10,
"added": 10,
"awards": [
{
"id": "0040fe51-6bce-4b44-b0ad-bddc4e123534",
"awarded": 10,
"date": "2021-01-01T00:00:00Z",
"total": 10,
"trigger": {
"id": "0040fe51-6bce-4b44-b0ad-bddc4e123534",
"type": "achievement",
"achievementName": "Finish onboarding",
"points": 10
}
}
]
}
}
}
Mark an achievement as completed for a user.
import { TrophyApiClient } from '@trophyso/node';
const trophy = new TrophyApiClient({
apiKey: 'YOUR_API_KEY'
});
const response = await trophy.achievements.complete("achievement-key", {
user: {
id: "user-id",
}
});
{
"completionId": "0040fe51-6bce-4b44-b0ad-bddc4e123534",
"achievement": {
"id": "5100fe51-6bce-6j44-b0hs-bddc4e123682",
"trigger": "api",
"name": "Finish onboarding",
"description": "Complete the onboarding process.",
"badgeUrl": "https://example.com/badge.png",
"key": "finish-onboarding",
"achievedAt": "2021-01-01T00:00:00Z"
},
"points": {
"points-system-key": {
"id": "0040fe51-6bce-4b44-b0ad-bddc4e123534",
"name": "XP",
"description": null,
"badgeUrl": null,
"total": 10,
"added": 10,
"awards": [
{
"id": "0040fe51-6bce-4b44-b0ad-bddc4e123534",
"awarded": 10,
"date": "2021-01-01T00:00:00Z",
"total": 10,
"trigger": {
"id": "0040fe51-6bce-4b44-b0ad-bddc4e123534",
"type": "achievement",
"achievementName": "Finish onboarding",
"points": 10
}
}
]
}
}
}
Unique reference of the achievement as set when created.
Successful operation
The response is of type object
.
Was this page helpful?