164 lines
4.7 KiB
Markdown
164 lines
4.7 KiB
Markdown
# Coolify API Documentation
|
|
|
|
## Base URL
|
|
```
|
|
https://redbull.rede5.com.br/api/v1
|
|
```
|
|
|
|
## Authorization
|
|
|
|
A API requer um token `Bearer` no header `Authorization`.
|
|
|
|
### Gerar Token
|
|
1. Acesse `Keys & Tokens` / `API tokens` no painel Coolify
|
|
2. Defina um nome para o token e clique em `Create New Token`
|
|
3. Copie o token (so aparece uma vez)
|
|
|
|
### Token Atual
|
|
```
|
|
fzz2xL0UUwpeVB1mObEwxE9GO8sTV8z2OHiOojmdf0e428be
|
|
```
|
|
> Salvo em `~/.ssh/coolify-redbull-token`
|
|
|
|
### Permissoes
|
|
- `read-only` (default): apenas leitura
|
|
- `read:sensitive`: leitura + dados sensiveis
|
|
- `view:sensitive`: visualizar dados sensiveis
|
|
- `*`: acesso total
|
|
|
|
## Endpoints Principais
|
|
|
|
### Applications
|
|
| Metodo | Endpoint | Descricao |
|
|
|--------|----------|-----------|
|
|
| GET | `/applications` | Listar aplicacoes |
|
|
| GET | `/applications/{uuid}` | Obter aplicacao |
|
|
| GET | `/applications/{uuid}/start` | Iniciar aplicacao |
|
|
| GET | `/applications/{uuid}/stop` | Parar aplicacao |
|
|
| GET | `/applications/{uuid}/restart` | Reiniciar aplicacao |
|
|
| DELETE | `/applications/{uuid}` | Deletar aplicacao |
|
|
| PATCH | `/applications/{uuid}` | Atualizar aplicacao |
|
|
|
|
### Databases
|
|
| Metodo | Endpoint | Descricao |
|
|
|--------|----------|-----------|
|
|
| GET | `/databases` | Listar bancos |
|
|
| GET | `/databases/{uuid}` | Obter banco |
|
|
| POST | `/databases/postgresql` | Criar PostgreSQL |
|
|
| POST | `/databases/mysql` | Criar MySQL |
|
|
| POST | `/databases/mariadb` | Criar MariaDB |
|
|
| POST | `/databases/mongodb` | Criar MongoDB |
|
|
| POST | `/databases/redis` | Criar Redis |
|
|
| GET | `/databases/{uuid}/start` | Iniciar banco |
|
|
| GET | `/databases/{uuid}/stop` | Parar banco |
|
|
| DELETE | `/databases/{uuid}` | Deletar banco |
|
|
|
|
### Deployments
|
|
| Metodo | Endpoint | Descricao |
|
|
|--------|----------|-----------|
|
|
| GET | `/deployments` | Listar deployments |
|
|
| GET | `/deploy?uuid={uuid}` | Deploy por UUID |
|
|
| GET | `/deploy?tag={tag}` | Deploy por tag |
|
|
|
|
### Projects
|
|
| Metodo | Endpoint | Descricao |
|
|
|--------|----------|-----------|
|
|
| GET | `/projects` | Listar projetos |
|
|
| POST | `/projects` | Criar projeto |
|
|
| GET | `/projects/{uuid}` | Obter projeto |
|
|
| PATCH | `/projects/{uuid}` | Atualizar projeto |
|
|
| DELETE | `/projects/{uuid}` | Deletar projeto |
|
|
|
|
### Servers
|
|
| Metodo | Endpoint | Descricao |
|
|
|--------|----------|-----------|
|
|
| GET | `/servers` | Listar servidores |
|
|
| GET | `/servers/{uuid}` | Obter servidor |
|
|
| GET | `/servers/{uuid}/domains` | Listar dominios |
|
|
|
|
## Exemplos
|
|
|
|
### Listar Aplicacoes
|
|
```bash
|
|
curl -s -H "Authorization: Bearer $TOKEN" \
|
|
"https://redbull.rede5.com.br/api/v1/applications"
|
|
```
|
|
|
|
### Criar PostgreSQL Database
|
|
```bash
|
|
curl -s -X POST -H "Authorization: Bearer $TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
"https://redbull.rede5.com.br/api/v1/databases/postgresql" \
|
|
-d '{
|
|
"name": "my-database",
|
|
"description": "PostgreSQL database",
|
|
"project_uuid": "t0c4ss0wkcgwg48g088wkwgs",
|
|
"environment_name": "production",
|
|
"server_uuid": "m844o4gkwkwcc0k48swgs8c8",
|
|
"destination_uuid": "e0ggcws4gsw4w4wkgggkg8ow",
|
|
"postgres_user": "myuser",
|
|
"postgres_password": "mypassword",
|
|
"postgres_db": "mydb",
|
|
"image": "postgres:16-alpine",
|
|
"instant_deploy": true
|
|
}'
|
|
```
|
|
|
|
### Deploy por UUID
|
|
```bash
|
|
curl -s -H "Authorization: Bearer $TOKEN" \
|
|
"https://redbull.rede5.com.br/api/v1/deploy?uuid={UUID}"
|
|
```
|
|
|
|
### Atualizar Dominio
|
|
```bash
|
|
curl -s -X PATCH -H "Authorization: Bearer $TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
"https://redbull.rede5.com.br/api/v1/applications/{UUID}" \
|
|
-d '{"domains":"https://meu-dominio.com"}'
|
|
```
|
|
|
|
## UUIDs Importantes
|
|
|
|
### Server
|
|
| Nome | UUID |
|
|
|------|------|
|
|
| localhost | `m844o4gkwkwcc0k48swgs8c8` |
|
|
|
|
### Destination (Docker Network)
|
|
| Nome | UUID |
|
|
|------|------|
|
|
| coolify | `e0ggcws4gsw4w4wkgggkg8ow` |
|
|
|
|
### Projects
|
|
| Nome | UUID |
|
|
|------|------|
|
|
| Infraestrutura | `t0c4ss0wkcgwg48g088wkwgs` |
|
|
| gohorsejobs | `gkgksco0ow4kgwo8ow4cgs8c` |
|
|
| rodiziosdaqui | `iooos0488ww0coccosc0sk4c` |
|
|
| obramarket | `scwgsc8k0w84gkc88c080ck4` |
|
|
|
|
### Environments (Infraestrutura)
|
|
| Nome | UUID |
|
|
|------|------|
|
|
| production | `sw4ckcgkgs0wssgs40os8s0g` |
|
|
|
|
## Variaveis de Ambiente
|
|
```bash
|
|
export COOLIFY_TOKEN="fzz2xL0UUwpeVB1mObEwxE9GO8sTV8z2OHiOojmdf0e428be"
|
|
export COOLIFY_URL="https://redbull.rede5.com.br/api/v1"
|
|
export COOLIFY_SERVER="m844o4gkwkwcc0k48swgs8c8"
|
|
export COOLIFY_DESTINATION="e0ggcws4gsw4w4wkgggkg8ow"
|
|
```
|
|
|
|
## Script de Health Check
|
|
```bash
|
|
#!/bin/bash
|
|
TOKEN="fzz2xL0UUwpeVB1mObEwxE9GO8sTV8z2OHiOojmdf0e428be"
|
|
curl -s -H "Authorization: Bearer $TOKEN" \
|
|
"https://redbull.rede5.com.br/api/v1/applications" | jq -r '.[] | "\(.name): \(.status)"'
|
|
```
|
|
|
|
## Links
|
|
- [Coolify API Docs](https://coolify.io/docs/api-reference/authorization)
|
|
- [GitHub Issues](https://github.com/coollabsio/coolify/issues)
|