API Documentation

2FA

2FA API Documentation

This API allows users to manage their two-factor authentication (2FA) settings.

Endpoints

POST /api/2FA

This endpoint handles the generation, verification, and disabling of 2FA for users.

Request Body

{
    "action": "string", // Can be "generate", "verify", or "disable"
    "otp": "string"     // Required for "verify" and "disable" actions
}
    

Parameters

Responses

Success Responses

HTTP 200 OK
{
    "qrCode": "string",  // Base64 encoded QR code for "generate" action
    "setupKey": "string" // The generated secret key for "generate" action
}

HTTP 200 OK
{
    "success": true      // Indicates successful verification or disabling of 2FA
}
    

Error Responses

HTTP 400 Bad Request
{
    "error": "No secret found" // Returned if no secret exists for the user
}

HTTP 400 Bad Request
{
    "error": "Invalid OTP" // Returned if the provided OTP is invalid
}

HTTP 400 Bad Request
{
    "error": "Unknown action" // Returned if the action is not recognized
}

HTTP 500 Internal Server Error
{
    "error": "Internal Server Error" // Returned for unexpected errors
}
    

Examples

Generate 2FA Secret

POST /api/2FA
{
    "action": "generate"
}
    

Verify OTP

POST /api/2FA
{
    "action": "verify",
    "otp": "123456" // Replace with actual OTP
}
    

Disable 2FA

POST /api/2FA
{
    "action": "disable",
    "otp": "123456" // Replace with actual OTP
}
    

admin/categoriesx

This API provides endpoints for managing server categories.


Endpoints

GET /api/categories

Fetches all server categories along with their associated servers.

Response


{
    "id": number,
    "name": string,
    "servers": [
        {
            "server_id": number,
            "server_name": string,
            "order": number,
            "categoryId": number,
            "image_path": string
        }
    ]
}
        

Example Request


GET /api/categories HTTP/1.1
Host: your-domain.com
        

POST /api/categories

Creates a new server category.

Request Body


{
    "name": "New Category",
    "order": 1
}
        

Response


{
    "success": true,
    "category": {
        "id": number,
        "name": string,
        "order": number
    }
}
        

Error Responses


{
    "error": "Unauthorized"
}
        

Example Request


POST /api/categories HTTP/1.1
Host: your-domain.com
Content-Type: application/json

{
    "name": "New Category",
    "order": 1
}
        

PUT /api/categories

Updates an existing server category.

Request Body


{
    "id": 1,
    "name": "Updated Category",
    "botToken": "optional-bot-token"
}
        

Response


{
    "success": true,
    "category": {
        "id": number,
        "name": string,
        "botToken": string
    }
}
        

Error Responses


{
    "error": "Unauthorized"
}
{
    "error": "Category name is required"
}
        

Example Request


PUT /api/categories HTTP/1.1
Host: your-domain.com
Content-Type: application/json

{
    "id": 1,
    "name": "Updated Category"
}
        

Error Codes


Authentication

All endpoints require authentication. The user must have the servers.manage permission to create or update categories.

admin/categories/reorder

Reorder Server Categories

POST /api/servers/reorder

This endpoint allows authorized users to reorder server categories.

Request

Method: POST

URL: /api/servers/reorder

Headers

Body Parameters

{
    "newOrder": [
        {
            "id": 1,
            "order": 2
        },
        {
            "id": 2,
            "order": 1
        }
    ]
}
    

The newOrder array contains objects with the id of the category and its new order.

Responses

Success Response

HTTP/1.1 200 OK
{
    "success": true
}
    

Error Responses

Example Request

POST /api/servers/reorder
Content-Type: application/json
Authorization: Bearer {token}

{
    "newOrder": [
        {
            "id": 1,
            "order": 2
        },
        {
            "id": 2,
            "order": 1
        }
    ]
}
    

Example Success Response

HTTP/1.1 200 OK
{
    "success": true
}
    

Example Error Response

HTTP/1.1 401 Unauthorized
{
    "error": "Unauthorized"
}
    

admin/categories/[id]

API Documentation

DELETE /api/server-category/:id

This endpoint allows you to delete a server category by its ID.

HTTP Method

DELETE

Parameters

Parameter Description Type Required
id The unique identifier of the server category to delete. string Yes

Request Example

DELETE /api/server-category/1

Responses

Success Response

HTTP Status: 200 OK

{
    "success": true
}

Error Responses

Unauthorized

HTTP Status: 401 Unauthorized

{
    "error": "Unauthorized"
}

This error occurs if the user is not authenticated or lacks the necessary permissions to manage server categories.

Server Error

HTTP Status: 500 Internal Server Error

{
    "error": "Failed to delete category"
}

This error indicates that an unexpected error occurred while attempting to delete the category.

Notes

admin/clans


Endpoints

POST /api/clans

Create or Update Clans and Members

This endpoint allows you to create or update clans and their members in the database.

Authorization

Requires a Bearer token in the Authorization header.

Request Body

{
  "clanId": {
    "ClanID": "string",
    "ClanName": "string | null",
    "Members": {
      "playerId": {
        "PlayerID": "string",
        "PlayerName": "string",
        "CollectedDogTags": "number"
      }
    }
  }
}
            

Responses

Success (200)

{
  "success": true,
  "data": "array of created/updated clans and members"
}
            

Error (401)

{
  "success": false,
  "error": "Unauthorized"
}
            

Error (400)

{
  "success": false,
  "error": "Invalid request body"
}
            

Error (500)

{
  "success": false,
  "error": "Internal Server Error"
}
            
GET /api/clans

Retrieve All Clans

This endpoint retrieves a list of all clans in the database, ordered by the total collected dog tags.

Responses

Success (200)

{
  "data": [
    {
      "ClanID": "string",
      "ClanName": "string | null",
      "totalCollectedDogTags": "number"
    }
  ]
}
            

Error (500)

{
  "success": false,
  "error": "Internal Server Error"
}
            

Error Codes

Status Code Description
401 Unauthorized access due to missing or invalid token.
400 Invalid request body format.
500 Internal server error, something went wrong on the server side.

admin/discord

Discord Guild API Documentation

This API allows you to manage Discord guilds in your application.

Endpoints

GET /api/guilds

Get All Discord Guilds

Retrieves a list of all Discord guilds.

Response

{
    "guilds": [
        {
            "id": "string",
            "name": "string"
        },
        ...
    ]
}

Example Request

GET /api/guilds

Example Response

HTTP/1.1 200 OK
Content-Type: application/json

[
    {
        "id": "123",
        "name": "Example Guild"
    }
]

Error Responses

HTTP/1.1 500 Internal Server Error
Content-Type: application/json

{
    "error": "Internal Server Error"
}
POST /api/guilds

Create a New Discord Guild

Creates a new Discord guild.

Request Body

{
    "id": "string", // Required: Unique identifier for the guild
    "name": "string" // Required: Name of the guild
}

Response

{
    "success": true
}

Example Request

POST /api/guilds
Content-Type: application/json

{
    "id": "123",
    "name": "New Guild"
}

Example Response

HTTP/1.1 201 Created
Content-Type: application/json

{
    "success": true
}

Error Responses

HTTP/1.1 400 Bad Request
Content-Type: application/json

{
    "error": "Missing required fields"
}
HTTP/1.1 500 Internal Server Error
Content-Type: application/json

{
    "error": "Internal Server Error"
}
DELETE /api/guilds

Remove a Discord Guild

Deletes a Discord guild by its ID.

Query Parameters

id: string // Required: Unique identifier of the guild to be deleted

Response

{
    "message": "Discord guild deleted successfully"
}

Example Request

DELETE /api/guilds?id=123

Example Response

HTTP/1.1 200 OK
Content-Type: application/json

{
    "message": "Discord guild deleted successfully"
}

Error Responses

HTTP/1.1 400 Bad Request
Content-Type: application/json

{
    "error": "Missing guild ID"
}
HTTP/1.1 500 Internal Server Error
Content-Type: application/json

{
    "error": "Internal Server Error"
}

admin/discord/roles

Discord Guilds API

This API allows you to fetch roles for a specific Discord guild.


Endpoints

GET /api/guilds

Retrieve all roles for a specified Discord guild.

Request Parameters

Request Example

GET /api/guilds?guildId=123456789012345678

Response

On success, the API returns a JSON object containing the guild ID and an array of roles.

Successful Response Example

{
    "guildId": "123456789012345678",
    "roles": [
        { "id": "987654321098765432", "name": "Admin" },
        { "id": "876543210987654321", "name": "Moderator" }
    ]
}

Error Responses


Authentication

This endpoint requires authentication via a Discord Bot Token. Ensure that the token is included in the environment variables as DISCORD_BOT_TOKEN.

Notes

Roles returned will exclude the default '@everyone' role.

admin/giveaways

Giveaway API Documentation

Endpoints

  • GET /api/giveaways

    Fetches a list of all giveaways.

  • POST /api/giveaways

    Creates a new giveaway.

GET /api/giveaways

Request

No parameters required.

Response

On success, returns a JSON array of giveaways:

{
    "id": 1,
    "title": "Sample Giveaway",
    "description": "Win amazing prizes!",
    "headerImage": "http://example.com/image.png",
    "enabled": true,
    "startDate": "2023-10-01T00:00:00Z",
    "endDate": "2023-10-31T23:59:59Z",
    "giveawayOptions": [
        {
            "id": 1,
            "prize": "Gift Card",
            "entries": []
        }
    ]
}

Error Responses

  • 500 Internal Server Error: Failed to fetch giveaways.

POST /api/giveaways

Request

Body Parameters

{
    "title": "Sample Giveaway",
    "description": "Win a fantastic prize!",
    "headerImage": "http://example.com/image.png",
    "enabled": true,
    "startDate": "2023-10-01T00:00:00Z",
    "endDate": "2023-10-31T23:59:59Z",
    "giveawayOptions": [
        {
            "prize": "Gift Card"
        }
    ]
}

Response

On success, returns the created giveaway object:

{
    "id": 2,
    "title": "Sample Giveaway",
    "description": "Win a fantastic prize!",
    "headerImage": "http://example.com/image.png",
    "enabled": true,
    "startDate": "2023-10-01T00:00:00Z",
    "endDate": "2023-10-31T23:59:59Z",
    "giveawayOptions": [
        {
            "id": 1,
            "prize": "Gift Card"
        }
    ]
}

Error Responses

  • 400 Bad Request: Invalid request body or validation errors.
  • 401 Unauthorized: User is not authenticated or lacks permission.
  • 500 Internal Server Error: Failed to create giveaway.

Validation Errors

When validation fails, the API returns an array of error messages. Example:

[
    {
        "message": "Title is required",
        "path": ["title"]
    },
    {
        "message": "At least one giveaway option is required",
        "path": ["giveawayOptions"]
    }
]

Permissions

The POST /api/giveaways endpoint requires the user to have the giveaways.manage permission.

admin/giveaways/enter

Giveaway Entry API

This API endpoint allows users to enter a giveaway by submitting a giveaway ID.

POST /api/admin/giveaways/enter

Enter a giveaway by providing the giveaway ID in the request body.

Request


POST /api/admin/giveaways/enter
Content-Type: application/json
    

Request Body


{
    "giveawayId": "string" // The ID of the giveaway to enter
}
    

Authentication

This endpoint requires the user to be authenticated. If the user is not logged in, the API will return a 401 Unauthorized status.

Responses

Successful Response


Status: 200 OK
{
    "message": "Successfully entered the giveaway!"
}
    

Error Responses

Example Request


POST /api/admin/giveaways/enter
Content-Type: application/json

{
    "giveawayId": "12345"
}
    

Example Successful Response


Status: 200 OK
{
    "message": "Successfully entered the giveaway!"
}
    

Example Error Response


Status: 404 Not Found
{
    "message": "Giveaway not found."
}
    

admin/giveaways/winner

Pick Winners API Documentation

This API endpoint allows you to pick winners for a giveaway based on the provided giveaway ID.

Endpoint

POST /api/pick-winners

Authentication

This endpoint requires Bearer Token authentication. Include the token in the Authorization header of your request.

Authorization: Bearer <API_BEARER_TOKEN>

Request Body

The request body must be in JSON format and include the following parameter:

Example Request

{
    "giveawayId": "12345"
}

Responses

Success Responses

Error Responses

Error Codes Summary

HTTP Status Code Description
200 Winners have already been picked or giveaway not ended yet.
201 Winners successfully picked.
400 Bad Request: giveawayId is required.
401 Unauthorized: Invalid or missing Authorization header.
500 An unexpected error occurred.

