Skip to content

API Endpoints

BadgerPanel provides a comprehensive REST API for managing all aspects of the platform. This page covers the API conventions, response format, pagination, and provides an overview of the major endpoint groups.

Base URL

All API endpoints are prefixed with /api/v1:

https://panel.your-domain.com/api/v1

Request Format

Headers

HeaderRequiredDescription
AuthorizationYesBearer <token> (JWT access token or API key)
Content-TypeFor POST/PUT/PATCHapplication/json
AcceptNoapplication/json (default)

Example Request

bash
curl -X GET "https://panel.your-domain.com/api/v1/servers" \
  -H "Authorization: Bearer bp_your-api-key" \
  -H "Accept: application/json"

Response Format

All API responses follow a consistent JSON structure.

Successful Response (Single Resource)

json
{
  "data": {
    "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "name": "My Minecraft Server",
    "status": "running",
    "memory": 2048,
    "cpu": 200,
    "disk": 10240,
    "created_at": "2025-01-15T10:30:00Z",
    "updated_at": "2025-01-15T12:45:00Z"
  }
}

Successful Response (List)

json
{
  "data": [
    {
      "id": "a1b2c3d4-...",
      "name": "Server 1"
    },
    {
      "id": "b2c3d4e5-...",
      "name": "Server 2"
    }
  ],
  "meta": {
    "current_page": 1,
    "per_page": 25,
    "total": 42,
    "total_pages": 2
  }
}

Error Response

json
{
  "error": {
    "code": "not_found",
    "message": "The requested server was not found.",
    "details": {}
  }
}

Validation Error Response

json
{
  "error": {
    "code": "validation_error",
    "message": "The request body contains invalid data.",
    "details": {
      "name": ["Name is required."],
      "memory": ["Memory must be at least 128 MB."]
    }
  }
}

HTTP Status Codes

CodeMeaningDescription
200OKSuccessful GET, PUT, PATCH, or DELETE
201CreatedSuccessful POST that created a resource
204No ContentSuccessful DELETE with no response body
400Bad RequestMalformed request or validation error
401UnauthorizedMissing or invalid authentication
403ForbiddenAuthenticated but lacking permission
404Not FoundResource does not exist
409ConflictResource conflict (e.g., duplicate)
422Unprocessable EntityValidation error with details
429Too Many RequestsRate limit exceeded
500Internal Server ErrorUnexpected server error

Pagination

All list endpoints support pagination via query parameters:

ParameterDescriptionDefault
pagePage number (1-indexed)1
per_pageItems per page (max 100)25
bash
# Get page 2 with 50 items per page
curl "https://panel.your-domain.com/api/v1/servers?page=2&per_page=50" \
  -H "Authorization: Bearer bp_your-api-key"

The response includes a meta object with pagination info:

json
{
  "meta": {
    "current_page": 2,
    "per_page": 50,
    "total": 120,
    "total_pages": 3
  }
}

Filtering & Sorting

Many list endpoints support filtering and sorting:

bash
# Filter by status
curl "https://panel.your-domain.com/api/v1/servers?status=running"

# Search by name
curl "https://panel.your-domain.com/api/v1/servers?search=minecraft"

# Sort by creation date (descending)
curl "https://panel.your-domain.com/api/v1/servers?sort=-created_at"
  • Prefix sort fields with - for descending order
  • Multiple sort fields can be comma-separated: sort=-created_at,name

Client API Endpoints

These endpoints are available to authenticated users for managing their own resources.

Servers

MethodEndpointDescription
GET/api/v1/serversList your servers
GET/api/v1/servers/{id}Get server details
GET/api/v1/servers/{id}/resourcesGet live resource usage
POST/api/v1/servers/{id}/powerSend power action (start, stop, restart, kill)
POST/api/v1/servers/{id}/commandSend console command

Power Actions

bash
# Start a server
curl -X POST "https://panel.your-domain.com/api/v1/servers/{id}/power" \
  -H "Authorization: Bearer bp_your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"action": "start"}'

Valid actions: start, stop, restart, kill

Send Console Command

bash
curl -X POST "https://panel.your-domain.com/api/v1/servers/{id}/command" \
  -H "Authorization: Bearer bp_your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"command": "say Hello from the API!"}'

Files

MethodEndpointDescription
GET/api/v1/servers/{id}/files/listList directory contents
GET/api/v1/servers/{id}/files/contentsGet file contents
PUT/api/v1/servers/{id}/files/writeWrite/update a file
POST/api/v1/servers/{id}/files/create-directoryCreate a directory
POST/api/v1/servers/{id}/files/renameRename a file or directory
POST/api/v1/servers/{id}/files/copyCopy a file
POST/api/v1/servers/{id}/files/deleteDelete files
bash
# List files in the root directory
curl "https://panel.your-domain.com/api/v1/servers/{id}/files/list?directory=/" \
  -H "Authorization: Bearer bp_your-api-key"

