# Join the leaderboard

> Page: https://docs.flung.dev/reference/api/put-v1-leaderboard-entry. Index of every page: https://docs.flung.dev/llms.txt

Lists the workspace under `name`, which every Flung customer can see.

`PUT /v1/leaderboard/entry`

## TL;DR

| Question | Answer |
|---|---|
| What does it do? | Join the leaderboard. |
| What does it need? | An API key or an OAuth access token. |
| What does it take? | A JSON body with the fields below. |
| What does it return? | Status 200 with a body of type [`Experience`](https://docs.flung.dev/reference/api/schemas.md#experience). |
| In the SDK? | `flung.experience.joinLeaderboard()` |
| What can go wrong? | `401` Missing, unknown, revoked or expired API key; `422` The request failed validation; `429` Too many requests for this credential; wait for `retry-after` seconds. Every failure has the same [error shape](https://docs.flung.dev/reference/api/errors.md). |

## What it does

Lists the workspace under `name`, which every Flung customer can see. Its XP and level are shown; nothing else.

## Example

**curl**

```bash
curl -X PUT 'https://api.flung.dev/v1/leaderboard/entry' \
  --header "Authorization: Bearer $FLUNG_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "string"
}'
```

**TypeScript**

```ts
import { Flung } from '@flung.dev/sdk'

const flung = new Flung({ apiKey: process.env.FLUNG_API_KEY! })
const result = await flung.experience.joinLeaderboard({
  name: 'string',
})
```

**fetch**

```js
const response = await fetch('https://api.flung.dev/v1/leaderboard/entry', {
  method: 'PUT',
  headers: {
    'Authorization': `Bearer ${process.env.FLUNG_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    name: 'string',
  }),
})
if (!response.ok) throw new Error((await response.json()).error.message)
const result = await response.json()
```

A successful answer looks like this:

```json
{
  "xp": 1,
  "level": 1,
  "xpIntoLevel": 1,
  "xpForNextLevel": 1,
  "streakDays": 1,
  "leaderboardName": "string",
  "achievements": [
    {
      "id": "first-post",
      "name": "string",
      "description": "string",
      "category": "string",
      "rarity": "common",
      "xp": 1,
      "unlocked": true,
      "unlockedAt": "2026-11-01T09:00:00.000Z",
      "progress": {}
    }
  ]
}
```

## Request body

The body has the type an object, with the fields below.

| Field | Type | Required | Description |
|---|---|---|---|
| `name` | `string` | yes | at least 2 characters; at most 40 characters. |

## Responses

| Status | Meaning | Body |
|---|---|---|
| 200 | The workspace's experience, now listed. | [`Experience`](https://docs.flung.dev/reference/api/schemas.md#experience) |
| 401 | Missing, unknown, revoked or expired API key. | [`Error`](https://docs.flung.dev/reference/api/schemas.md#error) |
| 422 | The request failed validation. | [`Error`](https://docs.flung.dev/reference/api/schemas.md#error) |
| 429 | Too many requests for this credential; wait for `retry-after` seconds. | [`Error`](https://docs.flung.dev/reference/api/schemas.md#error) |

## Response body

A 200 answer has the type [`Experience`](https://docs.flung.dev/reference/api/schemas.md#experience).

| Field | Type | Required | Description |
|---|---|---|---|
| `xp` | `integer` | yes |  |
| `level` | `integer` | yes |  |
| `xpIntoLevel` | `integer` | yes |  |
| `xpForNextLevel` | `integer` | yes |  |
| `streakDays` | `integer` | yes | Days in a row with a published post, up to today or yesterday. |
| `leaderboardName` | `string \| null` | yes | The name on the public leaderboard; null when the workspace is not on it. |
| `achievements` | `Achievement[]` | yes |  |
| `achievements[].id` | `string` | yes |  |
| `achievements[].name` | `string` | yes |  |
| `achievements[].description` | `string` | yes |  |
| `achievements[].category` | `string` | yes |  |
| `achievements[].rarity` | `"common" \| "rare" \| "epic" \| "legendary"` | yes |  |
| `achievements[].xp` | `integer` | yes |  |
| `achievements[].unlocked` | `boolean` | yes |  |
| `achievements[].unlockedAt` | `string \| null` | yes | When Flung first saw it earned. |
| `achievements[].progress` | `object` | yes |  |
| `achievements[].progress.current` | `integer` | yes |  |
| `achievements[].progress.target` | `integer` | yes |  |

## See also

| Doc | Why |
|---|---|
| [API reference](https://docs.flung.dev/reference/api.md) | Every endpoint |
| [Schemas](https://docs.flung.dev/reference/api/schemas.md) | Every request and response type |
| [Errors](https://docs.flung.dev/reference/api/errors.md) | Every error code and what to do about it |