admin/giveaways/[id]

Giveaway API Documentation

Manage giveaways with ease using our comprehensive API.


Endpoints

GET /api/admin/giveaways/{id}

Fetch a specific giveaway by its ID.

Parameters

Responses

Example Request

GET /api/admin/giveaways/123e4567-e89b-12d3-a456-426614174000

Example Response

{
    "id": "123e4567-e89b-12d3-a456-426614174000",
    "title": "Summer Giveaway",
    "description": "Win exciting prizes!",
    "headerImage": "http://example.com/image.png",
    "enabled": true,
    "startDate": "2023-06-01T00:00:00Z",
    "endDate": "2023-06-30T23:59:59Z",
    "giveawayOptions": [...],
    "winnerIds": ["user1", "user2"]
}

PUT /api/admin/giveaways/{id}

Update an existing giveaway.

Parameters

Request Body

{
    "title": "Updated Title",
    "description": "Updated description.",
    "headerImage": "http://example.com/new-image.png",
    "enabled": true,
    "startDate": "2023-07-01T00:00:00Z",
    "endDate": "2023-07-31T23:59:59Z",
    "giveawayOptions": [
        {"id": "existing-option-id", "prize": "New Prize"},
        {"prize": "Another New Prize"}
    ]
}

Responses

DELETE /api/admin/giveaways/{id}

Delete a specific giveaway by its ID.

Parameters

Responses

Example Request

DELETE /api/admin/giveaways/123e4567-e89b-12d3-a456-426614174000

Example Response

{
    "message": "Giveaway deleted successfully"
}

Error Codes

admin/leaderboard-settings

Leaderboard Settings API

Manage leaderboard settings for your application.

Endpoints

GET /api/admin/leaderboard-settings

Description

Fetches the current leaderboard tabs and their columns.

Authentication

This endpoint requires authentication. Only users with the leaderboard.manage permission can access it.

Responses

Success Response

HTTP/1.1 200 OK
[
  {
    "id": "string",
    "tabKey": "string",
    "tabLabel": "string",
    "columns": [
      {
        "columnKey": "string",
        "columnLabel": "string",
        "icon": "string|null"
      }
    ]
  }
]

Error Responses

HTTP/1.1 401 Unauthorized
{ "error": "Unauthorized" }

HTTP/1.1 500 Internal Server Error
{ "error": "Failed to fetch leaderboard settings" }

POST /api/admin/leaderboard-settings

Description

Updates the leaderboard tabs and columns. Can also delete specified tabs and columns.

Request Body

{
  "tabs": [
    {
      "id": "string",
      "tabKey": "string",
      "tabLabel": "string",
      "columns": [
        {
          "columnKey": "string",
          "columnLabel": "string",
          "icon": "string|null"
        }
      ]
    }
  ],
  "deletedTabKeys": ["string"],
  "deletedColumnKeys": ["string"]
}

Authentication

This endpoint requires authentication. Only users with the leaderboard.manage permission can access it.

Responses

Success Response

HTTP/1.1 200 OK
[
  {
    "id": "string",
    "tabKey": "string",
    "tabLabel": "string",
    "columns": [
      {
        "columnKey": "string",
        "columnLabel": "string",
        "icon": "string|null"
      }
    ]
  }
]

Error Responses

HTTP/1.1 401 Unauthorized
{ "error": "Unauthorized" }

HTTP/1.1 400 Bad Request
{ "error": "Invalid input: tabs must be an array" }

HTTP/1.1 500 Internal Server Error
{ "error": "Failed to update leaderboard settings" }

admin/logs

Admin Logs API Documentation

This API provides access to the admin logs stored in the database. It allows filtering logs based on various parameters.

Endpoints

GET /api/admin-logs

Fetches admin logs based on the provided query parameters.

Query Parameters

Parameter Type Description Required Default
action string The action to filter logs by. No N/A
userId string The ID of the user associated with the logs. No N/A
targetId string The ID of the target associated with the logs. No N/A
roleId string The ID of the role associated with the logs. No N/A
serverId string The ID of the server associated with the logs. No N/A
startDate string | number The starting date or timestamp for filtering logs. No N/A
endDate string | number The ending date or timestamp for filtering logs. No N/A
page string The page number for pagination. No 1
limit string The number of logs to return per page. No 10
minimize enum Whether to return minimized log details. No N/A
type enum The type of log to filter by (oxide or discord). No N/A

Responses

Success Response


HTTP/1.1 200 OK
Content-Type: application/json

{
    "logs": [
        {
            "action": "string",
            "timestamp": "string",
            "details": { ... }
        }
    ],
    "pagination": {
        "currentPage": 1,
        "totalPages": 10,
        "totalItems": 100
    }
}
    

Error Responses

400 Bad Request


HTTP/1.1 400 Bad Request
Content-Type: application/json

{
    "error": "startDate is required when minimize is true"
}
    

500 Internal Server Error


HTTP/1.1 500 Internal Server Error
Content-Type: application/json

{
    "error": "Internal Server Error"
}
    

Example Request

admin/map-voting

Map Voting API Documentation

This API allows for the creation, retrieval, and updating of map votes for servers.


Endpoints

POST /api/map-vote

Creates a new map vote.

Request Body

{
    "server": "string", // Required: Server ID
    "vote_start": "string", // Required: Start date in ISO 8601 format
    "vote_end": "string", // Required: End date in ISO 8601 format
    "map_start": "string", // Required: Date when the map starts in ISO 8601 format
    "map_options": [
        {
            "value": "string" // Required: Map option value
        },
        ...
    ] // At least two map options required
}
        

Responses

  • 201 Created: Map vote created successfully.
  • 401 Unauthorized: User does not have permission.
  • 400 Bad Request: Validation failed.
  • 404 Not Found: Map not found.
  • 409 Conflict: Map is still generating.
  • 500 Internal Server Error: An error occurred on the server.

Example

POST /api/map-vote
{
    "server": "12345",
    "vote_start": "2023-10-01T10:00:00Z",
    "vote_end": "2023-10-02T10:00:00Z",
    "map_start": "2023-10-01T10:00:00Z",
    "map_options": [
        {"value": "https://rustmaps.com/map1"},
        {"value": "https://rustmaps.com/map2"}
    ]
}
        

GET /api/map-vote

Retrieves map votes based on query parameters.

Query Parameters

  • serverId (optional): Filter by server ID.
  • status (optional): Filter by vote status ('active' or 'completed').

Responses

  • 200 OK: Returns a list of map votes.
  • 401 Unauthorized: User does not have permission.
  • 500 Internal Server Error: An error occurred on the server.

Example

GET /api/map-vote?serverId=12345&status=active
        

PUT /api/map-vote

Updates an existing map vote.

Request Body

{
    "id": "string", // Required: Map vote ID
    "server": "string", // Required: Server ID
    "vote_start": "string", // Required: Start date in ISO 8601 format
    "vote_end": "string", // Required: End date in ISO 8601 format
    "map_start": "string", // Required: Date when the map starts in ISO 8601 format
    "enabled": true, // Required: Status of the map vote
    "map_options": [
        {
            "value": "string" // Required: Map option value
        },
        ...
    ] // At least two map options required
}
        

admin/navigation

Navigation Items API

This API allows you to manage navigation items for your application.


Endpoints

GET /api/navigation-items

Retrieve a list of navigation items.

Response


[
    {
        "label": "Home",
        "url": "/home",
        "order": 1
    },
    {
        "label": "About",
        "url": "/about",
        "order": 2
    }
]
    

POST /api/navigation-items

Create a new navigation item.

Request Body


{
    "label": "Contact",
    "url": "/contact",
    "order": 3
}
    

Response


{
    "label": "Contact",
    "url": "/contact",
    "order": 3,
    "id": "abc123"
}
    

Error Responses

  • 401 Unauthorized: User does not have permission to manage settings.

PUT /api/navigation-items

Update an existing navigation item.

Request Body


{
    "id": "abc123",
    "label": "Updated Contact",
    "url": "/contact-updated",
    "order": 4
}
    

Response


{
    "id": "abc123",
    "label": "Updated Contact",
    "url": "/contact-updated",
    "order": 4
}
    

Error Responses

  • 401 Unauthorized: User does not have permission to manage settings.

DELETE /api/navigation-items

Delete a navigation item.

Request Body


{
    "id": "abc123"
}
    

Response


{
    "success": true
}
    

Error Responses

  • 401 Unauthorized: User does not have permission to manage settings.
  • 400 Bad Request: Missing id in the request body.

Schema Validation

The following schema is used to validate the request body for POST and PUT requests:


{
    "label": "string (min 1 character)",
    "url": "string",
    "order": "integer (min 0)"
}
    

admin/notes/[id]

Admin Notes API

This API allows admins to manage notes associated with users.

Endpoints

GET /api/admin/notes/{id}

Fetches the notes associated with a user by their ID.

Parameters

  • id (path parameter): The ID of the user whose notes are to be fetched.

Response

{
    "id": "string",
    "roles": [
        {
            "id": "string",
            "name": "string",
            "order": 1
        }
    ],
    "Note": [
        {
            "id": "string",
            "content": "string",
            "role": {
                "id": "string",
                "name": "string",
                "order": 1
            },
            "creator": {
                "id": "string",
                "name": "string"
            }
        }
    ]
}
        

Error Codes

  • 401 Unauthorized: User is not authenticated.
  • 404 Not Found: User not found.
  • 500 Internal Server Error: An error occurred while fetching the user.

Example Request

GET /api/admin/notes/12345

Example Response

{
    "id": "12345",
    "roles": [
        {
            "id": "admin",
            "name": "Administrator",
            "order": 1
        }
    ],
    "Note": [
        {
            "id": "note1",
            "content": "This is a note.",
            "role": {
                "id": "role1",
                "name": "Editor",
                "order": 2
            },
            "creator": {
                "id": "creator1",
                "name": "John Doe"
            }
        }
    ]
}
        

POST /api/admin/notes/{id}

Creates a new note for a user by their ID.

Parameters

  • id (path parameter): The ID of the user for whom the note is being created.

Request Body

{
    "content": "string",
    "roleId": "string"
}
        

Response

{
    "id": "string",
    "content": "string",
    "role": {
        "id": "string",
        "name": "string",
        "order": 1
    },
    "creator": {
        "id": "string",
        "name": "string"
    }
}
        

Error Codes

  • 401 Unauthorized: User is not authenticated.
  • 400 Bad Request: Invalid input (missing content or roleId).
  • 403 Forbidden: User does not have permission to assign this role.
  • 404 Not Found: User not found.
  • 500 Internal Server Error: An error occurred while creating the note.

Example Request

POST /api/admin/notes/12345

admin/page-metadata

This documentation provides details about the API endpoints related to page metadata management.

GET /api/pages

Endpoint Description

Fetches a list of page metadata slugs.

HTTP Method

GET

Authentication

This endpoint requires user authentication. The user must have the seo.manage permission.

Response

Success Response

{
    "slug": "example-page-1"
},
{
    "slug": "example-page-2"
}

Status: 200 OK

Error Responses

{
    "error": "Unauthorized"
}

Status: 401 Unauthorized

{
    "error": "Internal Server Error"
}

Status: 500 Internal Server Error

POST /api/pages

Endpoint Description

Creates a new page metadata entry.

HTTP Method

POST

Request Body

The request should contain a JSON object with the page metadata details. Example:

{
    "slug": "new-page"
}

Authentication

This endpoint requires user authentication. The user must have the seo.manage permission.

Response

Success Response

{
    "slug": "new-page",
    "createdAt": "2023-10-01T00:00:00.000Z",
    "updatedAt": "2023-10-01T00:00:00.000Z"
}

Status: 201 Created

Error Responses

{
    "error": "Unauthorized"
}

Status: 401 Unauthorized

{
    "error": "Internal Server Error"
}

Status: 500 Internal Server Error

admin/page-metadata/[slug]

This API allows for the management of page metadata. Below are the available endpoints.

GET /api/pages/{slug}

Summary

Fetches the metadata for a specific page identified by the slug.

Parameters

  • slug (path parameter): The unique identifier for the page.

Responses

200 OK

{
    "slug": "example-page",
    "title": "Example Page",
    "description": "This is an example page."
}

401 Unauthorized

{
    "error": "Unauthorized"
}

404 Not Found

{
    "error": "Page not found"
}

500 Internal Server Error

{
    "error": "Internal Server Error"
}

PUT /api/pages/{slug}

Summary

Updates the metadata for a specific page identified by the slug.

