FlagForge supports two types of badges: system badges earned automatically by hitting solve milestones, and custom badges assigned manually by admins. The badges API lets you retrieve profile badges as embeddable images and — for admins — manage badge templates and assignments.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/flagForgeCTF/flagForge/llms.txt
Use this file to discover all available pages before exploring further.
GET /api/badge/[username]/svg
Generate and return a player’s profile badge as an SVG image. No authentication is required. The badge displays the player’s name, level, rank, score, solved challenge count, and avatar. Badge color is determined by the player’s total score.Path parameters
The player’s display name. Hyphens are treated as spaces during the lookup.
Response
Returns animage/svg+xml response. The image is cached for 5 minutes (Cache-Control: public, max-age=300).
Badge color thresholds
| Score | Color |
|---|---|
| 3000+ | Yellow (#EAB308) — Flag Conqueror |
| 2000 – 2999 | Red (#DC2626) — Forger |
| 1500 – 1999 | Orange (#EA580C) — Cipher Hunter |
| 1000 – 1499 | Purple (#7C3AED) — Hacker |
| 500 – 999 | Green (#059669) — Codebreaker |
| 200 – 499 | Blue (#2563EB) — Scout |
| 0 – 199 | Gray (#6B7280) — Newbie |
Example
GET /api/badge/[username]/png
Identical to the SVG endpoint but returns aimage/svg+xml response rendered as a PNG-compatible SVG. Use this endpoint in contexts where SVG embedding is not supported.
Path parameters
The player’s display name.
Example
POST /api/admin/assign-badge
Assign a badge to a user. Requires theAdmin role. The badge is recorded as an AssignedBadge document and added to the user’s customBadges array so it appears on their profile immediately.
Request body
The endpoint accepts two formats. You can send the badge fields directly at the top level, or nest them under abadge object.
Direct format:
The MongoDB
_id of the user receiving the badge.A string identifier for the badge. For template badges, this is typically the badge name.
Badge type:
template for a predefined badge, or custom for a badge image uploaded via the badge images endpoint.The name or email of the admin performing the assignment.
Optional reason for the assignment, stored on the badge record.
The MongoDB
_id of the user receiving the badge.Badge details nested under a
badge key.Response fields
Success (201 Created):
trueConfirmation message, e.g.
"Badge \"CTF Champion\" assigned successfully".MongoDB
_id of the new AssignedBadge document.Summary of the assigned badge:
id, name, and type.Error responses
| Status | Condition |
|---|---|
400 Bad Request | Missing or invalid userId or badgeId. |
401 Unauthorized | Not signed in. |
403 Forbidden | Signed in but not an Admin. |
409 Conflict | The badge is already assigned to this user. |
Example
GET /api/admin/assign-badge
List badge assignments. Requires theAdmin role. Returns all active assignments, or those for a specific user when userId is provided.
Query parameters
Filter assignments to a specific user by their MongoDB
_id. Omit to return all active assignments.Response fields
true on success.Array of active badge assignment records.
Total number of assignments returned.
Example
DELETE /api/admin/assign-badge
Remove a badge assignment. The assignment is soft-deleted (markedisActive: false) and the badge is removed from the user’s customBadges array. Requires the Admin role.
Query parameters
The
_id of the AssignedBadge document to remove.The user’s
_id. Required when id is not provided.The badge identifier. Required when
id is not provided.Provide either
id alone, or both userId and badgeId together. The request returns 400 Bad Request if neither combination is supplied.