RESTful API

Introduction

The Trooper AI API provides comprehensive access to GPU server management, including server provisioning, monitoring, migration, and administrative functions. This RESTful API allows you to programmatically manage your GPU infrastructure, create and monitor server orders, handle templates, and perform administrative tasks.

API endpoints and the API documentation are currently in Beta. Contact us with any issues: Support Contacts.

You find your API key at the API Console.

Try Out API Console

Pro Tip: Just give this documentation to your Development LLM Agent and it will integrate it into your code.

Base URL

Code
https://james.trooper.ai

Authentication

Most endpoints require Bearer token authentication using your Trooper API key:

http
Authorization: Bearer YOUR_API_KEY

Get your API key from the API Console.

Response Format

All API responses are in JSON format. Successful responses typically include:

Error responses include:


Public Endpoints

Get Test Status

GET /api/test

Simple test endpoint to verify API connectivity.

Request

http
GET /api/test

Success Response (200)

json
{
  "test": "meinstring5"
}

Get Available GPU Servers (Public)

GET /api/blibs

Retrieve all publicly available GPU server configurations.

Request

http
GET /api/blibs
Authorization: Bearer YOUR_API_KEY  # Optional - includes your private networks if provided

Success Response (200)

json
[
  {
    "id": 1,
    "name": "powerai.example",
    "gpu_type": "RTX 4090",
    "gpu_num": 1,
    "gpu_ram": 24,
    "cpu_cores": 8,
    "cpu_ram": 32,
    "hdd": 500,
    "price_h": 0.85,
    "is_public": 1,
    "country_code": "DE",
    "is_available": true,
    "available_hosts": ["ai18", "ai89"],
    "fitCount": 2,
    "maxPossibleInstances": 5
  }
]

Error Response (500)

json
{
  "error": "Error fetching Blibs"
}

Authentication Required Endpoints

Get Private GPU Servers

GET /api/blibs-private

Retrieve GPU servers accessible to your account, including private configurations.

Request

http
GET /api/blibs-private
Authorization: Bearer YOUR_API_KEY

Success Response (200)

json
[
  {
    "id": 2,
    "name": "RTX 4090 Dual Private",
    "gpu_type": "RTX 4090",
    "gpu_num": 2,
    "gpu_ram": 24,
    "cpu_cores": 16,
    "cpu_ram": 64,
    "hdd": 1000,
    "price_h": 1.65,
    "is_public": 1,
    "country_code": "DE"
  }
]

Error Response (401)

json
{
  "error": "Missing or invalid Authorization header"
}

Create Server Order

POST /api/order

Create a new GPU server order. You must submit the price provided, otherwise the order will not be accepted. This makes sure the current price matches your expectations!

Open API Console & Try Out

Request

http
POST /api/order
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

Request Body

json
{
  "blib_id": 1,
  "price_h": 0.85,
  "total_price": 0.85,
  "terms_accepted": true,
  "contract_interval": "HOUR",
  "second_partition_percentage": 20,
  "templates": [
    {
      "id": 1,
      "name": "PyTorch Environment"
    }
  ]
}

Success Response (200)

json
{
  "success": true,
  "orderId": 123
}

Error Response (400)

json
{
  "error": "You must accept the terms and conditions."
}

Error Response (400)

json
{
  "error": "Invalid or missing contract interval."
}

Get Your Server Orders

GET /api/orders

Retrieve all your server orders with detailed information.

When handling server statuses, consider the interplay between desired_status and current_status. For example, a server might have a desired_status of “stopped”, but its current_status could still be “running” if the stop process is in progress. Your application should account for these transitions and handle them accordingly.

Request

http
GET /api/orders
Authorization: Bearer YOUR_API_KEY

Query Parameters

Success Response (200)

json
[
  {
    "order_id": 123,
    "serverId": 123,
    "title": "My PyTorch Server",
    "status": "running",
    "status_user": "running",
    "server_name": "gpu-server-01",
    "machine_name": "ai99_trooperai_000123",
    "ip": "192.168.1.100",
    "ssh_port": 22001,
    "price_h": 0.85,
    "paid_until": "2025-09-26T14:30:00.000Z",
    "contract_interval": "HOUR",
    "is_locked": false,
    "is_low_priority": false,
    "blib_name": "RTX 4090 Single",
    "blib_gpu_type": "RTX 4090",
    "blib_gpu_num": 1,
    "country_code": "DE",
    "template_installs": [
      {
        "id": 1,
        "template_name": "PyTorch Environment",
        "status": 1,
        "status_readable": "Completed"
      }
    ]
  }
]

Error Response (401)

json
{
  "error": "Missing or invalid Authorization header",
  "next": "login"
}

Update Server Status

POST /api/order-status

Update your server order status (running, stopped, restarted, frozen).

Set "migration_allowed": true if you approve host migration when transitioning from a frozen to running state. This process may take 10–90 minutes and will change the Ports Range and potentially the CPU model/speed.

Request

http
POST /api/order-status
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

Request Body

json
{
  "serverId": 123,
  "action": "running",
  "migration_allowed": false
}

Success Response (200)

json
{
  "success": true,
  "message": "Server start initiated successfully",
  "status": "starting"
}

Error Response (403)

json
{
  "success": false,
  "error": "Server is locked and cannot be modified"
}

Update Server Title

POST /api/order-title

Update the display title of your server.

Request

http
POST /api/order-title
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

Request Body

json
{
  "serverId": 123,
  "title": "My New Server Title"
}

Success Response (200)

json
{
  "success": true,
  "message": "Title updated successfully"
}

Lock/Unlock Server

POST /api/order-lock

Lock or unlock a server to prevent/allow status changes.

Request

http
POST /api/order-lock
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

Request Body

json
{
  "serverId": 123,
  "is_locked": true
}