Parameters

  • slug (path parameter): The unique identifier for the page.

Request Body

{
    "title": "Updated Page Title",
    "description": "Updated description for the page."
}

Responses

200 OK

{
    "slug": "example-page",
    "title": "Updated Page Title",
    "description": "Updated description for the page."
}

401 Unauthorized

{
    "error": "Unauthorized"
}

500 Internal Server Error

{
    "error": "Internal Server Error"
}

DELETE /api/pages/{slug}

Summary

Deletes the metadata for a specific page identified by the slug.

Parameters

  • slug (path parameter): The unique identifier for the page.

Responses

204 No Content

No content returned on successful deletion.

401 Unauthorized

{
    "error": "Unauthorized"
}

500 Internal Server Error

{
    "error": "Internal Server Error"
}

admin/redirects

Redirects API Documentation

This API allows for the management of URL redirects. It supports creating, updating, retrieving, and deleting redirects.


Endpoints

GET /api/redirects

Retrieves a list of all redirects.

Response

{
    "source": "string",
    "destination": "string",
    "permanent": boolean,
    "createdAt": "string"
}

HTTP Status Codes

  • 200 OK - Returns an array of redirects.
  • 401 Unauthorized - User does not have permission to access this resource.

Example

GET /api/redirects

PUT /api/redirects

Creates a new redirect or updates an existing one.

Request Body

{
    "source": "string",
    "destination": "string",
    "permanent": boolean
}

Response

{
    "source": "string",
    "destination": "string",
    "permanent": boolean,
    "createdAt": "string"
}

HTTP Status Codes

  • 200 OK - Redirect created or updated successfully.
  • 401 Unauthorized - User does not have permission to access this resource.
  • 500 Internal Server Error - Failed to create/update redirect.

Example

PUT /api/redirects
Request Body:
{
    "source": "/old-path",
    "destination": "/new-path",
    "permanent": true
}

DELETE /api/redirects

Deletes a redirect by ID.

Query Parameters

  • id (required) - The ID of the redirect to delete.

Response

{
    "success": true
}

HTTP Status Codes

  • 200 OK - Redirect deleted successfully.
  • 401 Unauthorized - User does not have permission to access this resource.
  • 400 Bad Request - ID is required.

Example

DELETE /api/redirects?id=1

Authentication

This API requires authentication. Ensure that the user has the settings.manage permission to perform any operations.

admin/roles


Roles API

This API endpoint allows you to retrieve role information from the database.

GET /api/roles

Fetches a list of roles based on optional query parameters.

Query Parameters

Parameter Type Description
serverId string Filters roles by server ID. If provided, it also includes global roles.
discordId string Filters roles by Discord ID, returning roles associated with the specified Discord guild.

Expected Responses

Success Response

{
    "roles": [
        {
            "id": "roleId",
            "name": "Role Name",
            "color": "#FFFFFF",
            "order": 1,
            "serverId": "serverId",
            "oxideGroupName": "Oxide Group Name",
            "assignOnBoost": true,
            "assignOnVerification": false,
            "assignOnGroupJoin": true,
            "discordAssociations": [
                {
                    "discordGuild": "discordGuildId",
                    "discordRole": "discordRoleId"
                }
            ]
        }
    ]
}
    

Error Response

{
    "error": "Internal Server Error"
}
    

Error Codes

Status Code Description
500 An internal server error occurred while processing the request.

Examples

Example Request

GET /api/roles?serverId=myServerId
    

Example Response

{
    "roles": [
        {
            "id": "1",
            "name": "Admin",
            "color": "#FF0000",
            "order": 1,
            "serverId": "myServerId",
            "oxideGroupName": "Admin Group",
            "assignOnBoost": true,
            "assignOnVerification": false,
            "assignOnGroupJoin": true,
            "discordAssociations": [
                {
                    "discordGuild": "123456789",
                    "discordRole": "987654321"
                }
            ]
        }
    ]
}
    

admin/roles/reorderx

Reorder Roles API

POST /api/roles/reorder

This endpoint allows authorized users to reorder roles based on the provided order data.

Request

This endpoint accepts a JSON payload with the new order of roles.

Headers

  • Content-Type: application/json
  • Authorization: Bearer token (if applicable)

Body

{
    "newOrder": [
        {
            "id": "roleId1",
            "order": 1
        },
        {
            "id": "roleId2",
            "order": 2
        }
    ]
}
    

Responses

Success Response

On successful reordering of roles, the API will respond with:

HTTP/1.1 200 OK
{
    "success": true
}
    

Error Responses

  • 401 Unauthorized
    {
        "error": "Unauthorized"
    }
                
  • 400 Bad Request
    {
        "error": "Invalid data format"
    }
                
  • 500 Internal Server Error
    {
        "error": "Failed to reorder roles"
    }
                

Permissions

Users must have the settings.roles.manage permission to access this endpoint.

Example Usage

fetch('/api/roles/reorder', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
        'Authorization': 'Bearer YOUR_TOKEN'
    },
    body: JSON.stringify({
        newOrder: [
            { id: "roleId1", order: 1 },
            { id: "roleId2", order: 2 }
        ]
    })
})
.then(response => response.json())
.then(data => console.log(data));
    

admin/roles/[id]

Role Management API

This API allows you to manage roles including retrieval, updating, and deletion of roles.

Endpoints

GET /api/roles/{id}

Retrieve a role by ID or oxide group name.

Parameters

  • id (path parameter): The ID or oxide group name of the role.

Responses

  • 200 OK: Returns the role details.
  • 204 No Content: Role not found.
  • 500 Internal Server Error: An error occurred while fetching the role.

Example Request

GET /api/roles/123

Example Response

{
    "role": {
        "id": "123",
        "name": "Admin",
        "serverId": "server_1",
        "color": "#FF0000",
        "oxideGroupName": "oxide_admin",
        "assignOnVerification": true,
        "assignOnBoost": false,
        "assignOnGroupJoin": true,
        "discordAssociations": [
            {
                "discordGuild": "guild_1",
                "discordRole": "role_1"
            }
        ]
    }
}

PUT /api/roles/{id}

Update an existing role.

Parameters

  • id (path parameter): The ID or oxide group name of the role.

Request Body

{
    "name": "New Role Name",
    "serverId": "new_server_id",
    "color": "#00FF00",
    "oxideGroupName": "new_oxide_group",
    "assignOnVerification": false,
    "assignOnBoost": true,
    "assignOnGroupJoin": false,
    "discordAssociations": [
        {
            "discordGuild": "new_guild",
            "discordRole": "new_role"
        }
    ]
}

Responses

  • 200 OK: Returns the updated role details.
  • 204 No Content: Role not found.
  • 500 Internal Server Error: An error occurred while updating the role.

Example Request

PUT /api/roles/123

Example Response

{
    "role": {
        "id": "123",
        "name": "Updated Role",
        "serverId": "server_1",
        "color": "#00FF00",
        "oxideGroupName": "oxide_updated",
        "assignOnVerification": false,
        "assignOnBoost": true,
        "assignOnGroupJoin": false,
        "discordAssociations": [
            {
                "discordGuild": "new_guild",
                "discordRole": "new_role"
            }
        ]
    }
}

DELETE /api/roles/{id}

Delete a role by ID or oxide group name.

Parameters

  • id (path parameter): The ID or oxide group name of the role.

Responses

  • 200 OK: Role deleted successfully.
  • 204 No Content: Role not found.
  • 500 Internal Server Error: An error occurred while deleting the role.

Example Request

DELETE /api/roles/123

Example Response

admin/servers

Server Management API

This API allows for the management of servers including creation, updating, and deletion.


Endpoints

POST /api/servers

Create a new server.

Request Body

{
    "id": "string", // Unique identifier for the server
    "name": "string", // Name of the server
    "order": "integer", // Order of the server
    "image_path": "string", // Path to the server image
    "server_address": "string", // Address of the server
    "discordBotToken": "string", // Discord bot token (optional)
    "categoryId": "string" // ID of the category to connect
}

Responses

  • 201 Created: Returns the created server object.
  • 401 Unauthorized: If the user is not authorized.
  • 500 Internal Server Error: If the server fails to create the server.

Example

POST /api/servers
{
    "id": "srv123",
    "name": "My Server",
    "order": 1,
    "image_path": "/images/server.png",
    "server_address": "192.168.1.1",
    "discordBotToken": "xyz123",
    "categoryId": "cat456"
}

PUT /api/servers

Update an existing server.

Request Body

{
    "oldServerId": "string", // The ID of the server to update
    "serverId": "string", // New unique identifier for the server
    "name": "string", // Updated name of the server
    "imagePath": "string", // Updated path to the server image
    "serverAddress": "string", // Updated address of the server
    "enabled": "boolean", // Whether the server is enabled
    "discordBotToken": "string" // Updated Discord bot token (optional)
}

Responses

  • 200 OK: Returns the updated server object.
  • 401 Unauthorized: If the user is not authorized.
  • 500 Internal Server Error: If the server fails to update the server.

Example

PUT /api/servers
{
    "oldServerId": "srv123",
    "serverId": "srv123-updated",
    "name": "My Updated Server",
    "imagePath": "/images/server-updated.png",
    "serverAddress": "192.168.1.2",
    "enabled": true,
    "discordBotToken": "xyz456"
}

DELETE /api/servers

Delete a server.

Query Parameters

id=string // The ID of the server to delete

Responses

  • 204 No Content: If the server is successfully deleted.
  • 400 Bad Request: If the server ID is not provided.
  • 401 Unauthorized: If the user is not authorized.
  • 500 Internal Server Error: If the server fails to delete the server.

Example

DELETE /api/servers?id=srv123

Error Codes

  • 401 Unauthorized: The user does not have permission to perform this action.
  • <

admin/servers/reorder

Reorder Servers

This endpoint allows authorized users to reorder servers within a specific category.

Endpoint

POST /api/servers/reorder

HTTP Method

POST

Request Parameters

Parameter Type Description Required
categoryId String The ID of the category the servers belong to. Yes
serverIds Array of Strings An array of server IDs in the order they should be arranged. Yes

Request Example

{
    "categoryId": "123456",
    "serverIds": ["server1", "server2", "server3"]
}
    

Responses

Success Response

On success, the API will return a JSON object indicating the operation was successful.

HTTP/1.1 200 OK
{
    "success": true
}
    

Error Responses

Unauthorized

If the user is not authenticated or does not have the required permissions.

HTTP/1.1 401 Unauthorized
{
    "error": "Unauthorized"
}
    

Internal Server Error

If an error occurs during the processing of the request.

HTTP/1.1 500 Internal Server Error
{
    "error": "Failed to reorder servers"
}
    

Error Codes

  • 401: Unauthorized - The user is not authenticated or lacks permissions.
  • 500: Internal Server Error - An unexpected error occurred during processing.

Notes

Ensure that the user has the servers.manage permission to access this endpoint.

admin/settings/discord

Discord Integration API

Manage Discord integration settings for your application.


Endpoints

GET /api/discord-integration

Method: GET

Description: Retrieves the current Discord integration settings.

Authorization

This endpoint requires the user to be authenticated and have the settings.manage permission.

Responses

200 OK

{
    "id": 1,
    "guildId": "123456789012345678",
    "webhookUrl": "https://discord.com/api/webhooks/.../... ",
    "verificationHookColor": "#00FF00",
    "verificationHookEnabled": true,
    "ticketHookUrl": "https://discord.com/api/webhooks/.../... ",
    "ticketHookColor": "#FF0000",
    "ticketHookEnabled": false
}

204 No Content

{
    "error": "Discord integration settings not found"
}

401 Unauthorized

{
    "error": "Unauthorized"
}

500 Internal Server Error

{
    "error": "Failed to fetch Discord integration settings"
}

PUT /api/discord-integration

Method: PUT

Description: Updates the Discord integration settings.

Authorization

This endpoint requires the user to be authenticated and have the settings.manage permission.

Request Body

{
    "guildId": "123456789012345678",
    "webhookUrl": "https://discord.com/api/webhooks/.../... ",
    "verificationHookColor": "#00FF00",
    "verificationHookEnabled": true,
    "ticketHookUrl": "https://discord.com/api/webhooks/.../... ",
    "ticketHookColor": "#FF0000",
    "ticketHookEnabled": false
}

Responses

200 OK

{
    "success": true
}

401 Unauthorized

{
    "error": "Unauthorized"
}

500 Internal Server Error

{
    "error": "Failed to update Discord integration settings"
}

