# EasyPanel API - Services

**Verificado:** 12-03-2026 (engenharia reversa do backend.js)

## Service Types

| Type | Descricao |
|------|-----------|
| `app` | Aplicacao (Node.js, Python, Go, Rust, etc.) |
| `mysql` | MySQL database |
| `mariadb` | MariaDB database |
| `postgres` | PostgreSQL database |
| `mongo` | MongoDB database |
| `redis` | Redis cache |

## Criar Servico App

```bash
curl -s -X POST "http://localhost:3000/api/trpc/services.app.createService" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"json":{"projectName":"descomplicar","serviceName":"minha-api"}}'
```

## Criar Servico Database

```bash
# PostgreSQL
curl -s -X POST "http://localhost:3000/api/trpc/services.postgres.createService" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"json":{"projectName":"descomplicar","serviceName":"minha-db"}}'

# MySQL
curl -s -X POST "http://localhost:3000/api/trpc/services.mysql.createService" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"json":{"projectName":"descomplicar","serviceName":"mysql-db"}}'

# Redis
curl -s -X POST "http://localhost:3000/api/trpc/services.redis.createService" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"json":{"projectName":"descomplicar","serviceName":"cache"}}'
```

## Inspeccionar Servico (GET)

```bash
INPUT='{"json":{"projectName":"descomplicar","serviceName":"dashboard_descomplicar"}}'
ENCODED=$(python3 -c "import urllib.parse; print(urllib.parse.quote('$INPUT'))")
curl -s "http://localhost:3000/api/trpc/services.app.inspectService?input=$ENCODED" \
  -H "Authorization: Bearer $TOKEN"
```

Response parcial:
```json
{
  "projectName": "descomplicar",
  "name": "dashboard_descomplicar",
  "type": "app",
  "enabled": true,
  "token": "deploy-webhook-token",
  "source": {"type": "git", "repo": "https://...", "ref": "main"},
  "build": {"type": "nixpacks", "buildCommand": "npm run build"},
  "env": "VAR=value",
  "mounts": [],
  "ports": []
}
```

## Deploy Servico

```bash
curl -s -X POST "http://localhost:3000/api/trpc/services.app.deployService" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"json":{"projectName":"descomplicar","serviceName":"minha-api"}}'
```

## Stop / Start / Restart Servico

```bash
# Parar servico
curl -s -X POST "http://localhost:3000/api/trpc/services.app.stopService" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"json":{"projectName":"descomplicar","serviceName":"minha-api"}}'

# Iniciar servico
curl -s -X POST "http://localhost:3000/api/trpc/services.app.startService" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"json":{"projectName":"descomplicar","serviceName":"minha-api"}}'

# Reiniciar servico
curl -s -X POST "http://localhost:3000/api/trpc/services.app.restartService" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"json":{"projectName":"descomplicar","serviceName":"minha-api"}}'
```

**IMPORTANTE:** `enableService` e `disableService` NAO existem na versao instalada. Usar `startService`/`stopService`.

## Destruir Servico

```bash
curl -s -X POST "http://localhost:3000/api/trpc/services.app.destroyService" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"json":{"projectName":"descomplicar","serviceName":"minha-api"}}'
```

---

## Resumo de Endpoints

| Endpoint | Tipo | Descricao | Verificado |
|----------|------|-----------|:----------:|
| `services.app.createService` | POST | Criar servico app | Sim |
| `services.postgres.createService` | POST | Criar PostgreSQL | Sim |
| `services.mysql.createService` | POST | Criar MySQL | Sim |
| `services.redis.createService` | POST | Criar Redis | Sim |
| `services.app.inspectService` | GET | Inspeccionar servico | Sim |
| `services.app.deployService` | POST | Fazer deploy | Sim |
| `services.app.stopService` | POST | Parar servico | Sim |
| `services.app.startService` | POST | Iniciar servico | Sim |
| `services.app.restartService` | POST | Reiniciar servico | Sim |
| `services.app.destroyService` | POST | Destruir servico | Sim |

**Endpoints que NAO existem:** `enableService`, `disableService`, `redeployService`

---

*Actualizado: 12-03-2026*
