API Examples

Common use cases for the RespawnHost API.

List Your Servers

curl -X GET "https://api.respawnhost.com/api/servers" \
  -H "Authorization: Bearer YOUR_API_KEY"

Get Server Details

Retrieve details for a specific server by UUID:

curl -X GET "https://api.respawnhost.com/api/servers/{uuid}" \
  -H "Authorization: Bearer YOUR_API_KEY"

Control Server Power State

Start, stop, restart, or kill a server:

curl -X POST "https://api.respawnhost.com/api/servers/{uuid}/powerstate" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"signal": "start"}'

Available signals: start, stop, restart, kill

Send Console Command

Execute a command on your running server:

curl -X POST "https://api.respawnhost.com/api/servers/{uuid}/send-command" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"command": "say Hello from the API!"}'

Create a Backup

curl -X POST "https://api.respawnhost.com/api/servers/{uuid}/backups" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "pre-update-backup"}'

List Backups

curl -X GET "https://api.respawnhost.com/api/servers/{uuid}/backups" \
  -H "Authorization: Bearer YOUR_API_KEY"

Restore a Backup

curl -X POST "https://api.respawnhost.com/api/servers/{uuid}/backups/{backupId}/restore" \
  -H "Authorization: Bearer YOUR_API_KEY"

Add ?truncate=true to delete existing files before restoring.

List Files

curl -X GET "https://api.respawnhost.com/api/servers/{uuid}/files?directory=/" \
  -H "Authorization: Bearer YOUR_API_KEY"

Read File Content

curl -X GET "https://api.respawnhost.com/api/servers/{uuid}/files/content?file=/server.properties" \
  -H "Authorization: Bearer YOUR_API_KEY"

Write File Content

curl -X POST "https://api.respawnhost.com/api/servers/{uuid}/files/write?file=/motd.txt" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: text/plain" \
  -d "Welcome to the server!"

Update Server Alias

curl -X PUT "https://api.respawnhost.com/api/servers/{uuid}/alias" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"alias": "My Minecraft Server"}'

Create a Database

curl -X POST "https://api.respawnhost.com/api/servers/{uuid}/databases" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "mydb"}'

Get WebSocket Connection

For real-time console output, request WebSocket credentials:

curl -X GET "https://api.respawnhost.com/api/servers/{uuid}/websocket" \
  -H "Authorization: Bearer YOUR_API_KEY"

This returns the WebSocket URL and authentication token for connecting to the live console.

More Endpoints

For the complete list of endpoints, request/response schemas, and the ability to test requests directly, visit the API Reference.