# activities.export

Exportar o histórico global em CSV. Enfileira um CSV (UTF-8 com BOM, vírgula, até 50 000 atividades) com os mesmos filtros de `activities.list`. Roda em segundo plano com as permissões de quem pediu. `labels` (opcional) traz o rótulo de cada `eventName` no idioma da tela; sem ele sai o rótulo em português. Colunas: `data`, `hora` (fuso da conta), `contato`, `atividade`, `evento`, `categoria`, `responsavel`, `detalhes`. Devolve `jobId`; acompanhe e baixe por `activities.export_get`. Sem a migration do job, responde `migration_pendente`.

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

## Entrada

| Campo | Tipo | Obrigatório | Nota |
|---|---|---|---|
| `eventName` | string[] | não |  |
| `startDate` | string | não |  |
| `endDate` | string | não |  |
| `offerIds` | string[] | não |  |
| `pageIds` | string[] | não |  |
| `funnelIds` | string[] | não |  |
| `productIds` | string (uuid)[] | não |  |
| `tagIds` | string (uuid)[] | não |  |
| `messageIds` | string[] | não |  |
| `pipelineIds` | string (uuid)[] | não |  |
| `flowIds` | string (uuid)[] | não |  |
| `labels` | object | não |  |

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

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "eventName": {
      "maxItems": 400,
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 120
      }
    },
    "startDate": {
      "type": "string",
      "maxLength": 40
    },
    "endDate": {
      "type": "string",
      "maxLength": 40
    },
    "offerIds": {
      "maxItems": 200,
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 100
      }
    },
    "pageIds": {
      "maxItems": 200,
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 100
      }
    },
    "funnelIds": {
      "maxItems": 200,
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 100
      }
    },
    "productIds": {
      "maxItems": 200,
      "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)$"
      }
    },
    "tagIds": {
      "maxItems": 200,
      "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)$"
      }
    },
    "messageIds": {
      "maxItems": 200,
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 100
      }
    },
    "pipelineIds": {
      "maxItems": 200,
      "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)$"
      }
    },
    "flowIds": {
      "maxItems": 200,
      "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)$"
      }
    },
    "labels": {
      "type": "object",
      "propertyNames": {
        "type": "string"
      },
      "additionalProperties": {
        "type": "string",
        "maxLength": 200
      }
    }
  }
}
```

</details>

## Exemplo

```bash
curl -X POST https://app.atomiks.com.br/api/v1/activities.export \
  -H "Authorization: Bearer $ATOMIKS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"startDate":"2026-10-01","endDate":"2026-10-26"}'
```

CLI:

```bash
node cli/atomiks.mjs activities.export --json '{"startDate":"2026-10-01","endDate":"2026-10-26"}'
```

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