Success Response (200)

json
{
  "success": true,
  "updated": 1
}

Get Server Credentials

POST /api/credentials

Retrieve SSH credentials and connection details for your server.

Request

http
POST /api/credentials
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

Request Body

json
{
  "serverId": 123
}

Success Response (200)

json
{
  "success": true,
  "ip": "192.168.1.100",
  "ssh_port": 22001,
  "username": "root",
  "password": "generated-password",
  "status": "running"
}

Error Response (403)

json
{
  "error": "Access denied or server not found"
}

Get Server Status History

GET /api/order-status-history

Get the last 5 status changes for a server order.

Request

http
GET /api/order-status-history?order_id=123
Authorization: Bearer YOUR_API_KEY

Success Response (200)

json
{
  "success": true,
  "history": [
    {
      "id": 1,
      "status_user": "running",
      "status_txt": "Server started successfully",
      "status_since": "2025-09-25T10:30:00.000Z"
    },
    {
      "id": 2,
      "status_user": "stopped",
      "status_txt": "Server stopped by user",
      "status_since": "2025-09-25T08:15:00.000Z"
    }
  ]
}

Migration Endpoints

Migration is used to bring your GPU server to a different configuration. We don’t recommend to use this for production. But you can try if you like!

Get Migration Options

GET /api/migration-options

Get available server configurations for migration.

Request

http
GET /api/migration-options?order_id=123
Authorization: Bearer YOUR_API_KEY

Success Response (200)

json
{
  "success": true,
  "currentOrder": {
    "id": 123,
    "title": "My Server",
    "status": "running",
    "contract_interval": "HOUR",
    "paid_until": "2025-09-26T14:30:00.000Z"
  },
  "currentBlib": {
    "id": 1,
    "name": "RTX 4090 Single",
    "gpu_type": "RTX 4090",
    "gpu_num": 1,
    "price_h": 0.85
  },
  "availableBlibs": [
    {
      "id": 2,
      "name": "RTX 4090 Dual",
      "gpu_type": "RTX 4090",
      "gpu_num": 2,
      "price_h": 1.65,
      "is_available": true,
      "additionalCostPerCycle": 0.80
    }
  ]
}

Calculate Migration Cost

POST /api/migration-cost

Calculate the cost for migrating to a different server configuration.

Request

http
POST /api/migration-cost
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

Request Body

json
{
  "order_id": 123,
  "target_blib_id": 2
}

Success Response (200)

json
{
  "success": true,
  "upgradeCost": 15.50,
  "remainingValue": 12.30,
  "totalDue": 3.20,
  "additionalCostPerCycle": 0.80,
  "nextBillingDate": "2025-09-26T14:30:00.000Z",
  "currentRate": {
    "amount": 0.85,
    "display": "€0.85/hour"
  },
  "newRate": {
    "amount": 1.65,
    "display": "€1.65/hour"
  }
}

Execute Migration

POST /api/buy-migration

Execute the migration to a new server configuration.

IMPORTANT If you pass invalid data here, nothing is guaranteed. Support team can not restore your order if you missuse this endpoint for buying migrations. We recommend using the UI Dashboard.

Request

http
POST /api/buy-migration
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

Request Body

json
{
  "order_id": 123,
  "target_blib_id": 2,
  "keep_data": true
}

Success Response (200)

json
{
  "success": true,
  "message": "Migration initiated successfully",
  "new_order_id": 124
}

Error Response (400)

json
{
  "error": "Insufficient budget for migration"
}

Template Management

Get Available Templates

GET /api/templates

Get all available software templates.

Request

http
GET /api/templates
Authorization: Bearer YOUR_API_KEY  # Optional

Success Response (200)

json
[
  {
    "id": 1,
    "name": "PyTorch Environment",
    "description": "Pre-configured PyTorch environment with CUDA support",
    "category": "Machine Learning",
    "is_public": true,
    "options": [
      {
        "id": 1,
        "name": "Python Version",
        "type": "select",
        "default_value": "3.9",
        "possible_values": "3.8,3.9,3.10"
      }
    ]
  }
]

Get Template Configuration

GET /api/template-config

Get template installation configuration for a specific order.

Request

http
GET /api/template-config?order_id=123
Authorization: Bearer YOUR_API_KEY

Success Response (200)

json
{
  "success": true,
  "templates": [
    {
      "install_id": 1,
      "template_id": 1,
      "template_name": "PyTorch Environment",
      "status": 1,
      "status_readable": "Completed",
      "config": {
        "python_version": "3.9"
      }
    }
  ]
}

Install Template

POST /api/template-install-add

Install a new template on your server.

Request

http
POST /api/template-install-add
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

Request Body

json
{
  "order_id": 123,
  "template_id": 1,
  "config": {
    "python_version": "3.9"
  }
}

Success Response (200)

json
{
  "success": true,
  "install_id": 5,
  "message": "Template installation queued"
}

Remove Template

POST /api/template-install-delete

Remove a template installation from your server.

Request

http
POST /api/template-install-delete
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

Request Body

json
{
  "install_id": 5
}

Success Response (200)

json
{
  "success": true,
  "message": "Template removal initiated"
}

Retry Template Installation

POST /api/template-install-retry

Retry a failed template installation.

Request

http
POST /api/template-install-retry
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

Request Body

json
{
  "install_id": 5
}

Success Response (200)

json
{
  "success": true,
  "message": "Template installation retry initiated"
}

Error Codes

HTTP Status Codes

Common Error Messages


Rate Limiting

API endpoints may be rate-limited to prevent abuse. If you exceed the rate limit, you’ll receive a 429 status code. Implement appropriate retry logic with exponential backoff.

Support

For API support and questions, contact: support@trooper.ai

Open API Console


For any question related to the API please contact us: Support Contacts