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

# Achievements and XP

> Define achievements in the portal, unlock them from your game or your server, and give players XP that follows them everywhere.

Achievements reward players for playing your game. Each one adds XP to the player's Gamavas level, which they carry to every game on Gamavas. Their profile shows them too.

## Define them in the portal

On your app's **Achievements** page in the [developer portal](https://developer.gamavas.fun), add achievements with:

| Field | |
| - | - |
| **Key** | What your code unlocks, for example `first-win`. Keep it stable |
| **Name** and **description** | What players see |
| **Icon** | An `https://` image address, optional |
| **XP** | Up to 25, or up to 100 for server achievements |
| **Who can unlock it** | **Your game**, or **only your server** |
| **Hidden** | Players only see it once they've unlocked it |

An app can have up to 200 achievements. They're listed in the order you add them, and you can archive ones you no longer use.

## Unlock from your game

```js Web theme={"theme":{"light":"github-light","dark":"github-dark"}}
const result = await pass.unlock("first-win");
// { newlyUnlocked: true, xpAwarded: 20, achievement: { key, name, iconUrl } }
```

```csharp Unity theme={"theme":{"light":"github-light","dark":"github-dark"}}
UnlockResult result = await GamavasPass.UnlockAsync("first-win");
```

```gdscript Godot theme={"theme":{"light":"github-light","dark":"github-dark"}}
var r = await GamavasPass.unlock("first-win")
```

```gml GameMaker theme={"theme":{"light":"github-light","dark":"github-dark"}}
gamavas_unlock("first-win", true, function(_r) { /* _r.value.newlyUnlocked */ });
```

```lua Defold theme={"theme":{"light":"github-light","dark":"github-dark"}}
gamavas.unlock("first-win", function(r) end)
```

In Construct, use the **Unlock achievement** action.

Unlocking again is harmless: `newlyUnlocked` is false and no XP is added. On the web (including WebGL, Construct, GameMaker and Defold), Gamavas shows a small "Achievement unlocked" notice the first time. Turn it off to show your own: `notify: false`, or **Show notice** off in Construct.

## Server achievements

A game running in a browser can be modified, so anything it unlocks can be faked. For achievements that matter, choose **only your server**. Then:

* The game can't unlock it: it gets a `403 forbidden`.
* Your server unlocks it with a secret key, after checking the player really earned it.
* It can give more XP: up to 100.

```ts theme={"theme":{"light":"github-light","dark":"github-dark"}}
await gamavas.unlock(player.id, "beat-the-boss"); // @gamavas/pass-server
```

See [Your server](https://docs.gamavas.fun/pass/your-server.md) for setting up keys and checking who the player is.

## XP limits

XP is capped so no game can farm it:

| Limit | |
| - | - |
| Per achievement | 25 (your game) or 100 (your server) |
| Per player, per game | 1,000 XP from your achievements, ever |
| Per player, per day | 200 XP from all games' achievements |
| You | Your own game's achievements never give you XP |

When a cap is reached, the unlock still counts (`newlyUnlocked: true`) but `xpAwarded` is lower, or 0.

## Listing achievements

`achievements()` returns your game's achievements with the player's progress, in the order you added them. Hidden ones appear once unlocked.

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
[
  { "key": "first-win", "name": "First win", "description": "Win a match", "iconUrl": null,
    "xp": 20, "unlocked": true, "unlockedAt": "2026-12-01T10:00:00.000Z" }
]
```

You can also hear about every unlock on your server with the [`achievement.unlocked` webhook](https://docs.gamavas.fun/pass/webhooks).


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