# teams.create

Criar time. Cria um time. `slug` (letras minúsculas, números e hífen) é gerado do nome quando vazio e é único na conta (gerado repetido ganha `-2`, `-3`; informado repetido dá `invalid_input`). `emoji` é o nome do ícone; `color`/`brandColor` são `#rrggbb`. Começa no modo `weighted` e sem membros. Exige a migration de times (`migration_pendente` sem ela).

- Endpoint: `POST https://app.atomiks.com.br/api/v1/teams.create` (corpo JSON)
- Quem pode chamar: administrador da conta
- Escopo da chave: `crm:write`
- Grava dados: sim
- Pela chave de API: sim
- Ferramenta MCP: `teams_create`
- Ficha em JSON: `https://app.atomiks.com.br/api/v1/openapi.json` (operationId `teams.create`)

## Entrada

| Campo | Tipo | Obrigatório | Nota |
|---|---|---|---|
| `name` | string | sim |  |
| `slug` | string | não |  |
| `description` | string \| null | não |  |
| `emoji` | string \| null | não |  |
| `color` | string \| null | não |  |
| `brandColor` | string \| null | não |  |
| `logoUrl` | string \| null | não |  |

<details><summary>JSON Schema</summary>

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120
    },
    "slug": {
      "type": "string",
      "maxLength": 60
    },
    "description": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 1000
        },
        {
          "type": "null"
        }
      ]
    },
    "emoji": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 40
        },
        {
          "type": "null"
        }
      ]
    },
    "color": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "^#[0-9a-fA-F]{6}$"
        },
        {
          "type": "null"
        }
      ]
    },
    "brandColor": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "^#[0-9a-fA-F]{6}$"
        },
        {
          "type": "null"
        }
      ]
    },
    "logoUrl": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 2000
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "name"
  ]
}
```

</details>

## Exemplo

```bash
curl -X POST https://app.atomiks.com.br/api/v1/teams.create \
  -H "Authorization: Bearer $ATOMIKS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"Time Comercial","description":"Atende os leads novos"}'
```

CLI:

```bash
node cli/atomiks.mjs teams.create --json '{"name":"Time Comercial","description":"Atende os leads novos"}'
```

MCP: ferramenta `teams_create` com a mesma entrada.

## Saída

Sucesso: `{"data": ...}` com o formato abaixo.

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "name": {
      "type": "string"
    },
    "slug": {
      "type": "string"
    },
    "description": {
      "type": [
        "string",
        "null"
      ]
    },
    "emoji": {
      "type": [
        "string",
        "null"
      ]
    },
    "color": {
      "type": [
        "string",
        "null"
      ]
    },
    "brandColor": {
      "type": [
        "string",
        "null"
      ]
    },
    "logoUrl": {
      "type": [
        "string",
        "null"
      ]
    },
    "memberCount": {
      "type": "number"
    },
    "totalMembers": {
      "type": "number"
    },
    "memberTypeCounts": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "attendantTypeId": {
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "type": [
              "string",
              "null"
            ]
          },
          "color": {
            "type": [
              "string",
              "null"
            ]
          },
          "emoji": {
            "type": [
              "string",
              "null"
            ]
          },
          "count": {
            "type": "number"
          }
        },
        "required": [
          "attendantTypeId",
          "name",
          "color",
          "emoji",
          "count"
        ],
        "additionalProperties": false
      }
    },
    "appointmentSchedules": {
      "type": "array",
      "items": {
        "type": "object",
        "propertyNames": {
          "type": "string"
        },
        "additionalProperties": {}
      }
    },
    "distributionMode": {
      "type": "string",
      "enum": [
        "weighted",
        "strict"
      ]
    },
    "strictRespectCaps": {
      "type": "boolean"
    },
    "queueCursorMemberId": {
      "type": [
        "string",
        "null"
      ]
    },
    "createdAt": {
      "type": "string"
    },
    "updatedAt": {
      "type": "string"
    },
    "members": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "teamId": {
            "type": "string"
          },
          "attendantId": {
            "type": "string"
          },
          "attendantName": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "initials": {
            "type": "string"
          },
          "imageUrl": {
            "type": [
              "string",
              "null"
            ]
          },
          "role": {
            "type": "string",
            "enum": [
              "admin",
              "member"
            ]
          },
          "priority": {
            "type": "number"
          },
          "weight": {
            "type": "number"
          },
          "isFixed": {
            "type": "boolean"
          },
          "capOpen": {
            "type": [
              "number",
              "null"
            ]
          },
          "active": {
            "type": "boolean"
          },
          "operational": {
            "type": "boolean"
          },
          "inPipeline": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "position": {
            "type": "number"
          },
          "temperatureRules": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "temperature": {
                  "type": "string",
                  "enum": [
                    "hot",
                    "warm",
                    "cold"
                  ]
                },
                "cap": {
                  "anyOf": [
                    {
                      "type": "integer",
                      "minimum": 1,
                      "maximum": 9007199254740991
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              },
              "required": [
                "temperature",
                "cap"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "id",
          "teamId",
          "attendantId",
          "attendantName",
          "name",
          "initials",
          "imageUrl",
          "role",
          "priority",
          "weight",
          "isFixed",
          "capOpen",
          "active",
          "operational",
          "inPipeline",
          "position",
          "temperatureRules"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "id",
    "name",
    "slug",
    "description",
    "emoji",
    "color",
    "brandColor",
    "logoUrl",
    "memberCount",
    "totalMembers",
    "memberTypeCounts",
    "appointmentSchedules",
    "distributionMode",
    "strictRespectCaps",
    "queueCursorMemberId",
    "createdAt",
    "updatedAt",
    "members"
  ],
  "additionalProperties": false
}
```

## Erros

`{"error": {"code", "message", "requestId"}}`. Códigos: `invalid_input` (400), `unauthorized` (401), `forbidden` / `account_pending` / `scope_missing` (403), `not_found` (404), `limit_reached` (409), `internal` (500).
