# pipelines.import_contacts

Importar contatos de listas e segmentos para uma etapa. Cria uma oportunidade por contato das listas (`listIds`) e segmentos (`segmentIds`, recalculados na hora) na etapa aberta, no fim da coluna e com o nome do contato como título. Contato que já tem oportunidade no pipeline é pulado (`skipped`). `assignment`: `fixed`, `multiple` (revezamento) ou `round_robin` (time); sem ele o card fica sem responsável. Etapa com limite de cards em modo `block` recusa a importação que o passaria. Até 5000 contatos por chamada.

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

## Entrada

| Campo | Tipo | Obrigatório | Nota |
|---|---|---|---|
| `pipelineId` | string (uuid) | sim |  |
| `stageId` | string (uuid) | sim |  |
| `listIds` | string (uuid)[] | não | padrão [] |
| `segmentIds` | string (uuid)[] | não |  |
| `assignment` | object | não |  |

<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)$"
    },
    "stageId": {
      "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)$"
    },
    "listIds": {
      "default": [],
      "maxItems": 50,
      "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)$"
      }
    },
    "segmentIds": {
      "maxItems": 50,
      "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)$"
      }
    },
    "assignment": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "mode": {
              "type": "string",
              "const": "fixed"
            },
            "attendantId": {
              "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": [
            "mode",
            "attendantId"
          ]
        },
        {
          "type": "object",
          "properties": {
            "mode": {
              "type": "string",
              "const": "multiple"
            },
            "attendantIds": {
              "minItems": 1,
              "maxItems": 100,
              "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": [
            "mode",
            "attendantIds"
          ]
        },
        {
          "type": "object",
          "properties": {
            "mode": {
              "type": "string",
              "const": "round_robin"
            },
            "teamId": {
              "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": [
            "mode",
            "teamId"
          ]
        }
      ]
    }
  },
  "required": [
    "pipelineId",
    "stageId"
  ]
}
```

</details>

## Exemplo

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

CLI:

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

MCP: ferramenta `pipelines_import_contacts` 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": {
    "mode": {
      "type": "string",
      "const": "sync"
    },
    "jobId": {
      "type": "null"
    },
    "totalLeads": {
      "type": "number"
    },
    "created": {
      "type": "number"
    },
    "skipped": {
      "type": "number"
    }
  },
  "required": [
    "mode",
    "jobId",
    "totalLeads",
    "created",
    "skipped"
  ],
  "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).
