# inbox.dashboard_metrics

Gráficos e atividade do painel do atendimento. Métricas do período `from`..`to` (até 92 dias) das conversas que o membro enxerga: `volume` (atendimentos iniciados por hora, se o período tem até 36 h, senão por dia, no fuso da conta, com buckets vazios preenchidos), `byChannel` (por tipo de canal), `avgFirstResponseSeconds`, `avgResolutionSeconds` (atendimentos resolvidos), `responseBuckets` (primeira resposta média por hora ou por dia da semana, 0 = domingo), `recentActivity` (6 eventos: atribuída, transferida, resolvida, reaberta; sem repetir conversa+evento) e `byAttendant` (admin: todos; membro: só ele). Com `viewAsAttendantId` (só admin) tudo vale para os atendimentos daquele atendente.

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

## Entrada

| Campo | Tipo | Obrigatório | Nota |
|---|---|---|---|
| `from` | string (date-time) | sim |  |
| `to` | string (date-time) | sim |  |
| `viewAsAttendantId` | string (uuid) | não |  |

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

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "from": {
      "type": "string",
      "format": "date-time",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
    },
    "to": {
      "type": "string",
      "format": "date-time",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
    },
    "viewAsAttendantId": {
      "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": [
    "from",
    "to"
  ]
}
```

</details>

## Exemplo

```bash
curl -X POST https://app.atomiks.com.br/api/v1/inbox.dashboard_metrics \
  -H "Authorization: Bearer $ATOMIKS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"from":"2026-10-17T00:00:00-03:00","to":"2026-10-24T23:59:59-03:00"}'
```

CLI:

```bash
node cli/atomiks.mjs inbox.dashboard_metrics --json '{"from":"2026-10-17T00:00:00-03:00","to":"2026-10-24T23:59:59-03:00"}'
```

MCP: ferramenta `inbox_dashboard_metrics` 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": {
    "timezone": {
      "type": "string"
    },
    "bucketKind": {
      "type": "string",
      "enum": [
        "hour",
        "day"
      ]
    },
    "total": {
      "type": "number"
    },
    "volume": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "bucket": {
            "type": "string"
          },
          "count": {
            "type": "number"
          }
        },
        "required": [
          "bucket",
          "count"
        ],
        "additionalProperties": false
      }
    },
    "byChannel": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string"
          },
          "count": {
            "type": "number"
          }
        },
        "required": [
          "kind",
          "count"
        ],
        "additionalProperties": false
      }
    },
    "avgFirstResponseSeconds": {
      "type": [
        "number",
        "null"
      ]
    },
    "avgResolutionSeconds": {
      "type": [
        "number",
        "null"
      ]
    },
    "responseBuckets": {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "enum": [
            "hour",
            "weekday"
          ]
        },
        "items": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "key": {
                "type": "number"
              },
              "avgSeconds": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "count": {
                "type": "number"
              }
            },
            "required": [
              "key",
              "avgSeconds",
              "count"
            ],
            "additionalProperties": false
          }
        }
      },
      "required": [
        "kind",
        "items"
      ],
      "additionalProperties": false
    },
    "recentActivity": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "at": {
            "type": "string"
          },
          "action": {
            "type": "string",
            "enum": [
              "assigned",
              "unassigned",
              "transferred",
              "resolved",
              "reopened",
              "priority"
            ]
          },
          "conversationId": {
            "type": "string"
          },
          "contactName": {
            "type": [
              "string",
              "null"
            ]
          },
          "userId": {
            "type": [
              "string",
              "null"
            ]
          },
          "userName": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "at",
          "action",
          "conversationId",
          "contactName",
          "userId",
          "userName"
        ],
        "additionalProperties": false
      }
    },
    "byAttendant": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "userId": {
            "type": "string"
          },
          "name": {
            "type": [
              "string",
              "null"
            ]
          },
          "attended": {
            "type": "number"
          },
          "resolved": {
            "type": "number"
          },
          "avgFirstResponseSeconds": {
            "type": [
              "number",
              "null"
            ]
          }
        },
        "required": [
          "userId",
          "name",
          "attended",
          "resolved",
          "avgFirstResponseSeconds"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "timezone",
    "bucketKind",
    "total",
    "volume",
    "byChannel",
    "avgFirstResponseSeconds",
    "avgResolutionSeconds",
    "responseBuckets",
    "recentActivity",
    "byAttendant"
  ],
  "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).