Error Codes

  • 401: Unauthorized - User is not authenticated or does not have the required permissions.
  • 204: No Content - Discord integration settings not found.
  • 500: Internal Server Error - An error occurred while processing the request.

admin/settings/metadata

Site Metadata API

This API provides endpoints to manage site metadata. It supports both retrieval and updating of metadata, with built-in authorization checks.


Endpoints

GET /api/site-metadata

Retrieve the current site metadata.

HTTP Method

GET

Authorization

Requires the user to have the role seo.manage.

Responses

  • 200 OK - Returns the site metadata.
  • 401 Unauthorized - User does not have permission.
  • 404 Not Found - Site metadata not found.
  • 500 Internal Server Error - An error occurred while fetching metadata.

Example Response

{
    "id": 1,
    "title": "My Website",
    "description": "This is my personal website.",
    "keywords": "personal, blog, portfolio"
}
    

POST /api/site-metadata

Update the site metadata.

HTTP Method

POST

Authorization

Requires the user to have the role seo.manage.

Request Body

The request body must be a JSON object containing the metadata fields to update.

Example Request Body

{
    "title": "Updated Website Title",
    "description": "Updated description of my website.",
    "keywords": "updated, keywords, for, seo"
}
    

Responses

  • 200 OK - Returns the updated site metadata.
  • 401 Unauthorized - User does not have permission.
  • 500 Internal Server Error - An error occurred while updating metadata.

Example Response

{
    "id": 1,
    "title": "Updated Website Title",
    "description": "Updated description of my website.",
    "keywords": "updated, keywords, for, seo"
}
    

Error Codes

  • 401 - Unauthorized: The user does not have the required permissions.
  • 404 - Not Found: The requested resource could not be found.
  • 500 - Internal Server Error: An unexpected error occurred on the server.

Ensure that you have the necessary permissions to access these endpoints.

admin/settings/permissions

Update Role Permissions

This endpoint allows you to update the permissions of a specific role in the system.

Endpoint

PUT /api/roles/update

HTTP Method

PUT

Authentication

This endpoint requires authentication. Users must have the settings.roles.manage permission to access this endpoint.

Request Parameters

Request Body

{
    "roleId": "string",         // The ID of the role to be updated
    "permissions": [            // An array of permissions to be assigned to the role
        "string"
    ]
}

Responses

Successful Response

On a successful update, the response will contain the updated role object.

HTTP/1.1 200 OK
{
    "id": "string",            // The ID of the role
    "permissions": "string"    // The updated permissions as a comma-separated string
}

Error Responses

401 Unauthorized

HTTP/1.1 401 Unauthorized
{
    "error": "Unauthorized"
}

Returned when the user is not authenticated or does not have the required permissions.

400 Bad Request

HTTP/1.1 400 Bad Request
{
    "error": "Missing required fields"
}

Returned when the request is missing required fields such as roleId or permissions.

HTTP/1.1 400 Bad Request
{
    "error": "Permissions must be an array"
}

Returned when permissions is not an array.

500 Internal Server Error

HTTP/1.1 500 Internal Server Error
{
    "error": "Failed to update permissions"
}

Returned when there is an error updating the role in the database.

Example Request

PUT /api/roles/update
Content-Type: application/json

{
    "roleId": "12345",
    "permissions": ["read", "write", "delete"]
}

Example Successful Response

HTTP/1.1 200 OK
{
    "id": "12345",
    "permissions": "read,write,delete"
}

admin/settings/roles

Role Management API

This API allows for the management of user roles within the application.

Endpoints

GET /api/roles

Description

This endpoint retrieves a list of roles from the database.

HTTP Method

GET

Authentication

Requires user to have settings.roles.manage permission.

Response

{
    "roles": [
        {
            "name": "Admin",
            "order": 1,
            "permissions": ""
        },
        ...
    ]
}

Error Codes

  • 401 Unauthorized: User does not have permission to access this resource.
  • 500 Internal Server Error: Failed to retrieve roles.
POST /api/roles

Description

This endpoint creates a new role in the database.

HTTP Method

POST

Request Body

{
    "name": "NewRole"
}

Authentication

Requires user to have settings.roles.manage permission.

Response

{
    "success": true
}

Error Codes

  • 401 Unauthorized: User does not have permission to access this resource.
  • 500 Internal Server Error: Failed to create role.
PUT /api/roles

Description

This endpoint updates the permissions of an existing role.

HTTP Method

PUT

Request Body

{
    "role": {
        "name": "ExistingRole"
    },
    "permissions": ["permission1", "permission2"]
}

Authentication

Requires user to have settings.roles.manage permission.

Response

{
    "success": true
}

Error Codes

  • 401 Unauthorized: User does not have permission to access this resource.
  • 500 Internal Server Error: Failed to update role.

admin/site-settings

Update Site Settings

This endpoint allows authorized users to update site settings.

Endpoint

PATCH /api/settings

HTTP Method

PATCH

Authentication

This endpoint requires user authentication. The user must have the role that includes the permission settings.manage.

Request Body

The request body must be a JSON object containing the settings to update. Example:

{
    "settingKey1": "newValue1",
    "settingKey2": "newValue2"
}
    

Responses

Success Response

On a successful update, the API will return the updated settings with a 200 status code.

HTTP/1.1 200 OK
Content-Type: application/json

{
    "id": 1,
    "settingKey1": "newValue1",
    "settingKey2": "newValue2"
}
    

Error Responses

Unauthorized

If the user is not authenticated or does not have the required permissions, the API will return a 401 status code.

HTTP/1.1 401 Unauthorized
Content-Type: application/json

{
    "error": "Unauthorized"
}
    

Internal Server Error

If there is an error while processing the request, the API will return a 500 status code.

HTTP/1.1 500 Internal Server Error
Content-Type: application/json

{
    "error": "Failed to update settings"
}
    

Notes

After a successful update, all paths are revalidated to ensure the latest settings are reflected in the application.

admin/store-sale

Store Sale API Documentation

Endpoints

GET /api/store-sale

Fetches the current store sale details.

Request

Method: GET

Response

{
    "id": 1,
    "enabled": true,
    "title": "Summer Sale",
    "description": "Get up to 50% off!",
    "url": "https://example.com/sale"
}

Errors

  • 500 Internal Server Error: An error occurred while fetching the store sale.

POST /api/store-sale

Updates or creates the store sale details.

Request

Method: POST

Headers:

  • Content-Type: application/json

Body:

{
    "enabled": true,
    "title": "Black Friday Sale",
    "description": "Massive discounts on all items!",
    "url": "https://example.com/black-friday"
}

Response

{
    "id": 1,
    "enabled": true,
    "title": "Black Friday Sale",
    "description": "Massive discounts on all items!",
    "url": "https://example.com/black-friday"
}

Errors

  • 401 Unauthorized: The user does not have permission to manage settings.
  • 500 Internal Server Error: An error occurred while updating the store sale.

Authentication

This API requires authentication. Ensure that the user has the appropriate roles to access the endpoints.

Permissions

The following permission is required for the POST endpoint:

  • settings.manage: Required to update or create store sale details.

admin/store-settings

Store Settings API

This API allows you to retrieve and update store settings.


Endpoints

1. Get Store Settings

Endpoint: /api/store-settings

HTTP Method: GET

Description: Retrieve the current store settings.

Response

{
    "id": 1,
    "settingName": "example",
    "settingValue": "value"
}

Error Response

Code: 500

{}

2. Update Store Settings

Endpoint: /api/store-settings

HTTP Method: POST

Description: Update the store settings. Requires authorization.

Request Body

{
    "settingName": "example",
    "settingValue": "newValue"
}

Response

Code: 200

{
    "success": true
}

Error Responses

Code: 401

{
    "error": "Unauthorized"
}

Code: 500

{
    "error": "Failed to update store settings"
}

Authentication

This API requires the user to be authenticated and have the settings.manage permission to update store settings.

Notes

Ensure that the request body for the POST method contains valid JSON with the required fields.

admin/ticket-settings

Ticket Category API Documentation

This API allows you to manage ticket categories, including creating, updating, retrieving, and deleting categories.


Endpoints

GET /api/ticket-categories

Retrieve all ticket categories along with their associated steps and fields.

Response

{
    "categories": [
        {
            "id": "string",
            "name": "string",
            "slug": "string",
            "webhook": "string",
            "steps": [
                {
                    "id": "string",
                    "name": "string",
                    "fields": [
                        {
                            "id": "string",
                            "label": "string",
                            "key": "string",
                            "type": "string",
                            "required": true,
                            "options": ["string"]
                        }
                    ]
                }
            ],
            "flags": [
                {
                    "id": "string",
                    "name": "string",
                    "color": "string"
                }
            ]
        }
    ]
}

POST /api/ticket-categories

Create a new ticket category.

Request Body

{
    "name": "string",
    "steps": [
        {
            "name": "string",
            "fields": [
                {
                    "label": "string",
                    "key": "string",
                    "type": "string",
                    "required": true,
                    "options": ["string"]
                }
            ]
        }
    ],
    "flags": [
        {
            "name": "string",
            "color": "string"
        }
    ],
    "webhook": "string"
}

Response

{
    "id": "string",
    "name": "string",
    "slug": "string",
    "webhook": "string",
    "steps": [
        {
            "id": "string",
            "name": "string",
            "fields": [
                {
                    "id": "string",
                    "label": "string",
                    "key": "string",
                    "type": "string",
                    "required": true,
                    "options": ["string"]
                }
            ]
        }
    ],
    "flags": [
        {
            "id": "string",
            "name": "string",
            "color": "string"
        }
    ]
}

PUT /api/ticket-categories

Update an existing ticket category.

Request Body

{
    "slug": "string",
    "name": "string",
    "steps": [
        {
            "id": "string",
            "name": "string",
            "fields": [
                {
                    "id": "string",
                    "label": "string",
                    "key": "string",
                    "type": "string",
                    "required": true,
                    "options": ["string"]
                }
            ]
        }
    ],
    "flags": [
        {
            "id": "string",
            "name": "string",
            "color": "string"
        }
    ],
    "webhook": "string"
}

Response

{
    "success": true,
    "message": "Category updated successfully"
}

Error Response

{
    "success": false,
    "message": "Failed to update category",
    "error": "Error details"
}

DELETE /api/ticket-categories

Delete an existing ticket category.

Request Body

{
    "slug": "string"
}

Response

{
    "success": true,
    "message": "Category and permissions deleted successfully"
}

Error Response

