> ## 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.

# Create Squad

> Creates a new squad in the environment.

## Endpoint

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

**Authentication**\
Requires header `authorization:  <your_token>`.

## Request Body (JSON)

> The service expects a **wrapper** with the property `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" }
  }
}
```

> **Main fields of `Squad`**
>
> | Field         | Type                               | Required | Description                                   |
> | ------------- | ---------------------------------- | -------- | --------------------------------------------- |
> | name          | string                             | Yes      | Friendly name of the squad.                   |
> | tasks         | `Task[]`                           | Yes      | List of tasks orchestrated by the squad.      |
> | order         | `"sequential"` \| `"hierarchical"` | Yes      | Execution strategy of the tasks.              |
> | enabled       | boolean                            | Yes      | Activates/deactivates the squad.              |
> | do\_plan      | boolean                            | Yes      | If there is a planning step before execution. |
> | sectors       | string\[]                          | Yes      | Sectors with permission to use the squad.     |
> | publisher     | string                             | Yes      | Publisher/organization responsible.           |
> | planningAgent | `{ id: string, coordinates? }`     | No       | (Optional) Agent dedicated to planning.       |
> | supervisor    | `{ id: string, coordinates? }`     | No       | (Optional) Supervisor/validator agent.        |

## Example (cURL)

```bash theme={null}
curl -X POST "https://gateway.orkeia.ai/squads"   -H "authorization:  <your_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" }
    }
  }'
```

## Responses

### 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
}
```
