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",
}
});from trophy import TrophyApi
client = TrophyApi(api_key='YOUR_API_KEY')
user = UpsertedUser(id="123")
response = client.achievements.complete("achievement-key", user=user)import (
"context"
api "github.com/trophyso/trophy-go"
trophyclient "github.com/trophyso/trophy-go/client"
"github.com/trophyso/trophy-go/option"
)
client := trophyclient.NewClient(
option.WithApiKey("YOUR_API_KEY"),
)
response, err := client.Achievements.Complete(
context.TODO(),
"achievement-key",
&api.AchievementsCompleteRequest{
User: &api.UpsertedUser{Id: "user-id"},
},
)curl --request POST \
--url https://api.trophy.so/v1/achievements/{key}/complete \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"user": {
"id": "user-id",
"email": "user@example.com",
"tz": "Europe/London",
"subscribedToEmails": true
}
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.trophy.so/v1/achievements/{key}/complete",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'user' => [
'id' => 'user-id',
'email' => 'user@example.com',
'tz' => 'Europe/London',
'subscribedToEmails' => true
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://api.trophy.so/v1/achievements/{key}/complete")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"user\": {\n \"id\": \"user-id\",\n \"email\": \"user@example.com\",\n \"tz\": \"Europe/London\",\n \"subscribedToEmails\": true\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trophy.so/v1/achievements/{key}/complete")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"user\": {\n \"id\": \"user-id\",\n \"email\": \"user@example.com\",\n \"tz\": \"Europe/London\",\n \"subscribedToEmails\": true\n }\n}"
response = http.request(request)
puts response.read_body{
"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
}
}
]
}
}
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}Achievements
Mark an achievement as completed
Mark an achievement as completed for a user.
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",
}
});from trophy import TrophyApi
client = TrophyApi(api_key='YOUR_API_KEY')
user = UpsertedUser(id="123")
response = client.achievements.complete("achievement-key", user=user)import (
"context"
api "github.com/trophyso/trophy-go"
trophyclient "github.com/trophyso/trophy-go/client"
"github.com/trophyso/trophy-go/option"
)
client := trophyclient.NewClient(
option.WithApiKey("YOUR_API_KEY"),
)
response, err := client.Achievements.Complete(
context.TODO(),
"achievement-key",
&api.AchievementsCompleteRequest{
User: &api.UpsertedUser{Id: "user-id"},
},
)curl --request POST \
--url https://api.trophy.so/v1/achievements/{key}/complete \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"user": {
"id": "user-id",
"email": "user@example.com",
"tz": "Europe/London",
"subscribedToEmails": true
}
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.trophy.so/v1/achievements/{key}/complete",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'user' => [
'id' => 'user-id',
'email' => 'user@example.com',
'tz' => 'Europe/London',
'subscribedToEmails' => true
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://api.trophy.so/v1/achievements/{key}/complete")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"user\": {\n \"id\": \"user-id\",\n \"email\": \"user@example.com\",\n \"tz\": \"Europe/London\",\n \"subscribedToEmails\": true\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trophy.so/v1/achievements/{key}/complete")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"user\": {\n \"id\": \"user-id\",\n \"email\": \"user@example.com\",\n \"tz\": \"Europe/London\",\n \"subscribedToEmails\": true\n }\n}"
response = http.request(request)
puts response.read_body{
"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
}
}
]
}
}
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}Authorizations
Headers
The tenant identifier for multi-tenant organisations. Required when the organisation has multi-tenancy enabled. The value should be your internal ID for the tenant. Ignored for single-tenant organisations.
Path Parameters
Unique reference of the achievement as set when created.
Body
application/json
The user that completed the achievement.
Show child attributes
Show child attributes
Response
Successful operation
The unique ID of the completion.
Example:
"0040fe51-6bce-4b44-b0ad-bddc4e123534"
Show child attributes
Show child attributes
A map of points systems by key that were affected by this achievement completion.
Show child attributes
Show child attributes
Was this page helpful?
⌘I