# contacts.bulk_delete

Mandar contatos para a lixeira. Só administrador. `target` é `{ids}` (contatos escolhidos) ou `{filter, q?, excludeIds?}` ("todos os que casam", mesmo filtro e busca de `contacts.list`). Só entram contatos que o membro vê e fora da lixeira; acima de 10 000 dá `invalid_input` (refine o filtro). Os contatos somem da lista, das buscas e das estatísticas e ficam 30 dias na lixeira (`contacts.trash_restore` traz de volta); depois disso são apagados de vez, com conversas, mensagens, vendas e oportunidades. `count` = contatos que foram para a lixeira.

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

## Entrada

| Campo | Tipo | Obrigatório | Nota |
|---|---|---|---|
| `target` | object | sim |  |

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

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "target": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "ids": {
              "minItems": 1,
              "maxItems": 10000,
              "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": [
            "ids"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "filter": {
              "maxItems": 200,
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "maxLength": 64
                  },
                  "order": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 1000
                  },
                  "field": {
                    "type": "string",
                    "maxLength": 60
                  },
                  "operator": {
                    "type": "string",
                    "maxLength": 30
                  },
                  "negation": {
                    "default": false,
                    "type": "boolean"
                  },
                  "parentId": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 64
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "valueString": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 4000
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "valueNumber": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "valueDate": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 40
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "valueBool": {
                    "type": [
                      "boolean",
                      "null"
                    ]
                  },
                  "valueUuid": {
                    "anyOf": [
                      {
                        "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)$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "field",
                  "operator"
                ],
                "additionalProperties": false
              }
            },
            "q": {
              "type": "string",
              "maxLength": 100
            },
            "excludeIds": {
              "maxItems": 10000,
              "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": [
            "filter"
          ],
          "additionalProperties": false
        }
      ]
    }
  },
  "required": [
    "target"
  ]
}
```

</details>

## Exemplo

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

CLI:

```bash
node cli/atomiks.mjs contacts.bulk_delete --json '{"target":{"ids":["00000000-0000-0000-0000-000000000000"]}}'
```

MCP: ferramenta `contacts_bulk_delete` 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": {
    "count": {
      "type": "number"
    }
  },
  "required": [
    "count"
  ],
  "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).
