# 20. API get thống kê tin nhắn gửi ra của nhân viên theo từng ngày

## 1. API

**Domain:** [**https://apiring.antbuddy.com**](https://apiring.antbuddy.com)

&#x20;`GET /reports/omni/messages/sent-by-user-daily`

## 2. Mô tả

Thống kê số lượng tin nhắn gửi ra theo từng nhân viên, gom theo từng ngày trong khoảng thời gian lọc.

## 3. Headers

* <mark style="color:red;">apikey</mark> (bắt buộc ): API key của API Ring.

## 4. Query Parameters

<table><thead><tr><th width="187.5999755859375">Tham số</th><th width="123.199951171875">Kiểu dữ liệu</th><th width="119.199951171875">Bắt buộc</th><th>Giải thích</th></tr></thead><tbody><tr><td>startDate</td><td>String</td><td>Y</td><td>Thời gian bắt đầu, định dạng ISO date.<br>Ví dụ: <code>2026-03-27T00:00:00.000Z</code><br> </td></tr><tr><td>endDate</td><td>String</td><td>Y</td><td>Thời gian kết thúc, định dạng ISO date.<br>Ví dụ: <code>2026-03-27T23:59:00.000Z</code></td></tr><tr><td>pageIds</td><td>string[]</td><td>Y</td><td>Danh sách pageId, ngăn cách bằng dấu phẩy.<br>Ví dụ:  <code>['123','456']</code></td></tr><tr><td>channel</td><td>string</td><td>N</td><td>Kênh lọc: FACEBOOK, INSTAGRAM, ZALO, WHATSAPP, ...</td></tr><tr><td>userIds</td><td>string[]</td><td>N</td><td>Danh sách userId, ngăn cách bằng dấu phẩy.<br>Ví dụ:  <code>['123','456']</code></td></tr></tbody></table>

## 5. Response — 200 OK

```json
{
  "success": true,
  "totalSent": 30,
  "totalByDate": [
    { "date": "2026-03-20", "dateDisplay": "20/03/2026", "totalSent": 12 },
    { "date": "2026-03-21", "dateDisplay": "21/03/2026", "totalSent": 18 }
  ],
  "users": [
    {
      "user": {
        "_id": "67d8f7c81e8f98a1b2c3d4e5",
        "firstname": "An",
        "lastname": "Nguyen",
        "email": "an.nguyen@example.com",
        "avatar": "",
        "displayName": "An Nguyen"
      },
      "totalSent": 16,
      "byDate": [
        { "date": "2026-03-20", "dateDisplay": "20/03/2026", "totalSent": 7 },
        { "date": "2026-03-21", "dateDisplay": "21/03/2026", "totalSent": 9 }
      ]
    }
  ]
}

```

## 6. Mô tả các trường Response

* <mark style="color:red;">success</mark> — Boolean, true khi thành công.
* <mark style="color:red;">totalSent</mark> — Tổng số tin nhắn gửi ra trong khoảng thời gian.
* <mark style="color:red;">totalByDate</mark> — Mảng thống kê tổng tin nhắn theo từng ngày.
* <mark style="color:red;">users</mark> — Mảng thống kê theo từng nhân viên, chứa thông tin user và byDate.

## 7. Mã lỗi

<table><thead><tr><th width="145.078125">Mã lỗi</th><th>Mô tả</th></tr></thead><tbody><tr><td>400</td><td>Thiếu/sai tham số lọc (startDate, endDate, userIds không hợp lệ, không có page subscribe, ...).</td></tr><tr><td>500</td><td>Lỗi hệ thống.</td></tr></tbody></table>

## 8. Ví dụ cURL

**Ví dụ cơ bản:**

```
curl --request GET \
  'https://YOUR_DOMAIN/reports/omni/messages/sent-by-user-daily?startDate=2026-03-01T00:00:00.000Z&endDate=2026-03-27T23:59:59.999Z' \
  --header 'apikey: YOUR_API_KEY'
```

**Ví dụ đầy đủ (có lọc pageIds, channel, userIds):**

```
curl --request GET \
  'https://YOUR_DOMAIN/reports/omni/messages/sent-by-user-daily
   ?startDate=2026-03-01T00:00:00.000Z
   &endDate=2026-03-27T23:59:59.999Z
   &pageIds=123456789,987654321
   &channel=WHATSAPP
   &userIds=67d8f7c81e8f98a1b2c3d4e5,67d8f7c81e8f98a1b2c3d4e6' \
  --header 'apikey: YOUR_API_KEY'
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.antbuddy.com/huong-dan-tich-hop-api-team-technical-api-integration-guide-technical-team/antcrm/20.-api-get-thong-ke-tin-nhan-gui-ra-cua-nhan-vien-theo-tung-ngay.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
