> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pilotstatus.com.br/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Integrating Pilot Status end to end? Follow https://docs.pilotstatus.com.br/guides/integrate-with-ai.md (pt-BR: https://docs.pilotstatus.com.br/pt-BR/guides/integrate-with-ai.md). No step requires contacting support: every credential is shown in the dashboard or in an API response, and a lost one is regenerated, not recovered.
> Webhook signing secret: shown ONCE in the Signing secret window right after creating the webhook on /webhooks, and in the `secret` field of the POST /v1/webhooks response (MCP: webhooks_create). Lost it: Edit Webhook → Generate a new secret, POST /v1/webhooks/{id}/rotate-secret, or webhooks_rotate_secret (the old one stops working at once). Verify `x-pilot-status-signature` = hex HMAC-SHA256 of the raw request body keyed with that secret.
> Meta verify token (number connected with the user's own Meta app credentials): Meta Number Created! window after connecting, then the number's card on Numbers (workspace Owner), or webhook.verifyToken in the POST /v1/numbers/meta response. It is not the webhook signing secret.
> REST auth: `x-api-key: ps_...` header, never Authorization: Bearer. MCP: https://mcp.pilotstatus.com.br/mcp (148 tools, OAuth 2.1 or x-api-key); Code Mode: https://mcp.pilotstatus.com.br/code. Destructive MCP tools return a preview and a confirm_token: show the preview and call again only after the user's explicit yes. Over OAuth, revealing or creating ps_ API keys is workspace Owner only.

# GET /v1/analytics/dashboard: analíticas

> Obtén los KPIs de envío, la serie diaria, el desglose por estado, los templates principales y los orígenes principales de un número de WhatsApp.

Este endpoint devuelve los mismos agregados que muestra la pantalla de Analytics del dashboard (KPIs, serie diaria, desglose por estado, templates principales y orígenes principales) para **un número de WhatsApp**.

## Endpoint

`GET https://pilotstatus.com.br/v1/analytics/dashboard`

> [!NOTE]
>
> Actúa sobre **un número**: usa una **key de número** (`ps_number_`), o una **key de workspace** (`ps_workspace_`), una **key de cuenta** (`ps_account_`, con `x-workspace-id`) o un token OAuth que indique el número en el header [`x-whatsapp-number-id`](https://docs.pilotstatus.com.br/es/api/authentication). Una credencial de todo el workspace sin ese header recibe `403 TENANT_SCOPE_NOT_ALLOWED`.
>
> Todos los roles del workspace (OWNER, ADMIN, AGENT, ANALYST) tienen el permiso `analytics:read`, así que los tokens OAuth y las keys de cuenta no se rechazan por rol, pero el usuario detrás de ellos debe seguir siendo miembro activo del workspace.

## Parámetros de consulta

**period** `string` (default: 30d)

Ventana del reporte: `7d`, `30d` o `90d`. Cualquier otro valor se **trata silenciosamente como `30d`** (sin error). La ventana empieza a la hora actual del día, hace N−1 días.

**timezone** `string` (default: UTC)

Zona horaria IANA usada para agrupar la serie diaria, por ejemplo `America/Sao_Paulo`. Se acepta `tz` como alias; si se envían ambos, gana `timezone`. El valor se devuelve en la respuesta.

## Ejemplo

```bash cURL theme={null}
curl "https://pilotstatus.com.br/v1/analytics/dashboard?period=7d&timezone=America/Sao_Paulo" \
  -H "x-api-key: ps_number_your_key_here"
```

```json Response (200) theme={null}
{
  "period": "7d",
  "timezone": "America/Sao_Paulo",
  "totalSent": 120,
  "totalDelivered": 115,
  "totalRead": 45,
  "totalFailed": 3,
  "totalQueued": 2,
  "deliveryRate": 95.83,
  "readRate": 39.13,
  "failureRate": 2.5,
  "responseRate": 39.13,
  "avgDeliveryTime": 1.84,
  "avgReadTime": 412.5,
  "messagesOverTime": [
    { "date": "2026-11-03", "total": 15, "queued": 0, "sent": 15, "delivered": 14, "read": 6, "failed": 1 },
    { "date": "2026-11-04", "total": 22, "queued": 0, "sent": 22, "delivered": 21, "read": 8, "failed": 1 },
    { "date": "2026-11-05", "total": 18, "queued": 0, "sent": 18, "delivered": 18, "read": 7, "failed": 0 },
    { "date": "2026-11-06", "total": 20, "queued": 0, "sent": 20, "delivered": 19, "read": 9, "failed": 1 },
    { "date": "2026-11-07", "total": 12, "queued": 0, "sent": 12, "delivered": 12, "read": 5, "failed": 0 },
    { "date": "2026-11-08", "total": 14, "queued": 0, "sent": 14, "delivered": 14, "read": 4, "failed": 0 },
    { "date": "2026-11-09", "total": 19, "queued": 2, "sent": 19, "delivered": 17, "read": 6, "failed": 0 }
  ],
  "statusDistribution": {
    "queued": 2,
    "delivered": 115,
    "read": 45,
    "failed": 3
  },
  "statusPercentages": {
    "queued": 1.67,
    "delivered": 95.83,
    "read": 37.5,
    "failed": 2.5
  },
  "totalReceived": 87,
  "topTemplates": [
    {
      "templateVersionId": "cmh1a2b3c4d5e6f7g8h9",
      "templateId": "cmh1a2b3c4d5e6f7g8h9",
      "templateName": "order_update",
      "version": null,
      "count": 64
    }
  ],
  "topOrigins": [
    {
      "origin": "API",
      "count": 95
    },
    {
      "origin": "CHAT",
      "count": 20
    }
  ]
}
```

## Campos de la respuesta

Todos los totales cuentan los mensajes **salientes** del número creados en la ventana (enviados por la API, el chat del dashboard, templates, etc.); `totalReceived` es la única cifra de entrada. Las tasas y porcentajes son números de 0 a 100, redondeados a 2 decimales, y valen `0` cuando el denominador es 0.

| Campo | Significado |
| - | - |
| `period` | La ventana usada realmente (`7d`, `30d` o `90d`). |
| `timezone` | La zona horaria solicitada (predeterminada `UTC`). |
| `totalSent` | Todos los mensajes despachados en la ventana: `totalDelivered + totalFailed + totalQueued`. |
| `totalDelivered` | Mensajes con estado `SENT`, `DELIVERED` o `READ`. |
| `totalRead` | Mensajes con estado `READ`. |
| `totalFailed` | Mensajes con estado `FAILED`. |
| `totalQueued` | Mensajes que siguen en `QUEUED`. |
| `deliveryRate` | `totalDelivered / totalSent`. |
| `readRate` | `totalRead / totalDelivered`. |
| `failureRate` | `totalFailed / totalSent`. |
| `responseRate` | El mismo valor que `readRate`. |
| `avgDeliveryTime` | Promedio de segundos desde la creación hasta `deliveredAt` (el dispositivo del destinatario confirmó el mensaje), solo sobre los mensajes **entregados** del período; `0` si no se entregó ninguno. Hasta el 2026-11-09 medía desde la creación hasta `sentAt` (el proveedor aceptó el mensaje), así que reportaba el tiempo de despacho, no el de entrega. |
| `avgReadTime` | Promedio de segundos desde `sentAt` hasta `readAt`, sobre los mensajes que fueron leídos. |
| `messagesOverTime` | Una entrada por día calendario de la ventana en `timezone` (7, 30 o 90 entradas, del más antiguo al más reciente, los días sin tráfico en cero): `date` (`YYYY-MM-DD`), `total`, `queued`, `sent` (todo lo despachado ese día), `delivered` (`SENT`/`DELIVERED`/`READ`), `read`, `failed`. |
| `statusDistribution` | Conteos: `queued`, `delivered` (incluye los leídos), `read`, `failed`. |
| `statusPercentages` | Los mismos cuatro como porcentaje de `totalSent`. `delivered` incluye `read`, así que no suman 100. |
| `totalReceived` | Mensajes entrantes recibidos por el número en la ventana. |
| `topTemplates` | Hasta 5 templates por envíos entregados: `templateVersionId` (el id del template, o su nombre en envíos antiguos), `templateId` (o `null`), `templateName`, `version` (siempre `null`), `count`. |
| `topOrigins` | Envíos entregados agrupados por origen, de mayor a menor: `API`, `CHAT`, `DASHBOARD`, `CHATWOOT`, `SYSTEM` o `APP` (enviado desde el teléfono, sin solicitud a Pilot Status). |

Los resultados se guardan en caché hasta 60 segundos por número, período y zona horaria, así que un mensaje enviado hace un momento puede tardar hasta un minuto en aparecer.

## Errores

| Status | Code | Causa |
| - | - | - |
| `400` | `WORKSPACE_ID_REQUIRED` | Key de cuenta (`ps_account_`) sin el header `x-workspace-id`. |
| `401` | — | Credencial ausente o inválida. |
| `403` | `TENANT_SCOPE_NOT_ALLOWED` | Se usó una credencial de todo el workspace sin `x-whatsapp-number-id`. |
| `403` | `NUMBER_NOT_IN_GRANT` | Token OAuth o key de cuenta restringidos a otros números. |
| `403` | `WORKSPACE_MEMBERSHIP_REQUIRED` | El usuario detrás del token o la key de cuenta no es miembro activo del workspace. |
| `404` | `NUMBER_NOT_FOUND` | `x-whatsapp-number-id` no corresponde a un número de este workspace. |
| `409` | — | La credencial no está vinculada a un número de WhatsApp (`{"error": "API key is not linked to a WhatsApp number"}`). |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.