# message_history.webhooks

Histórico de envio: entregas de webhook. Aba Webhooks do Histórico de envio: as entregas de webhook de saída da conta (`webhook_deliveries`), da mais recente: `provider` (conector da integração), `event`, `httpStatus` da última tentativa, `newStatus` (queued, sending, sent ou failed), `externalMessageId` (id do evento de origem), `processingError` e `receivedAt` (quando entrou na fila). `provider` filtra pelo conector; `search` aceita o id da entrega ou do evento, ou parte do nome do evento. `providers` traz os conectores que a conta usa, para o filtro.

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

## Entrada

| Campo | Tipo | Obrigatório | Nota |
|---|---|---|---|
| `page` | integer | não | padrão 1 |
| `perPage` | integer | não | padrão 20 |
| `provider` | string | não |  |
| `search` | string | não |  |

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

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "page": {
      "default": 1,
      "type": "integer",
      "minimum": 1,
      "maximum": 10000
    },
    "perPage": {
      "default": 20,
      "type": "integer",
      "minimum": 1,
      "maximum": 100
    },
    "provider": {
      "type": "string",
      "maxLength": 40
    },
    "search": {
      "type": "string",
      "maxLength": 120
    }
  }
}
```

</details>

## Exemplo

```bash
curl -X POST https://app.atomiks.com.br/api/v1/message_history.webhooks \
  -H "Authorization: Bearer $ATOMIKS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"page":1,"perPage":20}'
```

CLI:

```bash
node cli/atomiks.mjs message_history.webhooks --json '{"page":1,"perPage":20}'
```

MCP: ferramenta `message_history_webhooks` 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": {
    "data": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "provider": {
            "type": "string"
          },
          "event": {
            "type": "string"
          },
          "httpStatus": {
            "type": [
              "number",
              "null"
            ]
          },
          "newStatus": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "queued",
                  "sending",
                  "sent",
                  "delivered",
                  "failed",
                  "visualized"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "externalMessageId": {
            "type": [
              "string",
              "null"
            ]
          },
          "messageInstanceId": {
            "type": "null"
          },
          "processingError": {
            "type": [
              "string",
              "null"
            ]
          },
          "receivedAt": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "provider",
          "event",
          "httpStatus",
          "newStatus",
          "externalMessageId",
          "messageInstanceId",
          "processingError",
          "receivedAt"
        ],
        "additionalProperties": false
      }
    },
    "meta": {
      "type": "object",
      "properties": {
        "page": {
          "type": "number"
        },
        "perPage": {
          "type": "number"
        },
        "countItens": {
          "type": "number"
        },
        "countPages": {
          "type": "number"
        }
      },
      "required": [
        "page",
        "perPage",
        "countItens",
        "countPages"
      ],
      "additionalProperties": false
    },
    "providers": {
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "required": [
    "data",
    "meta",
    "providers"
  ],
  "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).
