Achievements
Grant Achievement
Unlock an achievement for a user. Idempotent — calling twice with the same user/achievement returns "already_unlocked" without error.
POST
/api/achievements/grant.php
Requires
Authorization: AppID:AppKey headerIdentify the achievement (one of)
| Field | Type | Description |
|---|---|---|
| slug | string | Achievement slug from your app |
| achievement_id | int | Numeric ID returned by create.php |
Identify the user (one of)
| Field | Type | Description |
|---|---|---|
| user_id | int | Numeric user ID |
| userkey | string | User's userKey |
| token | string | User's session token |
Test this endpoint
Headers
Body
Success response 200
{
"success": true,
"result": "granted",
"achievement": {
"id": 1,
"slug": "first_kill",
"name": "First Kill",
"rarity": "common",
"xp": 100
},
"user_id": 42
}
{
"success": true,
"result": "already_unlocked",
"achievement": { "id": 1, "slug": "first_kill", ... },
"user_id": 42
}
Errors
| Code | Message | Cause |
|---|---|---|
| 401 | Invalid app credentials. | Bad AppID or AppKey |
| 400 | Achievement identifier required. | Neither slug nor achievement_id provided |
| 400 | User identifier required. | No user identification field in body |
| 404 | Achievement not found. | Slug/ID doesn't exist for this app |
| 401 | Invalid or expired token. | Token is invalid or expired |