# Template Analytics

Canonical: https://docs.bluehola.com/docs/templates-flows-media/get-v1-templates-analytics
OpenAPI: https://docs.bluehola.com/openapi.yaml

<div class="endpoint"><span class="endpoint-method endpoint-method--get">GET</span><code class="endpoint-path">/v1/templates/analytics</code></div>

Template analytics: sent / delivered / read / button clicks.

:::note[Authentication]

Send `Authorization: Bearer <API_KEY>` in the request headers; required scope: `templates:manage`. Which resources an API Key can reach is determined by its current authorization scope.

:::

## Request

Base URL: `https://api.bluehola.com`

## Response

| Status | Description |
| --- | --- |
| `200` | OK |
| `4xx` | Client error |

### 200 response schema

```json
{
  "$ref": "#/components/schemas/TemplateAnalyticsResult"
}
```

For the common error envelope and how to handle it, see [Error Codes](../guides/error-codes.md).

## Notes

Query parameters: `wabaId`, `templateIds` (**local** template ids, comma-separated), `start`/`end` (unix seconds), `metricTypes` (optional, default `SENT,DELIVERED,READ,CLICKED`).

#### You must enable it first

Call `POST /v1/templates/analytics/enable` for this WABA once beforehand, or Meta returns an error directly. That is a one-time confirmation to Meta, and **once enabled it cannot be turned off**.

#### Read the warnings in the response

This endpoint carries several hard limits on Meta's side, and rather than swallowing them silently we write them into `warnings` honestly:

- **At most 10 templates per call**; anything beyond that, only the first 10 are used;
- **Read and button-click data are only kept for 7 days**; over a longer span, those two metrics will be 0 for the earlier part (not a bug);
- **`COST` is never returned for a WABA on shared platform credit** (a Meta restriction, and that describes all of our customers). Ask BlueMedia for your spend figures;
- A template id outside the current authorization scope, or one that has never been synced with a Meta id, is dropped and called out by name in `warnings`.

Button-click data is only available for `MARKETING` / `UTILITY` category templates; WABAs in the EU and Japan are not supported (both Meta restrictions).
