AI AdminPanel Documentation

Services API

The Services API manages the full lifecycle of deployed services: creation, deployment, lifecycle control, monitoring, and deletion.

List Services

GET /api/services

Returns a paginated list of services.

Query Parameters:

ParameterDescription
pagePage number (default: 1)
per_pageItems per page (default: 20, max: 100)
statusFilter by status: running, stopped, deploying, failed
customer_idFilter by customer ID
sortSort by: name, status, created_at, updated_at
orderSort order: asc, desc
searchSearch by service name

Request:

curl https://panel.example.com/api/services?status=running&per_page=10 \
  -H "Authorization: Bearer aap_k1_..."

Response: 200 OK

{
  "data": [
    {
      "id": "svc_abc123",
      "name": "my-app",
      "status": "running",
      "url": "https://my-app.panel.example.com",
      "customer_id": "cust_def456",
      "template": "uptime-kuma",
      "deploy_method": "template",
      "created_at": "2026-03-29T10:00:00Z",
      "updated_at": "2026-03-29T10:05:00Z",
      "resources": {
        "cpu_usage": 0.15,
        "memory_usage_mb": 128,
        "memory_limit_mb": 512
      }
    }
  ],
  "total": 42,
  "page": 1,
  "per_page": 10
}

Get Service

GET /api/services/:id

Returns detailed information about a single service.

Request:

curl https://panel.example.com/api/services/svc_abc123 \
  -H "Authorization: Bearer aap_k1_..."

Response: 200 OK

{
  "id": "svc_abc123",
  "name": "my-app",
  "status": "running",
  "url": "https://my-app.panel.example.com",
  "customer_id": "cust_def456",
  "customer_name": "Acme Corp",
  "template": "uptime-kuma",
  "deploy_method": "template",
  "compose": "version: '3.8'\nservices:\n  ...",
  "variables": {
    "SERVICE_NAME": "my-app"
  },
  "custom_domains": [],
  "resources": {
    "cpu_usage": 0.15,
    "cpu_limit": 1.0,
    "memory_usage_mb": 128,
    "memory_limit_mb": 512,
    "storage_mb": 256
  },
  "health": {
    "status": "healthy",
    "last_check": "2026-03-29T14:30:00Z",
    "consecutive_failures": 0
  },
  "created_at": "2026-03-29T10:00:00Z",
  "updated_at": "2026-03-29T10:05:00Z",
  "deployed_at": "2026-03-29T10:05:00Z"
}

Create and Deploy Service

POST /api/services

Creates and deploys a new service. The request body varies by deployment method.

Template Deploy

curl -X POST https://panel.example.com/api/services \
  -H "Authorization: Bearer aap_k1_..." \
  -H "Content-Type: application/json" \
  -d '{
    "name": "my-app",
    "customer_id": "cust_def456",
    "deploy_method": "template",
    "template_id": "uptime-kuma",
    "variables": {
      "SERVICE_NAME": "my-app"
    }
  }'

Git Deploy

curl -X POST https://panel.example.com/api/services \
  -H "Authorization: Bearer aap_k1_..." \
  -H "Content-Type: application/json" \
  -d '{
    "name": "my-project",
    "customer_id": "cust_def456",
    "deploy_method": "git",
    "git_url": "https://github.com/user/repo.git",
    "git_branch": "main"
  }'

Compose Deploy

curl -X POST https://panel.example.com/api/services \
  -H "Authorization: Bearer aap_k1_..." \
  -H "Content-Type: application/json" \
  -d '{
    "name": "custom-app",
    "customer_id": "cust_def456",
    "deploy_method": "compose",
    "compose": "version: '\''3.8'\''\nservices:\n  app:\n    image: myapp:latest"
  }'

AI Deploy

curl -X POST https://panel.example.com/api/services \
  -H "Authorization: Bearer aap_k1_..." \
  -H "Content-Type: application/json" \
  -d '{
    "name": "auto-app",
    "customer_id": "cust_def456",
    "deploy_method": "ai",
    "ai_url": "https://github.com/user/repo"
  }'

Response: 201 Created

{
  "id": "svc_new789",
  "name": "my-app",
  "status": "deploying",
  "url": "https://my-app.panel.example.com",
  "deploy_job_id": "job_xyz456"
}

The service starts in deploying status. Monitor progress via WebSocket or poll the service endpoint.

Service Lifecycle

Start Service

POST /api/services/:id/start

curl -X POST https://panel.example.com/api/services/svc_abc123/start \
  -H "Authorization: Bearer aap_k1_..."

Response: 200 OK

{
  "id": "svc_abc123",
  "status": "running",
  "message": "Service started"
}

Stop Service

POST /api/services/:id/stop

curl -X POST https://panel.example.com/api/services/svc_abc123/stop \
  -H "Authorization: Bearer aap_k1_..."

Response: 200 OK

{
  "id": "svc_abc123",
  "status": "stopped",
  "message": "Service stopped"
}

Restart Service

POST /api/services/:id/restart

curl -X POST https://panel.example.com/api/services/svc_abc123/restart \
  -H "Authorization: Bearer aap_k1_..."

Response: 200 OK

{
  "id": "svc_abc123",
  "status": "running",
  "message": "Service restarted"
}

Redeploy Service

POST /api/services/:id/redeploy

Pulls the latest image and redeploys. For Git-deployed services, pulls the latest commit.

curl -X POST https://panel.example.com/api/services/svc_abc123/redeploy \
  -H "Authorization: Bearer aap_k1_..."

Response: 200 OK

{
  "id": "svc_abc123",
  "status": "deploying",
  "deploy_job_id": "job_xyz789"
}

Delete Service

DELETE /api/services/:id

Stops the service, removes containers, deletes volumes, and cleans up DNS records.

curl -X DELETE https://panel.example.com/api/services/svc_abc123 \
  -H "Authorization: Bearer aap_k1_..."

Response: 204 No Content

This action is irreversible. All service data and volumes are permanently deleted.

Service Logs

GET /api/services/:id/logs

Returns recent container logs.

Query Parameters:

ParameterDescription
tailNumber of lines from the end (default: 100)
sinceRFC3339 timestamp to start from
followSet to true for streaming (upgrades to WebSocket)

Request:

curl "https://panel.example.com/api/services/svc_abc123/logs?tail=50" \
  -H "Authorization: Bearer aap_k1_..."

Response: 200 OK

{
  "logs": [
    {
      "timestamp": "2026-03-29T14:30:00Z",
      "stream": "stdout",
      "message": "Server started on port 3001"
    },
    {
      "timestamp": "2026-03-29T14:30:01Z",
      "stream": "stdout",
      "message": "Health check endpoint ready"
    }
  ]
}

Real-Time Log Streaming

For real-time logs, use the WebSocket endpoint:

wss://panel.example.com/api/services/svc_abc123/logs?follow=true

Each WebSocket message is a JSON log entry.

Service Events

GET /api/services/:id/events

Returns the event timeline for a service (deploys, restarts, health changes).

curl "https://panel.example.com/api/services/svc_abc123/events" \
  -H "Authorization: Bearer aap_k1_..."

Response: 200 OK

{
  "data": [
    {
      "type": "deploy",
      "status": "success",
      "message": "Deployed from template uptime-kuma",
      "timestamp": "2026-03-29T10:05:00Z"
    },
    {
      "type": "health",
      "status": "healthy",
      "message": "Health check passed",
      "timestamp": "2026-03-29T10:05:30Z"
    }
  ]
}