Databases

MethodEndpointDescription
GET/api/v1/servers/{id}/databasesList server databases
POST/api/v1/servers/{id}/databasesCreate a database
DELETE/api/v1/servers/{id}/databases/{db-id}Delete a database
POST/api/v1/servers/{id}/databases/{db-id}/rotate-passwordRotate password

Backups

MethodEndpointDescription
GET/api/v1/servers/{id}/backupsList backups
POST/api/v1/servers/{id}/backupsCreate a backup
GET/api/v1/servers/{id}/backups/{backup-id}/downloadDownload a backup
POST/api/v1/servers/{id}/backups/{backup-id}/restoreRestore a backup
DELETE/api/v1/servers/{id}/backups/{backup-id}Delete a backup
POST/api/v1/servers/{id}/backups/{backup-id}/lockLock/unlock a backup

Schedules

MethodEndpointDescription
GET/api/v1/servers/{id}/schedulesList schedules
POST/api/v1/servers/{id}/schedulesCreate a schedule
PUT/api/v1/servers/{id}/schedules/{schedule-id}Update a schedule
DELETE/api/v1/servers/{id}/schedules/{schedule-id}Delete a schedule
POST/api/v1/servers/{id}/schedules/{schedule-id}/executeExecute now

Subusers

MethodEndpointDescription
GET/api/v1/servers/{id}/subusersList subusers
POST/api/v1/servers/{id}/subusersInvite a subuser
PUT/api/v1/servers/{id}/subusers/{subuser-id}Update permissions
DELETE/api/v1/servers/{id}/subusers/{subuser-id}Remove a subuser

Account

MethodEndpointDescription
GET/api/v1/accountGet account details
PUT/api/v1/accountUpdate profile
PUT/api/v1/account/passwordChange password
GET/api/v1/account/api-keysList API keys
POST/api/v1/account/api-keysCreate an API key
DELETE/api/v1/account/api-keys/{key-id}Delete an API key
GET/api/v1/account/sessionsList active sessions
DELETE/api/v1/account/sessions/{session-id}Revoke a session

Billing (Client)

MethodEndpointDescription
GET/api/v1/store/productsList available products
GET/api/v1/store/products/{id}Get product details
GET/api/v1/store/cartGet shopping cart
POST/api/v1/store/cartAdd item to cart
DELETE/api/v1/store/cart/{item-id}Remove cart item
POST/api/v1/store/checkoutProcess checkout
POST/api/v1/store/couponApply coupon code
GET/api/v1/billing/invoicesList your invoices
GET/api/v1/billing/invoices/{id}Get invoice details
GET/api/v1/billing/servicesList your services
GET/api/v1/billing/creditsGet credit balance

Admin API Endpoints

These endpoints require admin permissions (accessible to users with the appropriate role).

Admin: Servers

MethodEndpointDescription
GET/api/v1/admin/serversList all servers
POST/api/v1/admin/serversCreate a server
GET/api/v1/admin/servers/{id}Get server details
PUT/api/v1/admin/servers/{id}Update server
DELETE/api/v1/admin/servers/{id}Delete a server
POST/api/v1/admin/servers/{id}/suspendSuspend a server
POST/api/v1/admin/servers/{id}/unsuspendUnsuspend a server
POST/api/v1/admin/servers/{id}/reinstallReinstall a server
POST/api/v1/admin/servers/{id}/transferMigrate a server

Create a Server

bash
curl -X POST "https://panel.your-domain.com/api/v1/admin/servers" \
  -H "Authorization: Bearer bp_your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My Server",
    "user_id": "user-uuid",
    "node_id": "node-uuid",
    "egg_id": "egg-uuid",
    "allocation_id": "allocation-uuid",
    "memory": 2048,
    "cpu": 200,
    "disk": 10240,
    "swap": 0,
    "io": 500,
    "databases_limit": 2,
    "backups_limit": 3,
    "allocations_limit": 1
  }'

Admin: Users

MethodEndpointDescription
GET/api/v1/admin/usersList all users
POST/api/v1/admin/usersCreate a user
GET/api/v1/admin/users/{id}Get user details
PUT/api/v1/admin/users/{id}Update user
DELETE/api/v1/admin/users/{id}Delete user

Admin: Nodes

