JavaScript
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.
Unique reference of the achievement as set when created.
The user that completed the achievement.
Show child attributes
Successful operation
The unique ID of the completion.
"0040fe51-6bce-4b44-b0ad-bddc4e123534"
A map of points systems by key that were affected by this achievement completion.
Was this page helpful?