Experience
Join the leaderboard
Lists the workspace under name, which every Flung customer can see.
PUT
/v1/leaderboard/entryTL;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. |
| 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. |
What it does
Lists the workspace under name, which every Flung customer can see. Its XP and level are shown; nothing else.
Example
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"}'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',})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 |
| 401 | Missing, unknown, revoked or expired API key. | Error |
| 422 | The request failed validation. | Error |
| 429 | Too many requests for this credential; wait for retry-after seconds. | Error |
Response body
A 200 answer has the type 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 | Every endpoint |
| Schemas | Every request and response type |
| Errors | Every error code and what to do about it |