# integrations.records

Requisições de uma integração (página). Histórico da integração como no original: entrada lista os eventos recebidos, saída as entregas. Paginado por página (`page`, `perPage`), com filtro de status (COMPLETED, PROCESSING, FAILED, DELAYED) e ordem por data. Devolve também a contagem por status (sem o filtro) para os cartões do topo.

- Endpoint: `POST https://app.atomiks.com.br/api/v1/integrations.records` (corpo JSON)
- Quem pode chamar: membro da conta
- Escopo da chave: `automations:read`
- Grava dados: não
- Pela chave de API: sim
- Ferramenta MCP: `integrations_records`
- Ficha em JSON: `https://app.atomiks.com.br/api/v1/openapi.json` (operationId `integrations.records`)

## Entrada

| Campo | Tipo | Obrigatório | Nota |
|---|---|---|---|
| `integrationId` | string (uuid) | sim |  |
| `status` | "COMPLETED" \| "PROCESSING" \| "FAILED" \| "DELAYED" | não |  |
| `order` | "ASC" \| "DESC" | não | padrão "DESC" |
| `page` | integer | não | padrão 1 |
| `perPage` | integer | não | padrão 10 |

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

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "integrationId": {
      "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)$"
    },
    "status": {
      "type": "string",
      "enum": [
        "COMPLETED",
        "PROCESSING",
        "FAILED",
        "DELAYED"
      ]
    },
    "order": {
      "default": "DESC",
      "type": "string",
      "enum": [
        "ASC",
        "DESC"
      ]
    },
    "page": {
      "default": 1,
      "type": "integer",
      "minimum": 1,
      "maximum": 9007199254740991
    },
    "perPage": {
      "default": 10,
      "type": "integer",
      "minimum": 1,
      "maximum": 100
    }
  },
  "required": [
    "integrationId"
  ]
}
```

</details>

## Exemplo

```bash
curl -X POST https://app.atomiks.com.br/api/v1/integrations.records \
  -H "Authorization: Bearer $ATOMIKS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"integrationId":"00000000-0000-0000-0000-000000000000","order":"DESC","page":1,"perPage":10}'
```

CLI:

```bash
node cli/atomiks.mjs integrations.records --json '{"integrationId":"00000000-0000-0000-0000-000000000000","order":"DESC","page":1,"perPage":10}'
```

MCP: ferramenta `integrations_records` 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": {
    "type": {
      "type": "string",
      "enum": [
        "in",
        "out"
      ]
    },
    "records": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "trigger": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "COMPLETED",
              "PROCESSING",
              "FAILED",
              "DELAYED"
            ]
          },
          "createdAt": {
            "type": "string"
          },
          "attempts": {
            "type": [
              "number",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "trigger",
          "status",
          "createdAt",
          "attempts"
        ],
        "additionalProperties": false
      }
    },
    "total": {
      "type": "number"
    },
    "countPages": {
      "type": "number"
    },
    "counts": {
      "type": "object",
      "properties": {
        "all": {
          "type": "number"
        },
        "completed": {
          "type": "number"
        },
        "processing": {
          "type": "number"
        },
        "failed": {
          "type": "number"
        },
        "delayed": {
          "type": "number"
        }
      },
      "required": [
        "all",
        "completed",
        "processing",
        "failed",
        "delayed"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "type",
    "records",
    "total",
    "countPages",
    "counts"
  ],
  "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).
