POST
/
achievements
/
{key}
/
complete
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
          }
        }
      ]
    }
  }
}

Authorizations

X-API-KEY
string
header
required

Path Parameters

key
string
required

Unique reference of the achievement as set when created.

Body

application/json
user
object
required

The user that completed the achievement. An object with editable user fields.

Response

Successful operation

completionId
string
required

The unique ID of the completion.

Example:

"0040fe51-6bce-4b44-b0ad-bddc4e123534"

achievement
object
required
points
object

A map of points systems by key that were affected by this achievement completion.