# Get WhatsApp analytics

> POST https://api.nabrah.ai/api/ext/omni_v2/whatsapp/analytics

Group: WhatsApp. Page: https://www.nabrah.ai/en/docs/api-reference/whatsapp/get-whatsapp-analytics

Get aggregated WhatsApp conversation analytics for a date window. The request body specifies the time range (`since`/`until`) and optionally an `inbox_id`; if `inbox_id` is omitted, the analytics combine every WhatsApp number of the project. The response includes a `summary` of totals (conversations by status, incoming/outgoing message counts, average first-response and resolution times), time-series `trend` arrays, per-assignee metrics, and an `inboxes` breakdown with one row per WhatsApp number.

## Request body

All timestamps are ISO 8601 date-times.

- **since / until**: The inclusive start and end of the analytics window. Fields: `since`, `until`.
- **inbox_id**: Optional WhatsApp inbox UUID to scope the analytics to one number. If omitted, every WhatsApp number of the project is combined: counts are summed and average times are weighted by volume. Get the value from GET /api/ext/omni_v2/whatsapp/inboxes. An `inbox_id` that is not one of the project's WhatsApp numbers returns 404, as does a project with no WhatsApp number connected. Fields: `inbox_id`.

## Response shape

- **summary**: Totals for the window: conversation counts by status, incoming/outgoing message counts, and average first-response and resolution times (seconds). Fields: `total_conversations`, `open_conversations`, `pending_conversations`, `resolved_conversations`, `snoozed_conversations`, `incoming_messages`, `outgoing_messages`, `avg_first_response_time`, `avg_resolution_time`.
- **trends**: Time-series arrays of `{ timestamp, value }` points for conversation volume and inbound/outbound message volume. Fields: `conversations_trend`, `incoming_trend`, `outgoing_trend`.
- **assignee_metrics**: Per-agent breakdown of conversation handling and timing. It always covers the whole project, even when `inbox_id` is sent. Fields: `agent_id`, `agent_name`, `agent_email`, `conversations_count`, `resolved_conversations_count`, `avg_first_response_time`, `avg_resolution_time`, `avg_reply_time`.
- **inboxes**: One row per WhatsApp number in the result, with its totals for the window. Fields: `inbox_id`, `name`, `phone_number`, `conversations`, `resolutions`, `incoming_messages`, `outgoing_messages`, `avg_first_response_time`, `avg_resolution_time`.

## Authorization

- `X-API-Key` (string, header, required): your workspace API key.

## Body (application/json)

### Example: Analytics by date range

Scope analytics to a specific WhatsApp inbox and date window.

```json
{
  "since": "2026-06-01T00:00:00.000Z",
  "until": "2026-06-23T23:59:59.000Z",
  "inbox_id": "00000000-0000-4000-8000-000000000000"
}
```

### Example: All numbers (no inbox_id)

Omit inbox_id to combine every WhatsApp number of the project.

```json
{
  "since": "2026-06-01T00:00:00.000Z",
  "until": "2026-06-23T23:59:59.000Z"
}
```

## Response

### 200 Successful Response

Content type: `application/json`

```json
{
  "summary": {
    "total_conversations": 0,
    "open_conversations": 0,
    "pending_conversations": 0,
    "resolved_conversations": 0,
    "snoozed_conversations": 0,
    "incoming_messages": 0,
    "outgoing_messages": 0,
    "avg_first_response_time": 0,
    "avg_resolution_time": 0
  },
  "conversations_trend": [
    {
      "timestamp": 0,
      "value": 0
    }
  ],
  "incoming_trend": [
    {
      "timestamp": 0,
      "value": 0
    }
  ],
  "outgoing_trend": [
    {
      "timestamp": 0,
      "value": 0
    }
  ],
  "assignee_metrics": [
    {
      "agent_id": 0,
      "agent_name": "string",
      "agent_email": "string",
      "conversations_count": 0,
      "resolved_conversations_count": 0,
      "avg_first_response_time": 0,
      "avg_resolution_time": 0,
      "avg_reply_time": 0
    }
  ],
  "inboxes": [
    {
      "inbox_id": "00000000-0000-4000-8000-000000000000",
      "name": "string",
      "phone_number": "string",
      "conversations": 0,
      "resolutions": 0,
      "incoming_messages": 0,
      "outgoing_messages": 0,
      "avg_first_response_time": 0,
      "avg_resolution_time": 0
    }
  ]
}
```

### 422 Validation Error

Content type: `application/json`

```json
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string"
    }
  ]
}
```

## Request examples

### cURL

```bash
curl --request POST \
  --url 'https://api.nabrah.ai/api/ext/omni_v2/whatsapp/analytics' \
  --header 'X-API-Key: <your-api-key>' \
  --header 'Content-Type: application/json' \
  --data '{
  "since": "2026-06-01T00:00:00.000Z",
  "until": "2026-06-23T23:59:59.000Z",
  "inbox_id": "00000000-0000-4000-8000-000000000000"
}'
```

### Python

```python
import requests

url = "https://api.nabrah.ai/api/ext/omni_v2/whatsapp/analytics"
headers = {
    "X-API-Key": "<your-api-key>",
}
payload = {
    "since": "2026-06-01T00:00:00.000Z",
    "until": "2026-06-23T23:59:59.000Z",
    "inbox_id": "00000000-0000-4000-8000-000000000000"
}

response = requests.post(url, headers=headers, json=payload)
response.raise_for_status()
print(response.json())
```

### JavaScript

```javascript
const response = await fetch("https://api.nabrah.ai/api/ext/omni_v2/whatsapp/analytics", {
  method: "POST",
  headers: {
    "X-API-Key": "<your-api-key>",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "since": "2026-06-01T00:00:00.000Z",
    "until": "2026-06-23T23:59:59.000Z",
    "inbox_id": "00000000-0000-4000-8000-000000000000"
  }),
});

const data = await response.json();
console.log(data);
```

### Go

```go
package main

import (
	"fmt"
	"io"
	"net/http"
	"strings"
)

func main() {
	payload := strings.NewReader(`{
  "since": "2026-06-01T00:00:00.000Z",
  "until": "2026-06-23T23:59:59.000Z",
  "inbox_id": "00000000-0000-4000-8000-000000000000"
}`)

	req, _ := http.NewRequest("POST", "https://api.nabrah.ai/api/ext/omni_v2/whatsapp/analytics", payload)
	req.Header.Set("X-API-Key", "<your-api-key>")
	req.Header.Set("Content-Type", "application/json")

	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()

	out, _ := io.ReadAll(res.Body)
	fmt.Println(string(out))
}
```
