# custom_objects.records_bulk_delete

Excluir registros em massa. Exclui vários registros do objeto de uma vez: `recordIds` (até 5.000) ou `allMatching: true` com `filters`/`search` (tudo o que casa). Até 200 registros roda na hora (`mode: "sync"`, com `affected`); acima disso vira uma tarefa em segundo plano (`mode: "async"`, com `jobId`): acompanhe com `custom_objects.record_job_get` (até 100.000 registros). Não dá para desfazer.

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

## Entrada

| Campo | Tipo | Obrigatório | Nota |
|---|---|---|---|
| `objectId` | string (uuid) | sim |  |
| `recordIds` | string (uuid)[] | não |  |
| `allMatching` | boolean | não |  |
| `filters` | object[] | não |  |
| `relations` | object[] | não |  |
| `search` | string | não |  |

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

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "objectId": {
      "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)$"
    },
    "recordIds": {
      "maxItems": 5000,
      "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)$"
      }
    },
    "allMatching": {
      "type": "boolean"
    },
    "filters": {
      "maxItems": 30,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "fieldId": {
            "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": "string",
                "enum": [
                  "title",
                  "responsible",
                  "createdAt",
                  "updatedAt"
                ]
              }
            ]
          },
          "op": {
            "type": "string",
            "enum": [
              "eq",
              "neq",
              "contains",
              "not_contains",
              "gt",
              "gte",
              "lt",
              "lte",
              "empty",
              "not_empty",
              "in",
              "not_in",
              "starts_with",
              "ends_with"
            ]
          },
          "value": {}
        },
        "required": [
          "fieldId",
          "op"
        ]
      }
    },
    "relations": {
      "maxItems": 10,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "relationId": {
            "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)$"
          },
          "side": {
            "type": "string",
            "enum": [
              "source",
              "target"
            ]
          },
          "quantifier": {
            "type": "string",
            "enum": [
              "any",
              "all",
              "none"
            ]
          },
          "value": {
            "type": "string",
            "maxLength": 200
          },
          "conditions": {
            "maxItems": 10,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "fieldId": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 80
                },
                "op": {
                  "type": "string",
                  "enum": [
                    "eq",
                    "neq",
                    "contains",
                    "not_contains",
                    "gt",
                    "gte",
                    "lt",
                    "lte",
                    "empty",
                    "not_empty",
                    "in",
                    "not_in",
                    "starts_with",
                    "ends_with"
                  ]
                },
                "value": {}
              },
              "required": [
                "fieldId",
                "op"
              ]
            }
          }
        },
        "required": [
          "relationId",
          "side",
          "quantifier"
        ]
      }
    },
    "search": {
      "type": "string",
      "maxLength": 200
    }
  },
  "required": [
    "objectId"
  ]
}
```

</details>

## Exemplo

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

CLI:

```bash
node cli/atomiks.mjs custom_objects.records_bulk_delete --json '{"objectId":"00000000-0000-0000-0000-000000000000","recordIds":["00000000-0000-0000-0000-000000000000"]}'
```

MCP: ferramenta `custom_objects_records_bulk_delete` com a mesma entrada.

## Saída

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

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "oneOf": [
    {
      "type": "object",
      "properties": {
        "mode": {
          "type": "string",
          "const": "sync"
        },
        "affected": {
          "type": "number"
        }
      },
      "required": [
        "mode",
        "affected"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "mode": {
          "type": "string",
          "const": "async"
        },
        "jobId": {
          "type": "string"
        }
      },
      "required": [
        "mode",
        "jobId"
      ],
      "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).