{
    "success": false,
    "message

admin/ticket-settings/[slug]/flags

Ticket Flags API

GET /api/ticket-flags/{slug}

Description

This endpoint retrieves a list of ticket flags associated with a specific category identified by the slug parameter.

Authentication

This endpoint requires user authentication. A valid session must be established to access the flags.

Parameters

  • slug (string, required): The unique identifier for the category of ticket flags to retrieve.

Request Example

GET /api/ticket-flags/12345

Responses

Success Response

HTTP/1.1 200 OK
Content-Type: application/json

[
    {
        "id": 1,
        "name": "Urgent",
        "categoryId": "12345"
    },
    {
        "id": 2,
        "name": "Pending",
        "categoryId": "12345"
    }
]

Error Responses

Unauthorized

HTTP/1.1 401 Unauthorized
Content-Type: application/json

{
    "error": "Unauthorized"
}

Internal Server Error

HTTP/1.1 500 Internal Server Error
Content-Type: application/json

{
    "error": "Failed to fetch flags"
}

Notes

Ensure that the provided slug corresponds to an existing category. The API will return an error if the session is invalid or if there is an issue with the database query.

admin/tickets

GET /api/tickets

Fetches a list of tickets based on user permissions and optional user ID.

Endpoint

GET /api/tickets

Authentication

This endpoint requires authentication. A valid session is necessary to access ticket data.

Query Parameters

Parameter Description Type Required
userId The ID of the user whose tickets are to be fetched. string No

Response

Successful Response

HTTP/1.1 200 OK
Content-Type: application/json

[
    {
        "id": "1",
        "title": "Ticket 1",
        "status": "open",
        "createdAt": "2023-10-01T12:00:00Z",
        "user": {
            "name": "John Doe",
            "image": "https://example.com/image.jpg"
        },
        "category": {
            "name": "Support",
            "slug": "support"
        },
        "flag": null
    },
    ...
]
    

Error Responses

Status Code Description Response Body
401 Unauthorized - No valid session found.
{
    "error": "Unauthorized"
}

Permissions

User permissions determine which tickets can be viewed. Users with the tickets.manage permission can view all tickets. Others will only see tickets in categories they have access to.

Example Request

GET /api/tickets?userId=12345
    

Notes

Ensure that the user has the necessary permissions to view the requested tickets. If no userId is provided, it will default to the current user's tickets based on their permissions.

admin/tickets/[id]

Ticket API Documentation

This API allows for managing tickets, including retrieving, updating, and deleting tickets.

Endpoints

GET /tickets/:id

Retrieve a Ticket

Fetches a ticket by its ID.

Parameters

  • id (string): The ID of the ticket to retrieve.

Responses


{
    "id": 1,
    "user": {
        "name": "John Doe",
        "image": "url_to_image",
        "storeId": 123,
        "createdAt": "2023-01-01T00:00:00Z",
        "accounts": [
            {
                "provider": "github",
                "providerAccountId": "123456"
            }
        ]
    },
    "category": {
        "name": "General Inquiry",
        "slug": "general-inquiry"
    },
    "flag": null
}
            

Error Responses


{
    "error": "Unauthorized"
}
{
    "error": "Ticket not found"
}
{
    "error": "Forbidden"
}
            
PUT /tickets/:id

Update a Ticket

Updates the specified ticket's status and/or flag.

Parameters

  • id (string): The ID of the ticket to update.

Request Body


{
    "flagId": 2,
    "status": "open" // optional
}
            

Responses


{
    "id": 1,
    "flagId": 2,
    "status": "open"
}
            

Error Responses


{
    "error": "Unauthorized"
}
{
    "error": "Ticket not found"
}
{
    "error": "Forbidden"
}
{
    "error": "Failed to update ticket"
}
            
DELETE /tickets/:id

Delete a Ticket

Marks the specified ticket as closed.

Parameters

  • id (string): The ID of the ticket to delete.

Responses


{
    "success": true
}
            

Error Responses


{
    "error": "Unauthorized"
}
{
    "error": "Ticket not found"
}
{
    "error": "Forbidden"
}
{
    "error": "Failed to close ticket"
}
            

Authentication

All endpoints require authentication. A valid session is necessary to access ticket data.

Permissions

Users must have the appropriate permissions to manage tickets. Permissions include:

  • tickets.manage: General permission to manage tickets.
  • tickets.{category_slug}

    admin/tickets/[id]/messages

    Ticket Message API

    This API allows you to interact with ticket messages in the system. You can retrieve messages for a specific ticket and post new messages.


    Endpoints

    GET /api/tickets/{id}/messages

    Retrieve all messages for a specific ticket.

    Parameters

    • id (path, required): The ID of the ticket.

    Response

    {
        "id": 1,
        "messages": [
            {
                "id": 101,
                "content": "Hello, how can I help you?",
                "createdAt": "2023-10-01T12:00:00Z",
                "user": {
                    "name": "John Doe",
                    "image": "https://example.com/johndoe.png"
                }
            }
        ]
    }

    Error Responses

    • 401 Unauthorized: User is not authenticated.

    Example Request

    GET /api/tickets/1/messages

    POST /api/tickets/{id}/messages

    Post a new message to a specific ticket.

    Parameters

    • id (path, required): The ID of the ticket.

    Request Body

    {
        "message": "This is a new message."
    }

    Response

    {
        "id": 102,
        "content": "This is a new message.",
        "createdAt": "2023-10-01T12:01:00Z",
        "user": {
            "id": 1,
            "image": "https://example.com/johndoe.png"
        }
    }

    Error Responses

    • 401 Unauthorized: User is not authenticated.
    • 404 Not Found: Ticket not found.

    Example Request

    POST /api/tickets/1/messages
    Content-Type: application/json
    
    {
        "message": "This is a new message."
    }

    admin/user-count

    Accounts

    GET /api/accounts/count

    Retrieves the count of accounts associated with the 'steam' provider.

    HTTP Method

    GET

    Request Parameters

    This endpoint does not require any query parameters.

    Expected Responses

    Success Response

    {
        "count": 10
    }

    Returns a JSON object containing the count of accounts.

    Error Response

    {
        "error": "Internal Server Error"
    }

    Returns an error object in case of server issues.

    Error Codes

    • 500: Internal Server Error - An unexpected error occurred on the server.

    Example Request

    GET /api/accounts/count

    Example Response

    {
        "count": 5
    }

    Authentication

    This endpoint is protected and requires authentication. Ensure that you include a valid token in the request headers.

    Authentication Header

    Authorization: Bearer YOUR_ACCESS_TOKEN

    Notes

    This endpoint specifically counts accounts from the 'steam' provider. Adjust the provider parameter in the database query as necessary for other providers.

    admin/users

    User Management API

    GET /api/users

    Fetch a list of users with optional filtering and pagination.

    Request Parameters

    • page (optional, integer): The page number to retrieve. Defaults to 1.
    • pageSize (optional, integer): The number of users per page. Defaults to 10.
    • search (optional, string): A search query to filter users by name, storeId, or linked accounts.
    • userId (optional, string): A specific user ID to fetch.

    Response

    {
        "users": [
            {
                "id": "string",
                "name": "string",
                "storeId": "string",
                "image": "string",
                "steamId": "string | null",
                "discordId": "string | null",
                "createdAt": "string"
            }
        ],
        "total": "integer"
    }
            

    Example Request

    GET /api/users?page=1&pageSize=10&search=john
            

    Example Response

    {
        "users": [
            {
                "id": "1",
                "name": "John Doe",
                "storeId": "store123",
                "image": "http://example.com/image.jpg",
                "steamId": "steamAccountId123",
                "discordId": null,
                "createdAt": "2023-01-01T00:00:00Z"
            }
        ],
        "total": 1
    }
            

    Error Responses

    • 500 Internal Server Error: If an error occurs while fetching users.
    {
        "error": "Failed to fetch users"
    }
            

    admin/users/linked


    Endpoint

    GET /api/users

    Description

    Fetches a list of users who have connected their accounts via the Discord provider. The response includes the provider account IDs of these users.

    HTTP Method

    GET

    Authentication

    This endpoint is protected and requires authentication. Ensure that you have valid credentials to access this resource.

    Request Parameters

    No request parameters are required for this endpoint.

    Response

    Success Response

    On a successful request, the API will return a JSON object containing an array of provider account IDs.

    {
        "users": [
            "providerAccountId1",
            "providerAccountId2",
            ...
        ]
    }

    Response Status Codes

    • 200 OK - Successfully fetched the users.
    • 500 Internal Server Error - An error occurred while fetching users.

    Error Response

    In the event of an error, the API will return a JSON object with an error message.

    {
        "error": "Failed to fetch users"
    }

    Example Request

    GET /api/users

    Example Successful Response

    {
        "users": [
            "123456789012345678",
            "987654321098765432"
        ]
    }

    Example Error Response

    {
        "error": "Failed to fetch users"
    }

    API Version 1.0

    admin/vote-results


    Endpoint

    Retrieve active map votes.

    GET /api/votes/active

    HTTP Method

    GET

    Authentication

    This endpoint requires authentication. Use a valid token in the request headers.

    Request Parameters

    No query parameters are required for this request.

    Response

    On success, the API will return a JSON array of active map votes.

    Success Response

    HTTP/1.1 200 OK
    Content-Type: application/json
    
    [
        {
            "vote_start": "2023-10-01T12:00:00Z",
            "vote_end": "2023-10-01T14:00:00Z",
            "wipe_time": "2023-10-01T14:00:00Z",
            "map": {
                "id": "map123",
                "thumbnailUrl": "https://example.com/thumbnail.jpg",
                "userVotes": 10
            },
            "server": {
                "id": "server456",
                "name": "Server Name"
            }
        }
    ]

    Response Fields

    • vote_start: The start time of the voting period.
    • vote_end: The end time of the voting period.
    • wipe_time: The time when the map will start.
    • map: An object containing details about the map:
      • id: The unique identifier of the map.
      • thumbnailUrl: URL to the map's thumbnail image.
      • userVotes: The count of user votes for the map.
    • server: An object containing server details:
      • id: The unique identifier of the server.
      • name: The name of the server.

    Error Responses

    Common Error Codes

    • 401 Unauthorized: Authentication failed or token is missing.
    • 500 Internal Server Error: An unexpected error occurred on the server.

    Example Request

    curl -X GET "https://api.example.com/api/votes/active" -H "Authorization: Bearer YOUR_TOKEN"

    Notes

    Ensure to replace YOUR_TOKEN with a valid access token.

    auth/[...nextauth]x

    This documentation provides details about the authentication API using NextAuth.


    Endpoints

    • GET /api/auth

      Handles authentication requests using the GET method.

    • POST /api/auth

      Handles authentication requests using the POST method.


    HTTP Methods

    • GET: Retrieve authentication session or redirect to sign-in.
    • POST: Submit credentials for authentication.

    Parameters

    Request Parameters

    • req: An instance of NextRequest containing the request data.
    • res: An instance of NextRequest used to send the response.

    Expected Responses

    Successful Responses

    On successful authentication, the API returns a session object with user information.

    
    {
        "user": {
            "name": "John Doe",
            "email": "john.doe@example.com",
            "image": "https://example.com/john.jpg"
        },
        "expires": "2023-10-30T12:00:00.000Z"
    }
        

    Error Responses

    In case of an error, the API will return an error message with a status code.

    
    {
        "error": "Authentication failed",
        "status": 401
    }
        

    Error Codes

    • 401: Unauthorized - Invalid credentials provided.
    • 403: Forbidden - Access denied for the requested resource.
    • 500: Internal Server Error - An unexpected error occurred on the server.

    Examples

    GET Request Example

    
    GET /api/auth HTTP/1.1
    Host: example.com
    Authorization: Bearer your_token_here
        

    POST Request Example

    
    POST /api/auth HTTP/1.1
    Host: example.com
    Content-Type: application/json
    
    {
        "email": "john.doe@example.com",
        "password": "your_password"
    }
        

    Generated with love for developers. Happy coding!

    bans

    BattleMetrics API

    API for retrieving ban information from BattleMetrics.

    GET /bans

    Fetches a list of bans from the BattleMetrics API.

    Endpoint

    https://api.yourdomain.com/bans

    HTTP Method

    GET

    Query Parameters

    Parameter Type Description Default
    pageSize integer Number of bans to return per page. 25
    pageKey string Key for pagination to fetch the next page of results.
    filter[search] string Search term to filter bans.
    filter[banList] string ID of the ban list to filter results. (fixed value) 7b844ef0-1baf-11ef-83d3-c1d70e327b8d

    Success Response

    HTTP/1.1 200 OK
    {
        "data": [
            {
                "id": "ban_id",
                "attributes": {
                    "reason": "ban_reason",
                    "createdAt": "2023-01-01T00:00:00Z",
                    "updatedAt": "2023-01-01T00:00:00Z"
                }
            }
        ],
        "meta": {
            "total": 100,
            "page": {
                "size": 25,
                "key": "next_page_key"
            }
        }
    }
        

    Error Responses

    500 Internal Server Error

    HTTP/1.1 500 Internal Server Error
    {
        "error": "BattleMetrics API key is not configured"
    }
        
    HTTP/1.1 500 Internal Server Error
    {
        "error": "An error occurred while fetching the bans."
    }
        

    Example Request

    GET https://api.yourdomain.com/bans?pageSize=10&filter[search]=example
        

    Notes

    • Ensure that the environment variable BM_API_KEY is set correctly.
    • The banListId is fixed and should not be changed.

    cache

    API Documentation

    Dark-themed API documentation for the PayNow Cache Management.

    Endpoints

    • GET /api/cache
    • PATCH /api/cache

    GET /api/cache

    Fetches cached data based on a provided key.

    Parameters

    Parameter Type Description
    key string The key for the cache entry. This parameter is required.

    Responses

    Successful Response

    {
        "data": { ... } // Cached data
    }

    Status Code: 200

    Error Responses

    • 400 Bad Request: Key is required.
    • 404 Not Found: Cache not found.
    • 500 Internal Server Error: Failed to fetch cache.

    Example Request

    GET /api/cache?key=exampleKey

    PATCH /api/cache

    Refreshes the cache for all defined endpoints.

    Responses

    Successful Response

    {
        "message": "Cache refreshed successfully"
    }

    Status Code: 200

    Error Responses

    • 500 Internal Server Error: Failed to refresh cache.

    Example Request

    PATCH /api/cache

    Notes

    The cache is refreshed for the following endpoints:

    • store
    • store/tags
    • store/navlinks
    • store/products

    comments/[id]

    User Comments API

    This API allows you to fetch user details and create comments associated with a user.


    Endpoints

    GET /api/users/{id}

    Fetch user details along with their associated comments and roles.

    Parameters

    • id (string): The unique identifier of the user.

    Responses

    • 200 OK: Returns user details along with roles and comments.
    • 404 Not Found: User not found.
    • 500 Internal Server Error: An error occurred while fetching user details.

    Example Request

    GET /api/users/12345

    Example Response

    {
      "id": "12345",
      "name": "John Doe",
      "image": "url_to_image",
      "roles": [...],
      "Comment": [
        {
          "content": "This is a comment",
          "role": {...},
          "creator": {
            "id": "67890",
            "name": "Jane Smith",
            "image": "url_to_image"
          }
        }
      ]
    }

    POST /api/users/{id}/comments

    Create a comment for a specific user.

    Parameters

    • id (string): The unique identifier of the user.

    Request Body

    {
      "content": "Your comment content here"
    }

    Responses

    • 201 Created: Comment created successfully.
    • 400 Bad Request: Content is required or creator has no roles.
    • 401 Unauthorized: User must be authenticated to create a comment.
    • 404 Not Found: Creator not found.
    • 500 Internal Server Error: An error occurred while creating the comment.

    Example Request

    POST /api/users/12345/comments
    Content-Type: application/json
    
    {
      "content": "This is a new comment"
    }

    Example Response

    {
      "id": "1",
      "content": "This is a new comment",
      "userId": "12345",
      "roleId": "role_id",
      "creatorId": "67890",
      "role": {...},
      "creator": {
        "id": "67890",
        "name": "Jane Smith",
        "image": "url_to_image"
      }
    }

    Error Codes

    • 400: Bad Request - Invalid input data.
    • 401: Unauthorized - Authentication required.
    • 404: Not Found - Resource not found.
    • 500: Internal Server Error - Unexpected error occurred.

    leaderboard-tabs

    Leaderboard API Documentation

    This API provides access to leaderboard tabs and their associated columns.


    Endpoints

    GET /api/leaderboard/tabs

    Fetch Leaderboard Tabs

    Retrieves a list of leaderboard tabs along with their columns.

    HTTP Method:

    GET

    Request Parameters:

    No request parameters required.

    Success Response:

    HTTP/1.1 200 OK
    [
        {
            "id": 1,
            "name": "Tab 1",
            "order": 1,
            "columns": [
                {
                    "id": 1,
                    "name": "Column 1",
                    "order": 1
                },
                {
                    "id": 2,
                    "name": "Column 2",
                    "order": 2
                }
            ]
        },
        {
            "id": 2,
            "name": "Tab 2",
            "order": 2,
            "columns": [
                {
                    "id": 3,
                    "name": "Column 3",
                    "order": 1
                }
            ]
        }
    ]

    Error Response:

    HTTP/1.1 500 Internal Server Error
    {
        "message": "Error fetching leaderboard tabs"
    }

    Error Codes:

    • 500 - Internal Server Error: Indicates that there was an error while fetching the leaderboard tabs.

    Error Handling

    In case of an error, the API will return a JSON response with a message indicating the nature of the error, along with a corresponding HTTP status code.

    Example Error Response:

    {
        "message": "Error fetching leaderboard tabs"
    }

    Notes

    • Ensure the database is connected and the schema is correctly set up for the API to function properly.
    • All responses are returned in JSON format.

    manage-comment/[noteId]

    Manage Comment API

    This API allows users to manage comments associated with notes.

    Endpoints

    DELETE /api/manage-comment/[noteId]

    Delete a Comment

    Removes a comment identified by the noteId parameter.

    Request

    DELETE /api/manage-comment/{noteId}

    Parameters

    • noteId (path parameter): The ID of the comment to delete.

    Responses

    • 200 OK: Comment successfully deleted.
    • 401 Unauthorized: User is not authenticated.
    • 403 Forbidden: User does not have permission to delete this comment.
    • 404 Not Found: Comment with the specified ID does not exist.
    • 500 Internal Server Error: An error occurred while processing the request.

    Example Request

    DELETE /api/manage-comment/12345

    Example Response

    { "success": true }
    PUT /api/manage-comment/[noteId]

    Update a Comment

    Updates the content of a comment identified by the noteId parameter.

    Request

    PUT /api/manage-comment/{noteId}

    Parameters

    • noteId (path parameter): The ID of the comment to update.

    Request Body

    {
        "content": "Updated comment content"
    }

    Responses

    • 200 OK: Comment successfully updated.
    • 400 Bad Request: Content is required or invalid.
    • 401 Unauthorized: User is not authenticated.
    • 403 Forbidden: User does not have permission to update this comment.
    • 404 Not Found: Comment with the specified ID does not exist.
    • 500 Internal Server Error: An error occurred while processing the request.

    Example Request

    PUT /api/manage-comment/12345

    Example Request Body

    {
        "content": "This is the updated content."
    }

    Example Response

    {
        "id": "12345",
        "content": "This is the updated content.",
        "creator": {
            "id": "67890",
            "name": "John Doe",
            "image": "https://example.com/image.jpg"
        }
    }

    maps

    Map Votes API

    This API allows you to retrieve map votes based on their status.

    Endpoints

    GET /api/mapVotes

    Description

    Fetches map votes filtered by their status.

    Query Parameters

    • status (optional): The status of the votes to retrieve. Acceptable values are:
      • active: Votes that are currently ongoing.
      • completed: Votes that have ended.

    Response

    Returns a JSON array of map votes that match the specified criteria.

    Success Response

    
    {
        "mapVotes": [
            {
                "id": 1,
                "vote_start": "2023-10-01T00:00:00Z",
                "vote_end": "2023-10-31T23:59:59Z",
                "map_options": [
                    {
                        "id": 1,
                        "name": "Map A",
                        "userVotes": [
                            {
                                "user_id": 1,
                                "vote": true
                            }
                        ]
                    }
                ],
                "server": {
                    "server_id": 1,
                    "server_name": "Server 1",
                    "server_address": "192.168.1.1"
                }
            }
        ]
    }
                

    Error Responses

    • 500 Internal Server Error - If an error occurs while fetching data.
    
    {
        "error": "Internal Server Error"
    }
                

    Example Request

    
    GET /api/mapVotes?status=active HTTP/1.1
    Host: example.com
    Accept: application/json
        

    Notes

    Ensure to handle errors appropriately in your application. The API will return a 500 status code for any internal errors.

    maps/[id]

    MapVote API Documentation

    This API allows you to retrieve details about a specific map vote, including options and associated user votes.


    GET /api/mapvote/{id}

    Retrieve a specific map vote by its unique identifier.

    Request

    This endpoint requires the following parameters:

    • Path Parameter:
      • id (string): The unique identifier of the map vote.

    Response

    The response will return a JSON object containing the map vote details.

    Successful Response

    {
        "id": "123",
        "vote_end": "2023-10-25T12:00:00Z",
        "map_options": [
            {
                "id": "1",
                "name": "Option 1",
                "vote_count": 10
            },
            {
                "id": "2",
                "name": "Option 2",
                "vote_count": 5
            }
        ],
        "server": {
            "server_id": "abc123",
            "server_name": "Game Server 1"
        }
    }
        

    Error Responses

    • 204 No Content: Mapvote not found.
    • {
          "error": "Mapvote not found"
      }
              
    • 500 Internal Server Error: An error occurred while fetching the map vote.
    • {
          "error": "Internal Server Error"
      }
              

    Example Request

    GET /api/mapvote/123
        

    Notes

    The vote_count field will only be populated if the voting period has ended.

    players

    Players API Documentation

    This API allows for retrieving and managing player data.


    Endpoints

    GET /api/players

    Retrieves player information based on Steam IDs.

    Parameters

    • ids (string, required): A comma-separated list of Steam IDs.

    Response

            [
                {
                    "username": "PlayerOne",
                    "steam_id": "123456789",
                    "avatar": "http://avatar.url",
                    "user": {
                        "image": "http://user.image.url"
                    }
                },
                ...
            ]
            

    Error Responses

    • 400 Bad Request: Invalid or missing parameters.

    Example Request

            GET /api/players?ids=123456789,987654321
            

    POST /api/players

    Creates or updates player information.

    Request Body

            {
                "steamId": "123456789",
                "username": "PlayerOne",
                "avatar": "http://avatar.url"
            }
            

    Response

            {
                "success": true
            }
            

    Error Responses

    • 400 Bad Request: Missing required fields.
    • 500 Internal Server Error: An error occurred on the server.

    Example Request

            POST /api/players
            Content-Type: application/json
    
            {
                "steamId": "123456789",
                "username": "PlayerOne",
                "avatar": "http://avatar.url"
            }
            

    Authentication

    Both endpoints require authentication. Ensure you include the necessary authentication tokens in your requests.

    redirects

    Redirects API

    GET /api/redirects

    This endpoint retrieves a list of redirects.

    HTTP Method

    GET

    Request Parameters

    No parameters are required for this endpoint.

    Response

    The response will return a JSON array containing redirect objects.

    {
        "redirects": [
            {
                "from": "/old-path",
                "to": "/new-path"
            },
            ...
        ]
    }

    Headers

    • Cache-Control: s-maxage=300, stale-while-revalidate

    Success Response

    HTTP Status Code: 200 OK

    {
        "redirects": [
            {
                "from": "/old-path",
                "to": "/new-path"
            },
            {
                "from": "/another-old-path",
                "to": "/another-new-path"
            }
        ]
    }

    Error Response

    In case of an error while fetching redirects, the API will return an empty array.

    HTTP Status Code: 200 OK

    []
    

    Error Codes

    • 500 Internal Server Error: Occurs when there is an issue in fetching redirects from the data source.

    Caching

    The API response is cached for 300 seconds (5 minutes) to improve performance and reduce load on the server.

    Notes

    Ensure to handle the empty response case in your client application.

    roles/[id]

    API Documentation

    Endpoint: Get Role by ID

    HTTP Method: GET

    URL: /api/roles/{id}

    Parameters

    Parameter Description Required
    id The unique identifier for the role. This can be a Discord role ID, an oxide group name, or the role name. Yes

    Responses

    Success Response

    {
        "role": {
            "id": "string",
            "name": "string",
            "serverId": "string",
            "oxideGroupName": "string",
            "assignOnBoost": true,
            "assignOnVerification": true,
            "assignOnGroupJoin": true,
            "discordAssociations": [
                {
                    "discordGuild": "string",
                    "discordRole": "string"
                }
            ]
        }
    }

    Error Responses

    Role Not Found

    {
        "error": "Role not found"
    }

    Status Code: 204

    Internal Server Error

    {
        "error": "Failed to lookup Discord roles"
    }

    Status Code: 500

    Example Request

    GET /api/roles/123456789012345678

    Example Success Response

    {
        "role": {
            "id": "123",
            "name": "Admin",
            "serverId": "456",
            "oxideGroupName": "Admins",
            "assignOnBoost": true,
            "assignOnVerification": false,
            "assignOnGroupJoin": true,
            "discordAssociations": [
                {
                    "discordGuild": "My Guild",
                    "discordRole": "Admin Role"
                }
            ]
        }
    }

    Notes

    • This endpoint is protected and requires authentication.
    • Ensure that the provided ID corresponds to an existing role in the database.

    servers

    Endpoint: Retrieve Server Categories

    This endpoint retrieves all server categories along with their enabled servers.

    GET /api/server-categories

    Description

    Fetches a list of server categories, each containing a sorted list of enabled servers.

    Request

    This endpoint accepts a GET request without any required parameters.

    Response

    On success, the API returns a JSON object containing an array of categories with their respective servers.

    Success Response

    {
        "data": [
            {
                "id": 1,
                "name": "Category 1",
                "servers": [
                    {
                        "server_id": 1,
                        "server_name": "Server A",
                        "server_address": "192.168.1.1",
                        "image_path": "/images/server-a.png",
                        "order": 1,
                        "mapVotes": [
                            {
                                "id": 1
                            }
                        ]
                    },
                    {
                        "server_id": 2,
                        "server_name": "Server B",
                        "server_address": "192.168.1.2",
                        "image_path": "/images/server-b.png",
                        "order": 2,
                        "mapVotes": []
                    }
                ]
            },
            {
                "id": 2,
                "name": "Category 2",
                "servers": []
            }
        ]
    }
        

    Error Response

    {
        "error": "Query failed"
    }
        

    In case of an error, the API will return a 500 status code along with an error message.

    Error Codes

    • 500: Internal Server Error - The query failed due to an unexpected error.

    Notes

    - The servers are sorted by their 'order' field within each category.

    - Only enabled servers with a future map start time are included in the response.

    session/update

    GET /api/user/session

    Fetches the current user's session information, including whether they have joined a Steam group and their boosted guilds.

    HTTP Method

    GET

    Request Parameters

    No query parameters are required for this endpoint.

    Authentication

    This endpoint requires a valid user session. If the session is invalid or the user ID is not present, a 400 error will be returned.

    Responses

    Success Response

    {
        "joinedSteamGroup": true,
        "boostedGuilds": ["guildId1", "guildId2"]
    }
        

    Returns a JSON object containing:

    • joinedSteamGroup: boolean indicating if the user has joined the Steam group.
    • boostedGuilds: array of IDs representing the guilds the user has boosted.

    Error Responses

    400 Bad Request

    {
        "success": false,
        "message": "invalid session"
    }
        

    Returned when the session is invalid or the user ID is not found.

    404 Not Found

    {
        "success": false,
        "message": "user not found"
    }
        

    Returned when the user does not exist in the database.

    500 Internal Server Error

    {
        "success": false,
        "message": "internal server error"
    }
        

    Returned when there is an unexpected error during the request processing.

    Example Request

    GET /api/user/session

    Notes

    Ensure that the user is authenticated and has a valid session before making this request.

    site-settings

    Comprehensive documentation for the Site Settings API.


    Endpoints

    GET /api/site-settings

    Description

    Fetches the current site settings. If no settings are found, it creates default settings.

    HTTP Method

    GET

    Request Parameters

    None

    Responses

    Success Response

    {
        "name": "Noble Rust Template",
        "discordInvite": "https://discord.gg/ArWvQaYFfx"
    }

    Status Code: 200 OK

    Default Creation Response

    {
        "name": "Noble Rust Template",
        "discordInvite": "https://discord.gg/ArWvQaYFfx"
    }

    Status Code: 201 Created

    Error Response

    {
        "error": "Internal Server Error"
    }

    Status Code: 500 Internal Server Error

    Example Request

    GET /api/site-settings HTTP/1.1
    Host: example.com
    Accept: application/json

    Error Codes

    • 500: Internal Server Error - An unexpected error occurred while processing the request.

    sitemap

    Sitemap API Documentation

    This API allows you to generate and retrieve a sitemap in XML format.

    Endpoints

    GET /api/sitemap

    Description

    Fetches the generated sitemap. Returns the sitemap in XML format if successful, or an error message if the sitemap cannot be generated.

    HTTP Method

    GET

    Request Parameters

    No parameters are required for this endpoint.

    Responses

    Successful Response

    
    HTTP/1.1 200 OK
    Content-Type: application/xml
    
    <?xml version="1.0" encoding="UTF-8"?>
    <urlset xmlns="http://www.sitemaps.org/schemas/sitemap-image">
        <url>
            <loc>https://example.com/</loc>
            <lastmod>2023-10-01</lastmod>
            <changefreq>daily</changefreq>
            <priority>1.0</priority>
        </url>
        ...
    </urlset>
    
    

    Error Responses

    
    HTTP/1.1 404 Not Found
    Content-Type: text/plain
    
    Sitemap is empty
    
    
    
    HTTP/1.1 500 Internal Server Error
    Content-Type: text/plain
    
    Error generating sitemap
    
    

    Error Codes

    • 404 Not Found: Returned when the sitemap is empty or invalid.
    • 500 Internal Server Error: Returned when there is an error during sitemap generation.

    Example Request

    
    GET /api/sitemap HTTP/1.1
    Host: example.com
    
    

    stats

    This documentation covers the endpoints for managing player statistics.

    Endpoints

    GET /api/stats

    Fetch statistics for a specified tab.

    Parameters

    • tab (required): The statistics table to query. Possible values: pvp_stats, resources_stats, explosives_stats, farming_stats, misc_stats, events_stats.
    • page (optional): The page number for pagination. Default is 1.
    • pageSize (optional): The number of records per page. Default is 10.
    • sortField (optional): The field to sort by.
    • sortOrder (optional): The order of sorting. Can be ASC or DESC. Default is ASC.
    • filter (optional): A search filter for player username or steam ID.
    • server (optional): The server ID to filter results.

    Responses

    {
        "data": [
            {
                "steam_id": "123456789",
                "username": "player1",
                "kills": 10,
                "deaths": 5,
                "kdr": 2
            }
        ],
        "totalPages": 5,
        "totalCount": 50
    }
        

    Error Codes

    • 400: Invalid tab specified.
    • 500: Query failed.

    POST /api/stats

    Update player statistics.

    Request Body

    [
        {
            "steamId": "123456789",
            "serverId": "server_1",
            "kills": 5,
            "deaths": 2
        },
        {
            "steamId": "987654321",
            "serverId": "server_2",
            "kills": 10,
            "deaths": 3
        }
    ]
        

    Responses

    {
        "success": true
    }
        

    Error Codes

    • 400: Invalid updates format or missing required fields.
    • 500: Update failed.

    Data Models

    StatUpdate

    type StatUpdate = {
        steamId: string;
        serverId: string;
        [key: string]: any;
    };
        

    TotalCountResult

    type TotalCountResult = {
        total: bigint; // BigInt is used to match the COUNT query's return type
    };
        

    Notes

    Ensure that all server IDs are created via the admin panel before updating statistics.

    support

    Ticket API Documentation

    This API allows you to manage ticket categories and create tickets.

    Endpoints

    GET /api/tickets/categories

    Fetches all ticket categories with their associated steps and fields.

    HTTP Method

    GET

    Response

    [
            {
                "id": "1",
                "name": "Support",
                "steps": [
                    {
                        "id": "1",
                        "title": "Step 1",
                        "fields": [
                            { "id": "1", "name": "Field 1", "order": 1 },
                            { "id": "2", "name": "Field 2", "order": 2 }
                        ]
                    }
                ]
            }
        ]

    POST /api/tickets/create

    Creates a new ticket under a specified category.

    HTTP Method

    POST

    Request Body

    {
            "categoryId": "string", // The slug of the category
            "content": "string | object" // The content of the ticket
        }

    Response

    {
            "id": "string",
            "categoryId": "string",
            "content": "string",
            "userId": "string",
            "createdAt": "string",
            "updatedAt": "string"
        }

    Error Responses

    • 401 Unauthorized: User session is required.
    • 204 No Content: Category not found.
    • 500 Internal Server Error: Failed to create ticket.

    Example Request

    POST /api/tickets/create
    Content-Type: application/json
    
    {
        "categoryId": "support",
        "content": "I need help with my account."
    }

    Example Response

    {
            "id": "abc123",
            "categoryId": "support",
            "content": "I need help with my account.",
            "userId": "user123",
            "createdAt": "2023-10-01T12:00:00Z",
            "updatedAt": "2023-10-01T12:00:00Z"
        }

    support/[slug]

    Ticket Category API Documentation

    Overview

    This API provides access to ticket categories, allowing users to retrieve detailed information about a specific category based on its unique slug identifier.

    Endpoints

    GET /api/ticket-categories/:slug

    Retrieve a specific ticket category by its slug.

    HTTP Method

    GET

    Parameters

    Parameter Type Description
    slug string The unique identifier for the ticket category.

    Expected Responses

    Success Response

    Status Code: 200 OK

    {
        "id": 1,
        "slug": "example-category",
        "steps": [
            {
                "id": 1,
                "order": 1,
                "fields": [/* array of field objects */]
            },
            {
                "id": 2,
                "order": 2,
                "fields": [/* array of field objects */]
            }
        ]
    }

    Error Responses

    Status Code: 404 Not Found

    {
        "error": "Ticket category not found"
    }

    Examples

    Request

    GET /api/ticket-categories/example-category

    Response

    {
        "id": 1,
        "slug": "example-category",
        "steps": [
            {
                "id": 1,
                "order": 1,
                "fields": [{ "id": 1, "name": "Field 1" }]
            },
            {
                "id": 2,
                "order": 2,
                "fields": [{ "id": 2, "name": "Field 2" }]
            }
        ]
    }

    tickets

    Tickets API

    GET /api/tickets

    Retrieve a list of tickets associated with the authenticated user.

    Authentication

    This endpoint requires user authentication. A valid session must be established.

    Request

    GET /api/tickets

    Response

    The response will return a JSON array of ticket objects or an error message if unauthorized.

    Success Response

    
    HTTP/1.1 200 OK
    Content-Type: application/json
    
    [
        {
            "id": 1,
            "title": "Ticket Title 1",
            "category": {
                "name": "Category Name",
                "slug": "category-slug"
            }
        },
        {
            "id": 2,
            "title": "Ticket Title 2",
            "category": {
                "name": "Category Name",
                "slug": "category-slug"
            }
        }
    ]
                

    Error Responses

    Possible error responses include:

    • 401 Unauthorized
      
      HTTP/1.1 401 Unauthorized
      Content-Type: application/json
      
      {
          "error": "Unauthorized"
      }
                          

    Parameters

    This endpoint does not require any query parameters.

    tickets/reportable

    Players API Documentation

    This API allows you to retrieve player information based on a search query.

    Endpoint

    GET /api/players

    Authentication

    This endpoint requires user authentication. A valid session must be established to access this resource.

    Query Parameters

    Parameter Type Required Description
    search string No Search term to filter players by username or steam ID.

    Response

    Success Response

    HTTP/1.1 200 OK
    Content-Type: application/json
    
    [
        {
            "username": "player1",
            "steam_id": "123456789",
            "user": {
                "image": "https://example.com/image1.png"
            }
        },
        {
            "username": "player2",
            "steam_id": "987654321",
            "user": {
                "image": "https://example.com/image2.png"
            }
        }
    ]

    Error Response

    HTTP/1.1 401 Unauthorized
    Content-Type: application/json
    
    {
        "error": "Unauthorized"
    }

    Error Codes

    Error Code Description
    401 The request is unauthorized. Ensure the user is authenticated.

    Example Request

    GET /api/players?search=player1

    Notes

    - The response will return up to 20 players sorted by their last seen time in descending order.

    tickets/[id]

    This documentation outlines the available endpoints for managing tickets.

    GET /api/tickets/:id

    Retrieve a specific ticket by its ID.

    Parameters:

    • id (string): The ID of the ticket to retrieve.

    Request Example:

    GET /api/tickets/1

    Responses:

    • 200 OK: Returns the ticket object.
    • 401 Unauthorized: If the user is not authenticated.

    Response Example:

    {
        "id": 1,
        "title": "Sample Ticket",
        "status": "open",
        "category": {
            "name": "Support",
            "slug": "support"
        }
    }

    DELETE /api/tickets/:id

    Close a specific ticket by its ID.

    Parameters:

    • id (string): The ID of the ticket to close.

    Request Example:

    DELETE /api/tickets/1

    Responses:

    • 200 OK: Returns success message.
    • 401 Unauthorized: If the user is not authenticated.
    • 500 Internal Server Error: If there is an error closing the ticket.

    Response Example:

    {
        "success": true
    }

    Error Response Example:

    {
        "error": "Failed to close ticket"
    }

    tickets/[id]/messages

    Ticket Messages API

    This API allows users to retrieve and post messages related to specific tickets.

    Endpoints

    GET /api/ticketMessages/{id}

    Retrieve Messages

    Fetch all messages for a specific ticket.

    Parameters:

    • id (path parameter): The ID of the ticket for which messages are being retrieved.

    Authentication:

    This endpoint requires user authentication. A valid session is needed to access the messages.

    Responses:

    • 200 OK: Returns an array of messages for the specified ticket.
    • 401 Unauthorized: Returned when the user is not authenticated.

    Example Request:

    GET /api/ticketMessages/1

    Example Response:

    [
        {
            "id": 1,
            "content": "Hello, how can I help you?",
            "createdAt": "2023-10-01T10:00:00Z",
            "user": {
                "name": "John Doe",
                "image": "https://example.com/image.jpg"
            }
        }
    ]
    POST /api/ticketMessages/{id}

    Post a Message

    Create a new message for a specific ticket.

    Parameters:

    • id (path parameter): The ID of the ticket to which the message is being posted.

    Request Body:

    {
        "message": "Your message content here."
    }

    Authentication:

    This endpoint requires user authentication. A valid session is needed to post a message.

    Responses:

    • 201 Created: Returns the created message object.
    • 401 Unauthorized: Returned when the user is not authenticated.

    Example Request:

    POST /api/ticketMessages/1

    Example Request Body:

    {
        "message": "Thank you for reaching out!"
    }

    Example Response:

    {
        "id": 2,
        "content": "Thank you for reaching out!",
        "createdAt": "2023-10-01T10:05:00Z",
        "user": {
            "id": "123",
            "name": "Jane Doe",
            "image": "https://example.com/image2.jpg"
        }
    }

    Error Codes

    Status Code Description
    401 Unauthorized - The user is not authenticated.
    404 Not Found - The specified ticket does not exist.
    500 Internal Server Error - An unexpected error occurred.

    user

    This API allows for the management of user roles in both Oxide and Discord environments.

    Endpoints

    GET /api/roles

    Retrieve user roles based on the specified type (oxide or discord).

    Parameters

    • type (query parameter, required): The type of role management. Possible values are oxide or discord.
    • playerId (query parameter, required for oxide): The Steam ID of the player.
    • serverId (query parameter, required for oxide): The server ID.
    • discordId (query parameter, required for discord): The Discord user ID.
    • guildId (query parameter, required for discord): The Discord guild ID.

    Responses

    Success Response

    {
        "roles": ["role1", "role2"]
    }

    Error Response

    {
        "success": false,
        "message": "Missing playerId or serverId"
    }

    Error codes:

    • 400 - Bad Request: Missing required parameters or invalid type.

    POST /api/roles

    Assign or revoke roles for users in either Oxide or Discord.

    Parameters

    • type (query parameter, required): The type of role management. Possible values are oxide or discord.
    • serverId (query parameter, required for oxide): The server ID for Oxide roles.

    Request Body

    Oxide Example

    {
        "roles": [
            {
                "steamId": "123456789",
                "role": "Admin",
                "action": "added"
            },
            {
                "steamId": "987654321",
                "role": "User",
                "action": "revoked"
            }
        ]
    }

    Discord Example

    {
        "roles": [
            {
                "discordGuildId": "guild123",
                "userId": "user456",
                "role": "Moderator",
                "action": "added"
            }
        ]
    }

    Responses

    Success Response

    {
        "success": true,
        "message": "Roles processed successfully"
    }

    Error Response

    {
        "success": false,
        "message": "Invalid request body",
        "errors": [...]
    }

    Error codes:

    • 400 - Bad Request: Missing required parameters or invalid request body.

    Schemas

    Oxide Role Schema

    {
        "steamId": "string",
        "role": "string",
        "action": "added" | "revoked"
    }

    Discord Role Schema

    {
        "discordGuildId": "string",
        "userId": "string",
        "role": "string",
        "action": "added" | "revoked"
    }

    user/discord/[id]

    Discord Account Retrieval

    Endpoint

    GET /api/discord/account/{id}

    Description

    Retrieves the Discord account information linked to a given Discord account ID. This includes user details, linked Steam account information, and user roles.

    Parameters

    Parameter Type Description
    id string The unique identifier for the Discord account.

    Responses

    Success Response

    On success, returns a JSON object with user details.

    {
        "user": {
            "id": "string",
            "name": "string",
            "image": "string",
            "steamId": "string | null",
            "boostedGuilds": ["string"],
            "isLinked": true,
            "storeId": "string | null",
            "joinedSteamGroup": true,
            "roles": [
                {
                    "name": "string",
                    "serverId": "string",
                    "oxideGroupName": "string",
                    "discordAssociations": [
                        {
                            "discordGuild": "string",
                            "discordRole": "string"
                        }
                    ]
                }
            ]
        }
    }
        

    Error Responses

    Status Code Message Description
    204 {"success": false, "message": "Discord account not found"} No Discord account found for the provided ID.
    500 {"message": "Internal server error"} An unexpected error occurred while processing the request.

    Example Request

    GET /api/discord/account/1234567890
        

    Example Successful Response

    {
        "user": {
            "id": "1234567890",
            "name": "John Doe",
            "image": "https://example.com/image.png",
            "steamId": "76561198012345678",
            "boostedGuilds": ["guild1", "guild2"],
            "isLinked": true,
            "storeId": "store123",
            "joinedSteamGroup": true,
            "roles": [
                {
                    "name": "Admin",
                    "serverId": "server123",
                    "oxideGroupName": "oxideGroup1",
                    "discordAssociations": [
                        {
                            "discordGuild": "guild1",
                            "discordRole": "role1"
                        }
                    ]
                }
            ]
        }
    }
        

    user/nitro

    Discord Nitro User API

    This API allows you to manage Discord Nitro users and their boosted guilds.


    Endpoints

    GET /api/nitro-user

    Retrieve boosted guilds for a specific Discord user.

    Query Parameters

    • discordId (string, required): The Discord ID of the user.

    Responses

    
    {
        "success": true,
        "guilds": ["guildId1", "guildId2"]
    }
            

    If no guilds are boosted:

    
    {
        "success": true,
        "guilds": []
    }
            

    If the user is not found:

    
    {
        "success": false,
        "message": "User not found"
    }
            

    If discordId is missing:

    
    {
        "success": false,
        "message": "Missing discordId"
    }
            

    POST /api/nitro-user

    Add a boosted guild for a specific Discord user.

    Request Body

    
    {
        "guildId": "guildId1",
        "discordId": "discordId1"
    }
            

    Responses

    On success:

    
    {
        "success": true
    }
            

    If any required field is missing:

    
    {
        "success": false,
        "message": "Missing guildId or discordId"
    }
            

    If the user is not found:

    
    {
        "success": false,
        "message": "User not found"
    }
            

    If there is an error updating the user:

    
    {
        "success": false,
        "message": "Error updating user"
    }
            

    DELETE /api/nitro-user

    Remove a boosted guild from a specific Discord user.

    Query Parameters

    • guildId (string, required): The ID of the guild to remove.
    • discordId (string, required): The Discord ID of the user.

    Responses

    On success:

    
    {
        "success": true
    }
            

    If any required field is missing:

    
    {
        "success": false,
        "message": "Missing discordId or guildId"
    }
            

    If the user is not found:

    
    {
        "success": false,
        "message": "User not found"
    }
            

    If there is an error updating the user:

    
    {
        "success": false,
        "message": "Error updating user"
    }
            

    user/search/[id]

    User Accounts API

    Get User Accounts

    Retrieve user accounts based on user ID or provider account ID.

    Endpoint

    GET /api/users/{id}

    Parameters

    Parameter Type Description
    id string The user ID or provider account ID to search for.

    Responses

    Success Response

    {
        "users": [
            {
                "id": "user-id-1",
                "name": "User Name",
                "image": "http://example.com/image.jpg",
                "boostedGuilds": ["guild-id-1", "guild-id-2"],
                "steamId": "steam-account-id",
                "discordId": "discord-account-id",
                "isLinked": true,
                "scrap": true,
                "storeId": "store-id",
                "joinedSteamGroup": true,
                "roles": [
                    {
                        "name": "Admin",
                        "serverId": "server-id",
                        "oxideGroupName": "oxide-group",
                        "discordAssociations": [
                            {
                                "discordGuild": "guild-id",
                                "discordRole": "role-id"
                            }
                        ]
                    }
                ]
            }
        ]
    }
        

    Error Responses

    Status Code Description Response
    204 No accounts found
    {
        "success": false,
        "message": "No accounts with this id has been found"
    }
    500 Internal server error
    {
        "message": "Internal server error"
    }

    Example Request

    GET /api/users/user-id-1

    Notes

    Ensure that the user ID or provider account ID exists in the database to receive a successful response.

    user/session

    Get User Roles and Session Information

    This API endpoint retrieves the roles and session information for the authenticated user.

    Endpoint

    GET /api/user/roles

    HTTP Method

    GET

    Authentication

    This endpoint requires authentication via a session token stored in cookies.

    Request Parameters

    No query parameters are required for this endpoint.

    Request Headers

    • Cookie: Contains the session token.

    Expected Responses

    Successful Response

    {
        "roles": [
            {
                "id": "1",
                "name": "Admin",
                "permissions": ["read", "write", "delete"]
            },
            {
                "id": "2",
                "name": "User",
                "permissions": ["read"]
            }
        ],
        "twoFAVerified": true,
        "is2FAEnabled": true
    }
        

    Status Code: 200 OK

    Unauthorized Response

    {
        "error": "Unauthorized"
    }
        

    Status Code: 401 Unauthorized

    Error Response

    {
        "error": "Failed to retrieve session and roles"
    }
        

    Status Code: 500 Internal Server Error

    Error Codes

    • 401 - Unauthorized: The user is not authenticated or the session token is missing/invalid.
    • 500 - Internal Server Error: An error occurred while processing the request.

    Example Request

    GET /api/user/roles
    Cookie: next-auth.session-token=exampleSessionToken
        

    Notes

    Ensure that the session token is valid and that the user is authenticated before making a request to this endpoint.

    user/steam/[id]

    Steam Account API Documentation

    This API allows you to retrieve information about Steam accounts linked to users in the system.

    Endpoint

    GET /api/steam/{id}

    Parameters

    Parameter Type Description
    id string The unique identifier for the Steam account.
    type string (optional) Specifies the type of data to return. If set to 'oxidegroups', it filters roles by server.
    server string (optional) The server ID to filter oxide groups when type is 'oxidegroups'.

    Responses

    Success Response

    
    {
        "user": {
            "id": "string",
            "name": "string",
            "image": "string",
            "boostedGuilds": ["string"],
            "isLinked": true,
            "storeId": "string",
            "joinedSteamGroup": true,
            "steamId": "string",
            "roles": [
                {
                    "name": "string",
                    "serverId": "string",
                    "oxideGroupName": "string",
                    "discordAssociations": [
                        {
                            "discordGuild": "string",
                            "discordRole": "string"
                        }
                    ]
                }
            ]
        }
    }
        

    Empty Response

    
    {
        "success": false,
        "message": "Steam account not found"
    }
        

    Error Response

    
    {
        "message": "Internal server error"
    }
        

    Example Request

    
    GET /api/steam/1234567890?type=oxidegroups&server=serverId123
        

    Error Codes

    Status Code Description
    204 No content, Steam account not found.
    500 Internal server error, unable to fetch user data.

    user/unlink

    Discord Account Unlinking API

    Endpoint

    DELETE /api/unlink-discord

    Description

    This endpoint allows users to unlink their Discord account from the application. The user must be authenticated to perform this action.

    Authentication

    This endpoint requires user authentication. A valid session must be present; otherwise, it will return an unauthorized error.

    Request

    Method: DELETE

    URL: /api/unlink-discord

    Headers:

    • Authorization: Bearer <token>

    Response

    Success Responses:

    
    {
        "success": true
    }
    

    No Discord Account Found:

    
    {
        "success": false,
        "message": "Discord account not found"
    }
    

    Error Responses:

    
    {
        "success": false,
        "message": "Error unlinking discord account"
    }
    

    HTTP Status Codes

    • 200 OK: Successfully unlinked the Discord account.
    • 204 No Content: No Discord account found for the user.
    • 401 Unauthorized: User is not authenticated.
    • 500 Internal Server Error: An error occurred while unlinking the Discord account.

    Example Request

    
    DELETE /api/unlink-discord
    Authorization: Bearer your_access_token
    

    Example Response

    
    {
        "success": true
    }
    

    vote

    Voting API Documentation

    This API allows users to cast their votes for map options and retrieve their voting history.


    Endpoints

    POST /api/vote

    Cast a vote for a specific map option.

    Request

    {
        "vote_id": "string",
        "map_option_id": "string"
    }

    Parameters

    • vote_id (string): The ID of the vote.
    • map_option_id (string): The ID of the map option being voted for.

    Responses

    200 OK

    {
        "message": "Your vote has been recorded"
    }

    400 Bad Request

    {
        "error": "Missing vote_id or map_option_id"
    }
    {
        "error": "You have already voted for this map"
    }

    401 Unauthorized

    {
        "error": "Unauthorized"
    }

    204 No Content

    {
        "error": "Vote not found"
    }
    {
        "error": "Map option not found"
    }

    GET /api/vote

    Retrieve the user's voting history.

    Responses

    200 OK

    [
        {
            "vote_id": "string",
            "vote_option_id": "string",
            "user_id": "string"
        },
        ...
    ]

    401 Unauthorized

    {
        "error": "Unauthorized"
    }

    Authentication

    All requests require user authentication. Ensure that the user is logged in to access the endpoints.


    Error Codes

    Status Code Description
    200 Request succeeded.
    204 No content available.
    400 Bad request due to missing parameters or duplicate votes.
    401 Unauthorized access.