> ## Documentation Index
> Fetch the complete documentation index at: https://docs.orkeia.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Criar Squad

> Cria um novo squad no ambiente.

## Endpoint

`POST https://gateway.orkeia.ai/squads`

**Autenticação**\
Requer cabeçalho `authorization:  <seu_token>`.

## Corpo da Requisição (JSON)

> O serviço espera um **wrapper** com a propriedade `squad`.

```json theme={null}
{
  "squad": {
    "name": "Equipe Alpha",
    "tasks": [
      {
        "id": "TASK_INGEST",
        "agent": "AGENT_INGEST",
        "name": "Ingestão de Dados",
        "objective": "Coletar e normalizar dados de origem externa",
        "dependsOn": [],
        "coordinates": { "x": 80, "y": 40, "width": 320, "height": 160 }
      }
    ],
    "order": "sequential",
    "enabled": true,
    "do_plan": false,
    "sectors": ["engineering"],
    "publisher": "Orkeia",
    "planningAgent": { "id": "AGENT_PLANNER" },
    "supervisor": { "id": "AGENT_SUPERVISOR" }
  }
}
```

> **Campos principais do `Squad`**
>
> | Campo         | Tipo                               | Obrigatório | Descrição                                      |
> | ------------- | ---------------------------------- | ----------- | ---------------------------------------------- |
> | name          | string                             | Sim         | Nome amigável do squad.                        |
> | tasks         | `Task[]`                           | Sim         | Lista de tarefas orquestradas pelo squad.      |
> | order         | `"sequential"` \| `"hierarchical"` | Sim         | Estratégia de execução das tarefas.            |
> | enabled       | boolean                            | Sim         | Ativa/desativa o squad.                        |
> | do\_plan      | boolean                            | Sim         | Se há etapa de planejamento antes da execução. |
> | sectors       | string\[]                          | Sim         | Setores com permissão para usar o squad.       |
> | publisher     | string                             | Sim         | Publicador/organização responsável.            |
> | planningAgent | `{ id: string, coordinates? }`     | Não         | (Opcional) Agente dedicado ao planejamento.    |
> | supervisor    | `{ id: string, coordinates? }`     | Não         | (Opcional) Agente supervisor/validador.        |

## Exemplo (cURL)

```bash theme={null}
curl -X POST "https://gateway.orkeia.ai/squads"   -H "authorization:  <seu_token>"   -H "Content-Type: application/json"   -d '{
    "squad": {
      "name": "Equipe Alpha",
      "tasks": [
        {
          "id": "TASK_INGEST",
          "agent": "AGENT_INGEST",
          "name": "Ingestão de Dados",
          "objective": "Coletar e normalizar dados de origem externa",
          "dependsOn": [],
          "coordinates": { "x": 80, "y": 40, "width": 320, "height": 160 }
        }
      ],
      "order": "sequential",
      "enabled": true,
      "do_plan": false,
      "sectors": ["engineering"],
      "publisher": "Orkeia",
      "planningAgent": { "id": "AGENT_PLANNER" },
      "supervisor": { "id": "AGENT_SUPERVISOR" }
    }
  }'
```

## Respostas

### Response - Success

```json response theme={null}
{
  "status": "OK",
  "data": { "id": "SQUAD_123456" }
}
```

### 500 — Server Error

```json theme={null}
{
  "status": "ERROR",
  "code": "server/error",
  "data": null
}
```

### 400 — Client Error

```json theme={null}
{
  "status": "ERROR",
  "code": "client/error",
  "data": null
}
```