MethodEndpointDescription
GET/api/v1/admin/nodesList all nodes
POST/api/v1/admin/nodesCreate a node
GET/api/v1/admin/nodes/{id}Get node details
PUT/api/v1/admin/nodes/{id}Update a node
DELETE/api/v1/admin/nodes/{id}Delete a node
GET/api/v1/admin/nodes/{id}/allocationsList allocations
POST/api/v1/admin/nodes/{id}/allocationsCreate allocations
DELETE/api/v1/admin/nodes/{id}/allocations/{alloc-id}Delete allocation

Admin: Nests & Eggs

MethodEndpointDescription
GET/api/v1/admin/nestsList nests
POST/api/v1/admin/nestsCreate a nest
GET/api/v1/admin/nests/{id}Get nest details
GET/api/v1/admin/nests/{id}/eggsList eggs in a nest
POST/api/v1/admin/nests/{id}/eggsCreate an egg
GET/api/v1/admin/eggs/{id}Get egg details
PUT/api/v1/admin/eggs/{id}Update an egg
POST/api/v1/admin/eggs/importImport egg from JSON
GET/api/v1/admin/eggs/{id}/exportExport egg as JSON

Admin: Billing

MethodEndpointDescription
GET/api/v1/admin/billing/productsList products
POST/api/v1/admin/billing/productsCreate a product
PUT/api/v1/admin/billing/products/{id}Update a product
DELETE/api/v1/admin/billing/products/{id}Delete a product
GET/api/v1/admin/billing/ordersList all orders
GET/api/v1/admin/billing/invoicesList all invoices
GET/api/v1/admin/billing/servicesList all services
GET/api/v1/admin/billing/couponsList coupons
POST/api/v1/admin/billing/couponsCreate a coupon

Admin: Roles

MethodEndpointDescription
GET/api/v1/admin/rolesList roles
POST/api/v1/admin/rolesCreate a role
PUT/api/v1/admin/roles/{id}Update a role
DELETE/api/v1/admin/roles/{id}Delete a role

Admin: Settings

MethodEndpointDescription
GET/api/v1/admin/settingsGet all settings
PUT/api/v1/admin/settingsUpdate settings
POST/api/v1/admin/settings/email/testSend test email

WebSocket Endpoints

Real-time features use WebSocket connections.

Server Console

wss://panel.your-domain.com/api/v1/servers/{id}/ws

Connect via WebSocket to receive real-time console output and send commands:

javascript
const ws = new WebSocket(
  'wss://panel.your-domain.com/api/v1/servers/{id}/ws',
  { headers: { 'Authorization': 'Bearer your-token' } }
);

// Receive console output
ws.onmessage = (event) => {
  const data = JSON.parse(event.data);
  if (data.type === 'console_output') {
    console.log(data.message);
  }
  if (data.type === 'stats') {
    console.log('CPU:', data.cpu, 'Memory:', data.memory);
  }
  if (data.type === 'status') {
    console.log('Server status:', data.status);
  }
};

// Send a command
ws.send(JSON.stringify({
  type: 'command',
  command: 'say Hello from WebSocket!'
}));

// Send a power action
ws.send(JSON.stringify({
  type: 'power',
  action: 'restart'
}));

WebSocket Message Types (Received):

TypeDescription
console_outputLine of console output from the server
statsResource usage update (CPU, memory, disk, network)
statusServer status change (starting, running, stopping, offline)
install_outputInstallation progress output

WebSocket Message Types (Sent):

TypeDescription
commandSend a command to the server console
powerSend a power action (start, stop, restart, kill)

Error Handling

Common Error Codes

CodeHTTP StatusDescription
unauthorized401Authentication required or token expired
forbidden403Insufficient permissions
not_found404Resource does not exist
validation_error422Request body failed validation
rate_limit_exceeded429Too many requests
internal_error500Unexpected server error
server_offline409Server is not running (for console/command)
server_locked409Server is locked by another operation

Error Handling Example

python
import requests

response = requests.get(
    "https://panel.your-domain.com/api/v1/servers/invalid-id",
    headers={"Authorization": "Bearer bp_your-api-key"}
)

if response.status_code == 200:
    server = response.json()["data"]
elif response.status_code == 401:
    print("Authentication failed - check your API key")
elif response.status_code == 403:
    print("Permission denied")
elif response.status_code == 404:
    print("Server not found")
elif response.status_code == 429:
    retry_after = response.headers.get("Retry-After", 60)
    print(f"Rate limited - retry after {retry_after} seconds")
else:
    error = response.json().get("error", {})
    print(f"Error: {error.get('message', 'Unknown error')}")

Next Steps

BadgerPanel Documentation