> ## Documentation Index
> Fetch the complete documentation index at: https://docs.opengame.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Achievements

> Achievements a game declares in opengame.json and unlocks for the players through the OpenGame SDK, each unlock stored as the game's claim.

You declare achievements in `opengame.json`, and a running game unlocks them for the player. An unlock is the game's claim: OpenGame stores it for the player and does not verify it. Games call these routes through the SDK.

[Authentication](https://docs.opengame.io/api-reference/authentication.md) covers each credential, and [errors](https://docs.opengame.io/api-reference/errors.md) covers the JSON error body.

## List the player's achievements in this game

`GET https://api.opengame.gg/v1/achievements`

**Authentication:** A game session token.

Each active achievement the game declared, and whether this player has unlocked it. Reading also counts this player as seen in the game, which is what rarity is measured against. Only for a published, live game: unavailable in a private preview or a review build. Rate limited per session, player and address.

### Request

```bash cURL theme={"system"}
curl --request GET \
  --url 'https://api.opengame.gg/v1/achievements' \
  --header "Authorization: Bearer $OPENGAME_SESSION"
```

### Response 200

One entry per achievement, by ID.

```json theme={"system"}
[
  {
    "achievementId": "first_win",
    "title": "First win",
    "description": "Finish any level with every marble.",
    "unlocked": true,
    "unlockedAt": "2026-10-21T19:04:12Z",
    "source": "game_reported"
  },
  {
    "achievementId": "full_drain",
    "title": "Full drain",
    "description": "Reach the river without losing a marble.",
    "unlocked": false,
    "unlockedAt": null,
    "source": "game_reported"
  }
]
```

### Errors

| Status | Meaning |
| - | - |
| 400 | `invalid_achievement`: this session's build is no longer published. Ask the page for a new session. |
| 401 | `token_rejected`: `reason` names why and `mint` names where a new session comes from. `session_rejected`: the player changed identity. Ask the page for a new session either way. |
| 403 | `origin_not_allowed`, `origin_mismatch`, `host_not_live`, `preview_session_mismatch` or `embed_not_allowed`; `unavailable_in_preview` or `preview_unavailable` for a preview or review build; or `achievement_unavailable`. |
| 405 | `method_not_allowed`. `Allow` lists the methods this path takes, except on a private preview, which sends no `Allow`. |
| 429 | `rate_limited`: `scope` names the budget that ran out. Wait for `Retry-After`, which is 60 seconds. |
| 500 | `internal_error`, sent without CORS headers, so a frame sees a failed request. Retry later. |
| 503 | `achievement_unavailable`, `rate_limit_unavailable` or `embed_unavailable`. Not caused by the request. Retry later. |

## Unlock an achievement

`POST https://api.opengame.gg/v1/achievements`

**Authentication:** A game session token.

Who and which game come from the session token. Unlocking twice is harmless: the first unlock is kept and `firstUnlock` names whether this call made it. The unlock is the game's claim. Not offered in a private preview or a review build.

### Body

Sent as `application/json`.

**achievement** `string` *required*

An active achievement ID the game declared. At most 48 characters. Matches `^[a-z0-9][a-z0-9_-]*$`. Example: `first_win`.

### Request

```bash cURL theme={"system"}
curl --request POST \
  --url 'https://api.opengame.gg/v1/achievements' \
  --header "Authorization: Bearer $OPENGAME_SESSION" \
  --header 'Content-Type: application/json' \
  --data '{
  "achievement": "first_win"
}'
```

### Response 200

Unlocked.

```json theme={"system"}
{
  "achievementId": "first_win",
  "unlocked": true,
  "firstUnlock": true,
  "unlockedAt": "2026-10-21T19:04:12Z",
  "source": "game_reported"
}
```

### Errors

| Status | Meaning |
| - | - |
| 400 | `invalid_achievement`: the body is not JSON, is over 2 KB, has another key, or names an achievement the game did not declare or turned off. Also sent when the session's build is no longer published. |
| 401 | `token_rejected`: `reason` names why and `mint` names where a new session comes from. `session_rejected`: the player changed identity. Ask the page for a new session either way. |
| 403 | `origin_not_allowed`, `origin_mismatch`, `host_not_live`, `preview_session_mismatch` or `embed_not_allowed`; `unavailable_in_preview` or `preview_unavailable` for a preview or review build; or `achievement_unavailable`. |
| 405 | `method_not_allowed`. `Allow` lists the methods this path takes, except on a private preview, which sends no `Allow`. |
| 429 | `rate_limited`: `scope` names the budget that ran out. Wait for `Retry-After`, which is 60 seconds. |
| 500 | `internal_error`, sent without CORS headers, so a frame sees a failed request. Retry later. |
| 503 | `achievement_unavailable`, `rate_limit_unavailable` or `embed_unavailable`. Not caused by the request. Retry later. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.