# contacts.create

Criar contato. Cria um contato com nome e pelo menos um canal: `phone` (só dígitos com DDI, 10 a 15; `+`, espaços e traços são ignorados), `email` ou `instagram` (o @ do perfil). Canal informado e inválido dá `invalid_input`. Origem `manual`; quem cria passa a vê-lo na lista mesmo sem conversa. `tagIds` (tags da conta) são aplicadas sem disparar automações de tag.

Identidade e duplicado: com telefone, procura pelo telefone; sem telefone, pelo e-mail; só com Instagram, pelo @. Se já existe, devolve o contato existente com `created: false` sem alterar nada (com e-mail, só preenche nome vazio) e sem aplicar as tags.

Contato só com e-mail ou Instagram não conversa pelo WhatsApp até ganhar um telefone; o só-Instagram não recebe Direct até a pessoa escrever. Para falar com ele use `inbox.conversation_start`.

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

## Entrada

| Campo | Tipo | Obrigatório | Nota |
|---|---|---|---|
| `name` | string | sim |  |
| `phone` | string | não |  |
| `email` | string | não |  |
| `instagram` | string | não |  |
| `tagIds` | string (uuid)[] | 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
    },
    "phone": {
      "type": "string",
      "maxLength": 40
    },
    "email": {
      "type": "string",
      "maxLength": 254
    },
    "instagram": {
      "type": "string",
      "maxLength": 100
    },
    "tagIds": {
      "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)$"
      }
    }
  },
  "required": [
    "name"
  ]
}
```

</details>

## Exemplo

```bash
curl -X POST https://app.atomiks.com.br/api/v1/contacts.create \
  -H "Authorization: Bearer $ATOMIKS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"Maria Souza","phone":"+55 11 91234-5678","email":"maria@exemplo.com","instagram":"@mariasouza"}'
```

CLI:

```bash
node cli/atomiks.mjs contacts.create --json '{"name":"Maria Souza","phone":"+55 11 91234-5678","email":"maria@exemplo.com","instagram":"@mariasouza"}'
```

MCP: ferramenta `contacts_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",
        "null"
      ]
    },
    "phone": {
      "type": [
        "string",
        "null"
      ]
    },
    "firstSeenAt": {
      "type": "string"
    },
    "origin": {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "enum": [
            "ad",
            "organic",
            "manual",
            "import",
            "integration",
            "instagram",
            "form",
            "api"
          ]
        },
        "detail": {
          "type": [
            "string",
            "null"
          ]
        },
        "adId": {
          "type": [
            "string",
            "null"
          ]
        },
        "adName": {
          "type": [
            "string",
            "null"
          ]
        },
        "campaignName": {
          "type": [
            "string",
            "null"
          ]
        },
        "headline": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "kind",
        "detail",
        "adId",
        "adName",
        "campaignName",
        "headline"
      ],
      "additionalProperties": false
    },
    "created": {
      "type": "boolean"
    }
  },
  "required": [
    "id",
    "name",
    "phone",
    "firstSeenAt",
    "origin",
    "created"
  ],
  "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).
