# pipelines.attendants_set

Definir os atendentes de um pipeline. Troca os atendentes do pipeline por `attendantIds` (ids de usuário de `attendants.list`). Quem já estava mantém o peso do rodízio; quem entra começa com 5. Devolve o mesmo que `pipelines.attendant_types_get`.

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

## Entrada

| Campo | Tipo | Obrigatório | Nota |
|---|---|---|---|
| `pipelineId` | string (uuid) | sim |  |
| `attendantIds` | string (uuid)[] | sim |  |

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

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "pipelineId": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "attendantIds": {
      "maxItems": 500,
      "type": "array",
      "items": {
        "type": "string",
        "format": "uuid",
        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
      }
    }
  },
  "required": [
    "pipelineId",
    "attendantIds"
  ]
}
```

</details>

## Exemplo

```bash
curl -X POST https://app.atomiks.com.br/api/v1/pipelines.attendants_set \
  -H "Authorization: Bearer $ATOMIKS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"pipelineId":"00000000-0000-0000-0000-000000000000","attendantIds":["00000000-0000-0000-0000-000000000000"]}'
```

CLI:

```bash
node cli/atomiks.mjs pipelines.attendants_set --json '{"pipelineId":"00000000-0000-0000-0000-000000000000","attendantIds":["00000000-0000-0000-0000-000000000000"]}'
```

MCP: ferramenta `pipelines_attendants_set` 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": {
    "items": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "attendantTypeId": {
            "type": "string"
          },
          "attendantTypeName": {
            "type": "string"
          },
          "attendantTypeEmoji": {
            "type": [
              "string",
              "null"
            ]
          },
          "attendantTypeColor": {
            "type": [
              "string",
              "null"
            ]
          },
          "commissionType": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "percentage",
                  "fixed"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "commissionPercentBp": {
            "type": [
              "number",
              "null"
            ]
          },
          "commissionFixedCents": {
            "type": [
              "number",
              "null"
            ]
          }
        },
        "required": [
          "attendantTypeId",
          "attendantTypeName",
          "attendantTypeEmoji",
          "attendantTypeColor",
          "commissionType",
          "commissionPercentBp",
          "commissionFixedCents"
        ],
        "additionalProperties": false
      }
    },
    "attendants": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "attendantId": {
            "type": "string"
          },
          "weight": {
            "type": "number"
          }
        },
        "required": [
          "attendantId",
          "weight"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "items",
    "attendants"
  ],
  "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).
