# Tổng quan hệ thống

Trang chủ: <https://esms.vn/>

![](/files/CG2p3XRS9qCFIlsX1fDJ)

Chi tiết các dịch vụ

<div><figure><img src="/files/6FXs5c630aE40VrskW1E" alt=""><figcaption></figcaption></figure> <figure><img src="/files/DB2JOM63GLzxafrqsXsh" alt=""><figcaption></figcaption></figure> <figure><img src="/files/i7V4e1Jh4acN9l93DkI6" alt=""><figcaption></figcaption></figure></div>


# Giới thiệu hệ thống API

<figure><img src="/files/Ov5GMPbHWFBjOdOf581e" alt=""><figcaption></figcaption></figure>

* Nếu website hoặc hệ thống của bạn cần tính năng gửi SMS, Zalo, Viber đến điện thoại — chẳng hạn như gửi mã xác nhận khi đăng ký tài khoản, phần mềm quản lý nhân sự cần thông báo lịch họp đến nhân viên, hay gửi lời chúc mừng sinh nhật khách hàng,... thì API của eSMS là giải pháp hoàn hảo.

* Hệ thống API của chúng tôi được thiết kế để đảm bảo tốc độ cao, đơn giản, đáng tin cậy và dễ dàng tích hợp vào bất kỳ nền tảng nào.

* Hỗ trợ kết nối với mọi ngôn ngữ lập trình phổ biến như C#, Java, ASP.NET, PHP.


# Cơ chế hoạt động

 Kết nối thông qua HTTP/HTTPS Request: POST/GET

 Xác thực: các request của bạn sẽ được hệ thống xác thực thông qua APIkey và SecretKey, 2 key này sẽ được cấp sau khi bạn đăng ký tài khoản tại eSMS.vn


# Lấy thông tin ApiKey và SecretKey

Trước khi sử dụng eSMS API vui lòng đăng ký tài khoản tại [esms.vn](https://esms.vn/) để lấy ApiKey và Secretkey. (Có ngay 5.000 VNĐ dùng thử)

Sau khi tạo xong tài khoản, quý khách đăng nhập và làm theo hướng dẫn ở bên dưới để lấy ApiKey và Secretkey.

![Truy cập vào menu Quản lý API](/files/Cr68WnS3DCqYjrYZ9nFZ)

![Sử dụng ApiKey và SecretKey để gửi tin, có thể tạo mới Key](/files/6m3K7RpJfCWadB2cOhRl)


# Hàm gửi tin


# Tin nhắn SMS OTP/CSKH (Khuyên Dùng)

LƯU Ý QUAN TRỌNG:

* **Liên hệ nhân viên chăm sóc khách hàng nếu muốn gửi tên thương hiêu và nội dung riêng của bạn.**
* **Nội dung (Content) tin nhắn test phải đúng như request mẫu, đổi nội dung tin sẽ thất bại.**
* **Thay đổi giá trị Brandname và Content ở request mẫu có thể tin nhắn không gửi được nếu chưa được đăng ký với nhà mạng.**
* Đổi giá trị CODE ở nội dung để test nhiều tin, tránh bị nhà mạng chặn tin spam.

## HTTP request

<mark style="color:yellow;">**`POST`**</mark> **<https://rest.esms.vn/MainService.svc/json/SendMultipleMessage\\_V4\\_post\\_json/>**

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location --request POST 'https://rest.esms.vn/MainService.svc/json/SendMultipleMessage_V4_post_json/' \
--header 'Content-Type: application/json' \
--data-raw '{
   "ApiKey": "APIKEYCUABAN",
   "Content": "CODE la ma xac minh dang ky Baotrixemay cua ban",
   "Phone": "0901888484",
   "SecretKey": "SECRETKEYCUABAN",
   "Brandname": "Baotrixemay",
   "SmsType": "2",
   "IsUnicode": "0",
   "campaignid": "Cảm ơn sau mua hàng tháng 7",
   "RequestId": "c82cd356-bf49-4113-9466-65a7f6359c96",
   "CallbackUrl": "https://esms.vn/webhook/"
// Brandname và Content trên dùng để thử nghiệm. Chỉ gửi được với nội dung này, thay đổi sẽ sai mẫu và tin nhắn không được gửi.
// CODE có thể tùy chỉnh, tối đa 8 ký tự gồm số hoặc chữ. Ví dụ: 2803 la ma xac minh dang ky Baotrixemay cua ban
// Mỗi số điện thoại và Content giống nhau chỉ được phép gửi một tin trong 5 phút. Hãy thay đổi số điện thoại hoặc Content để thử nghiệm các tin nhắn liên tiếp.
// Cần dùng Brandname/Content khác, hãy liên hệ nhân viên kinh doanh tại https://esms.vn/ (thông tin ở bên phải màn hình sau khi đăng nhập).
}'
```

* **Cấu trúc body của request:**&#x20;

<table><thead><tr><th width="148">Tham số</th><th width="136">Kiểu dữ liệu</th><th width="134" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey eSMS cung cấp.</td></tr><tr><td>Content</td><td>string</td><td>true</td><td>Nội dung tin nhắn.</td></tr><tr><td>Phone</td><td>string</td><td>true</td><td>Số điện thoại nhận tin nhắn.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>SecretKey eSMS cung cấp.</td></tr><tr><td>Brandname</td><td>string</td><td>true</td><td>Tên Brandname (tên công ty hay tổ chức khi gửi tin sẽ hiển thị trên tin nhắn). <strong>Chú ý: Phải đăng ký trước khi sử dụng.</strong></td></tr><tr><td>SmsType</td><td>string</td><td>true</td><td>Loại tin nhắn ID 2 là CSKH.</td></tr><tr><td>IsUnicode</td><td>string</td><td>false</td><td><p>Gửi nội dung có dấu:<br>1: Có dấu.</p><p>0: Không dấu.</p></td></tr><tr><td>Sandbox</td><td>string</td><td>false</td><td>1: Tin gửi ở môi trường test, dùng để kiểm tra kết nối và các thông số tích hợp, không về tin nhắn, không trừ tiên. <br>0: Tin gửi ở môi trường bình thường, có về tin nhắn.</td></tr><tr><td>RequestId</td><td>string</td><td>false</td><td>ID đối tác truyền sang để chặn trùng và đối soát khi cần.<br>Độ dài tối đa 50 ký tự.<br><strong>Mỗi RequestId truyền sang có hiệu lực chặn trong 24h.</strong></td></tr><tr><td>SendDate</td><td>string</td><td>false</td><td>Thời gian hẹn gửi của tin. <br>Không truyền khi tin muốn tin nhắn gửi đi liền.<br>Định dạng: yyyy-mm-dd hh:MM:ss</td></tr><tr><td>campaignid</td><td>string</td><td>false</td><td>Tên chiến dịch.</td></tr><tr><td>CallbackUrl</td><td>string</td><td>false</td><td>URL nhận kết quả gửi tin. <br>Xem body mẫu <a href="https://samplefordevelopers.esms.vn/#20f85e1f-3d9e-4ff4-bc4f-8d9c9edbc88a">ở đây</a>.<br>Xem chi tiết <a href="/pages/HxTrJlnDLexPUwac9BWb">ở đây</a>.</td></tr></tbody></table>

***

* **Response**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d533459ee42b2b9525ba9eabf6a8156"
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="104" %}

```json
{
    "CodeResult": "104",
    "CountRegenerate": 0,
    "ErrorMessage": "Brand name code is not exist"
}
```

**Brandname truyền chưa đúng hoặc chưa được active.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}

{% tab title="124" %}

```json
{
    "CodeResult": "124",
    "CountRegenerate": 0,
    "ErrorMessage": "Request exist 1",
    "SendStatus": "5"
}
```

**RequestId đã tồn tại.**
{% endtab %}

{% tab title="146" %}
{% code overflow="wrap" %}

```json
{
  "CodeResult": "146",
  "CountRegenerate": 0,
  "ErrorMessage": "Sai template Brandname CSKH",
  "SMSID": "3f5ec8c71c4a4ccea311f731dfeaa133156"
}
```

{% endcode %}

**Template CSKH chưa được đăng ký.**
{% endtab %}

{% tab title="99" %}

```json
{
  "error": "Invalid request"
}
```

**Kiểm tra lại thông tin kết nối hoặc liên hệ bộ phận chăm sóc khách hàng để được hỗ trợ khi gặp lỗi này.**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

<table><thead><tr><th width="150.86663818359375">Thuộc tính</th><th width="135.8665771484375">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Request được gửi đến ESMS thành công.<br><br><strong>Lưu ý:</strong> Mã phản hồi <strong>100</strong> chỉ xác nhận rằng yêu cầu đã được gửi thành công đến hệ thống ESMS, <strong>không phản ánh việc tin nhắn đã được gửi đến số điện thoại người nhận hay chưa</strong>.<br>Để theo dõi trạng thái cuối cùng của tin nhắn, quý khách vui lòng truyền thêm tham số <strong>CallbackUrl</strong>; hệ thống ESMS sẽ tự động gửi phản hồi (callback) đến địa chỉ này khi có trạng thái cuối của tin.</td></tr><tr><td>SMSID</td><td>string</td><td>ID tin nhắn do esms trả về.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi).</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [**Link code mẫu**](https://samplefordevelopers.esms.vn/#850974b9-12cf-46f5-946c-e8e15aa3585b)**.**


# Tin nhắn Zalo

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> [https://rest.esms.vn/MainService.svc/json/SendZaloMessage\_V6/](http://rest.esms.vn/MainService.svc/json/SendZaloMessage_V6/)

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

{% code overflow="wrap" %}

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/SendZaloMessage_V6/' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey": "APIKEYCUABAN",
    "SecretKey": "SECRETKEYCUABAN",
    "OAID": "4097311281936189049",
    "Phone": "0901888484",
    "TempData": {
        "customer_name": "Đinh Thái Hà",
        "order_code": "HD00001",
        "address": "140-142 Đường Số 1, KDC Vạn Phúc, Hiệp Bình Phước, Thủ Đức",
        "phone": "0901888484",
        "email": "dinhthaiha@vihatgroup.com",
        "product_name": "Gói duy trì OA Zalo Premium 1 năm",
        "quantity": "1",
        "payment_amount": "4308000",
        "delivery_date": "01/08/2024"
    },
    "TempID":  "200607",
    "SendingMode":"1",
    "campaignid":  "Xác nhận mua hàng",
    "RequestId": "96accf59-0c41-4bc7-a5c4-4a466c2e41c2",
    "CallbackUrl": "https://esms.vn/webhook/"
}'
```

{% endcode %}

* **Cấu trúc body của request:**

<table><thead><tr><th width="152">Tham số</th><th width="124.4666748046875">Kiểu dữ liệu</th><th width="123.13330078125" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>Phone</td><td>string</td><td>true</td><td>Số điện thoại người nhận.</td></tr><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey eSMS cung cấp.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>SecretKey eSMS cung cấp.</td></tr><tr><td>OAID</td><td>string</td><td>true</td><td>Zalo OA ID, là ID của trang Zalo Offical Account của doanh nghiệp. Doanh nghiệp cần đăng nhập vào trang quản trị của Zalo OA để lấy phần Zalo OA ID này. <br><strong>Chú ý: sẽ phải đăng ký trước khi sử dụng.</strong></td></tr><tr><td>TempData</td><td>JSON object</td><td>true</td><td>Các thuộc tính của template mà khách hàng eSMS đã đăng ký với Zalo.<br><strong>Chú ý: Cấu trúc TempData</strong> <strong>được quy định riêng ứng với từng template.</strong></td></tr><tr><td>SendDate</td><td>string</td><td>false</td><td>Thời gian hẹn gửi của tin. <br>Không truyền khi tin muốn tin nhắn gửi đi liền.<br>Định dạng: yyyy-mm-dd hh:MM:ss.</td></tr><tr><td>TempID </td><td>string</td><td>true</td><td>Template của Zalo OA mà khách hàng đăng kí với eSMS.</td></tr><tr><td>campaignid</td><td>string</td><td>false</td><td>Tên chiến dịch gửi tin, tối đa 254 ký tự.</td></tr><tr><td>RequestId</td><td>string</td><td>false</td><td>ID đối tác truyền sang để chặn trùng và đối soát khi cần.<br>Độ dài tối đa 50 ký tự.<br><strong>Mỗi RequestId truyền sang có hiệu lực chặn trong 24h.</strong></td></tr><tr><td>Sandbox</td><td>string</td><td>false</td><td>1: Tin gửi ở môi trường test, dùng để kiểm tra kết nối và các thông số tích hợp, không về tin nhắn, không trừ tiền.<br>0: Tin gửi ở môi trường bình thường, có về tin nhắn.</td></tr><tr><td>CallbackUrl</td><td>string</td><td>false</td><td>URL nhận kết quả gửi tin.<br>Xem body mẫu <a href="https://samplefordevelopers.esms.vn/#b98ca55e-3001-4446-b5bb-a4ab86127b0b">ở đây</a><strong>.</strong> <br>Xem chi tiết <a href="/pages/HxTrJlnDLexPUwac9BWb">ở đây</a><strong>.</strong></td></tr><tr><td>SendingMode</td><td>string</td><td>false</td><td>Chế độ gửi:<br><kbd><strong>1</strong></kbd> (Default): Gửi thường, tin ZNS được gửi theo cơ chế thông thường.<br><kbd><strong>3</strong></kbd>: Gửi vượt hạn mức, cho phép OA gửi tin ZNS tag 3 vượt hạn mức.<br><br><strong>Lưu ý</strong>: Chế độ Gửi vượt hạn mức (SendingMode = 3) chỉ áp dụng cho các OA được whitelist. Vui lòng liên hệ đội ngũ CSKH nếu có nhu cầu gửi ở chế độ Gửi vượt hạn mức.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d8e0f1f0702544b2acb456ca9ccfd111250"
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}

{% tab title="789" %}

```json
{
    "CodeResult": "789",
    "CountRegenerate": 0,
    "ErrorMessage": "TemplateId is not config"
}
```

**Template chưa được cấu hình cho OA ID bạn đang sử dụng.**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

<table><thead><tr><th width="195">Thuộc tính</th><th width="156">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Request được gửi đến ESMS thành công.<br><br><strong>Lưu ý:</strong> Mã phản hồi <strong>100</strong> chỉ xác nhận rằng yêu cầu đã được gửi thành công đến hệ thống ESMS, <strong>không phản ánh việc tin nhắn đã được gửi đến số điện thoại người nhận hay chưa</strong>.<br>Để theo dõi trạng thái cuối cùng của tin nhắn, quý khách vui lòng truyền thêm tham số <strong>CallbackUrl</strong>; hệ thống ESMS sẽ tự động gửi phản hồi (callback) đến địa chỉ này khi có trạng thái cuối của tin.</td></tr><tr><td>SMSID</td><td>string</td><td>ID của tin nhắn mới được tạo ra trên hệ thống eSMS. Dùng ID này để query lấy trạng thái tin nhắn.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi).</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu của các ngôn ngữ ở link**</mark>*<mark style="color:yellow;">:</mark> [**Link code mẫu .**](https://samplefordevelopers.esms.vn/#2d996c73-a5c2-45ca-973e-d18aabb960c7)


# Tin nhắn Zalo gửi bằng UID

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark>   <mark style="color:$primary;"><https://rest.esms.vn/MainService.svc/json/SendZaloMessage\\_V6/zalo\\_uid/></mark>

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

{% code overflow="wrap" %}

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/SendZaloMessage_V6/zalo_uid/' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey": "APIKEYCUABAN",
    "SecretKey": "SECRETKEYCUABAN",
    "OAID": "4097311281936189049",
    "ZaloUid": "31215806834323092",
    "TempData": {
        "name": "Đinh Thái Hà",
        "order_code": "HD00001",
        "address": "140-142 Đường Số 1, KDC Vạn Phúc, Hiệp Bình Phước, Thủ Đức",
        "phone_number": "0901888484",
        "product": "Màn hình máy tính",
        "number": "1",
        "number1": "1.500.000",
        "note": "Đặt hàng tại cửa hàng"
    },
    "TempID":  "540679",
    "campaignid":  "Xác nhận mua hàng",
    "RequestId": "96accf59-0c41-4bc7-a5c4-4a466c2e41c2",
    "CallbackUrl": "https://esms.vn/webhook/"
}'
```

{% endcode %}

* **Cấu trúc body của request:**

<table><thead><tr><th width="123.555419921875">Tham số</th><th width="124.4666748046875">Kiểu dữ liệu</th><th width="123.13330078125" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey eSMS cung cấp.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>SecretKey eSMS cung cấp.</td></tr><tr><td>OAID</td><td>string</td><td>true</td><td>Zalo OA ID, là ID của trang Zalo Offical Account của doanh nghiệp. Doanh nghiệp cần đăng nhập vào trang quản trị của Zalo OA để lấy phần Zalo OA ID này. <br><strong>Chú ý: sẽ phải đăng ký trước khi sử dụng.</strong></td></tr><tr><td>ZaloUid</td><td>string</td><td>true</td><td>Zalo Userid của người nhận.</td></tr><tr><td>TempData</td><td>JSON object</td><td>true</td><td>Các thuộc tính của template mà khách hàng eSMS đã đăng ký với Zalo.<br><strong>Chú ý: Cấu trúc TempData</strong> <strong>được quy định riêng ứng với từng template.</strong></td></tr><tr><td>TempID </td><td>string</td><td>true</td><td>Template của Zalo OA mà khách hàng đăng kí với eSMS.</td></tr><tr><td>campaignid</td><td>string</td><td>false</td><td>Tên chiến dịch gửi tin, tối đa 254 ký tự.</td></tr><tr><td>RequestId</td><td>string</td><td>false</td><td>ID đối tác truyền sang để chặn trùng và đối soát khi cần.<br>Độ dài tối đa 50 ký tự.<br><strong>Mỗi RequestId truyền sang có hiệu lực chặn trong 24h.</strong></td></tr><tr><td>Sandbox</td><td>string</td><td>false</td><td>1: Tin gửi ở môi trường test, dùng để kiểm tra kết nối và các thông số tích hợp, không về tin nhắn, không trừ tiền.<br>0: Tin gửi ở môi trường bình thường, có về tin nhắn.</td></tr><tr><td>CallbackUrl</td><td>string</td><td>false</td><td>URL nhận kết quả gửi tin.<br>Xem body mẫu <a href="https://samplefordevelopers.esms.vn/#b98ca55e-3001-4446-b5bb-a4ab86127b0b">ở đây</a><strong>.</strong> <br>Xem chi tiết <a href="https://developers.esms.vn/esms-api/callback-url#callback-mau-cho-loai-tin-zalo-gui-bang-uid">ở đây</a><strong>.</strong></td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d8e0f1f0702544b2acb456ca9ccfd111250"
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}

{% tab title="852" %}

```json
{
    "CodeResult": "852",
    "CountRegenerate": 0,
    "ErrorMessage": "Zalo UID Invalid"
}
```

**ZaloUid vượt quá ký tự cho phép, giới hạn 20 ký tự.**
{% endtab %}

{% tab title="853" %}

```jsonc
{
    "CodeResult": "853",
    "CountRegenerate": 0,
    "ErrorMessage": "Missing ZaloUid"
}
```

**Thiếu trường ZaloUid**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

<table><thead><tr><th width="195">Thuộc tính</th><th width="156">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Request được gửi đến ESMS thành công.<br><br><strong>Lưu ý:</strong> Mã phản hồi <strong>100</strong> chỉ xác nhận rằng yêu cầu đã được gửi thành công đến hệ thống ESMS, <strong>không phản ánh việc tin nhắn đã được gửi đến số điện thoại người nhận hay chưa</strong>.<br>Để theo dõi trạng thái cuối cùng của tin nhắn, quý khách vui lòng truyền thêm tham số <strong>CallbackUrl</strong>; hệ thống ESMS sẽ tự động gửi phản hồi (callback) đến địa chỉ này khi có trạng thái cuối của tin.</td></tr><tr><td>SMSID</td><td>string</td><td>ID của tin nhắn mới được tạo ra trên hệ thống eSMS. Dùng ID này để query lấy trạng thái tin nhắn.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi).</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu của các ngôn ngữ ở link**</mark>*<mark style="color:yellow;">:</mark> [**Link code mẫu .**](https://samplefordevelopers.esms.vn/#e87c19af-0679-40bc-9ec5-d369800be08d)


# Tin nhắn đa kênh: Zalo => SMS OTP/CSKH

Giải pháp Multi-Channel Messaging API cho phép bạn gửi tin nhắn đến khách hàng bằng tin ZNS và tự động gửi tin SMS nếu tin ZNS gửi thất bại.

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> <https://rest.esms.vn/MainService.svc/json/MultiChannelMessage/><br>

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

{% code overflow="wrap" %}

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/MultiChannelMessage/' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey": "{{ApiKey}}",
    "SecretKey": "{{SecretKey}}",
    "Phone": "0901888484",
    "Channels": [
        "zalo",
        "sms"
    ],
    "Data": [
        {
            "TempID": "205644",
            "Params": [
                "686868"
            ],
            "OAID": "4097311281936189049",
            "campaignid": "Gửi OTP",
            "CallbackUrl": "https://esms.vn/webhook/",
            "RequestId": "c82cd356-bf49-4113-9466-65a7f6359c97",
            "Sandbox":"0",
            "SendingMode": "1"
        },
        {
            "Content": "686868 la ma xac minh dang ky Baotrixemay cua ban",
            "IsUnicode": "0",
            "SmsType": "2",
            "Brandname": "Baotrixemay",
            "CallbackUrl": "https://esms.vn/webhook/",
            "RequestId": "c82cd356-bf49-4113-9466-65a7f6359c98",
            "Sandbox":"0"
        }
    ]
}'
```

{% endcode %}

* **Cấu trúc body của request:**

<table><thead><tr><th width="122.13330078125">Tham số</th><th width="135">Kiểu dữ liệu</th><th width="123.5333251953125" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey </td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Secretkey của tài khoản.</td></tr><tr><td>Phone</td><td>string</td><td>true</td><td>Số điện thoại nhận tin.</td></tr><tr><td>Channels</td><td>string</td><td>true</td><td>Các kênh đa kênh<br><strong>Giá trị này không thay đổi.</strong><br><strong>Không thay đổi thứ tự, không bỏ bớt kênh.</strong></td></tr><tr><td>Data</td><td>array</td><td>true</td><td>Cấu hình gửi tin của kênh ZNS và SMS.</td></tr></tbody></table>

**Cấu trúc thuộc tính Data\[0]**

<table><thead><tr><th width="130.244384765625">Tham số</th><th width="116.2667236328125">Kiểu dữ liệu</th><th width="125.5333251953125" data-type="checkbox">Tinh bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>TempID</td><td>string</td><td>true</td><td>Template của Zalo OA mà khách hàng đăng kí với eSMS.</td></tr><tr><td>Params</td><td>array</td><td>true</td><td><p>Giá trị cần truyền cho các biến trong Template *Lưu ý:</p><ol><li>Các tham số truyền vào phải đúng thứ tự như template bạn đăng ký.</li><li>Nếu tham số trùng nhau chỉ cần truyền vào một tham số.</li></ol></td></tr><tr><td>OAID</td><td>string</td><td>true</td><td>Zalo OA ID, là ID của trang Zalo Offical Account của doanh nghiệp. Doanh nghiệp cần đăng nhập vào trang quản trị của Zalo OA để lấy phần Zalo OA ID này. <strong>Chú ý: sẽ phải đăng ký trước khi sử dụng.</strong></td></tr><tr><td>campaignid</td><td>string</td><td>false</td><td>Tên chiến dịch gửi tin, tối đa 254 ký tự</td></tr><tr><td>CallbackUrl</td><td>string</td><td>false</td><td>Hàm gửi tin này sẽ truyền link callback riêng cho từng loại tin nhắn. URL nhận kết quả gửi tin. <br>Xem body mẫu ZNS <a href="https://samplefordevelopers.esms.vn/#b98ca55e-3001-4446-b5bb-a4ab86127b0b">ở đây</a>. <br>Xem body mẫu SMS <a href="https://samplefordevelopers.esms.vn/#20f85e1f-3d9e-4ff4-bc4f-8d9c9edbc88a">ở đây</a>. <br>Xem chi tiết <a href="https://developers-v2.esms.vn/esms-api/callback-url">ở đây</a>.</td></tr><tr><td>RequestId</td><td>string</td><td>false</td><td>ID đối tác truyền sang để chặn trùng và đối soát khi cần.<br>Độ dài tối đa 50 ký tự.<br><strong>Mỗi RequestId truyền sang có hiệu lực chặn trong 24h.</strong></td></tr><tr><td>Sandbox</td><td>string</td><td>false</td><td>1: Tin gửi ở môi trường test, dùng để kiểm tra kết nối và các thông số tích hợp, không về tin nhắn, không trừ tiền.<br>0: Tin gửi ở môi trường bình thường, có về tin nhắn.</td></tr><tr><td>SendingMode</td><td>string</td><td>false</td><td>Chế độ gửi: <br><kbd><strong>1</strong></kbd> (Default): Gửi thường, tin ZNS được gửi theo cơ chế thông thường. <br><kbd><strong>3</strong></kbd>: Gửi vượt hạn mức, cho phép OA gửi tin ZNS tag 3 vượt hạn mức. <br><br><strong>Lưu ý</strong>: Chế độ Gửi vượt hạn mức (SendingMode = 3) chỉ áp dụng cho các OA được whitelist. Vui lòng liên hệ đội ngũ CSKH nếu có nhu cầu gửi ở chế độ Gửi vượt hạn mức.</td></tr></tbody></table>

***

**Cấu trúc thuộc tính Data\[1]**

<table><thead><tr><th width="127.22222900390625">Tham số</th><th width="137.5555419921875">Kiểu dữ liệu</th><th width="124.5555419921875" data-type="checkbox">Tinh bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>Content</td><td>string</td><td>true</td><td>Nội dung tin nhắn.</td></tr><tr><td>IsUnicode</td><td>string</td><td>false</td><td>Gửi tin nhắn có dấu<br>0: Gửi tin không dấu.<br>1: Gửi tin nhắn có dấu.</td></tr><tr><td>SmsType</td><td>string</td><td>true</td><td>2: Tin CSKH</td></tr><tr><td>Brandname</td><td>string</td><td>true</td><td>Tên Brandname (tên công ty hay tổ chức khi gửi tin sẽ hiển thị trên tin nhắn đó). <br><strong>Chú ý: sẽ phải đăng ký trước khi sử dụng.</strong></td></tr><tr><td>CallbackUrl</td><td>string</td><td>false</td><td>Hàm gửi tin này sẽ truyền link callback riêng cho từng loại tin nhắn. URL nhận kết quả gửi tin. <br>Xem body mẫu ZNS <a href="https://samplefordevelopers.esms.vn/#b98ca55e-3001-4446-b5bb-a4ab86127b0b">ở đây</a>. <br>Xem body mẫu SMS <a href="https://samplefordevelopers.esms.vn/#20f85e1f-3d9e-4ff4-bc4f-8d9c9edbc88a">ở đây</a>. <br>Xem chi tiết <a href="https://developers-v2.esms.vn/esms-api/callback-url">ở đây</a>.</td></tr><tr><td>RequestId</td><td>string</td><td>false</td><td>ID đối tác truyền sang để chặn trùng và đối soát khi cần.<br>Độ dài tối đa 50 ký tự.<br><strong>Mỗi RequestId truyền sang có hiệu lực chặn trong 24h.</strong></td></tr><tr><td>Sandbox</td><td>string</td><td>false</td><td>1: Tin gửi ở môi trường test, dùng để kiểm tra kết nối và các thông số tích hợp, không về tin nhắn, không trừ tiền.<br>0: Tin gửi ở môi trường bình thường, có về tin nhắn.</td></tr></tbody></table>

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d8e0f1f0702544b2acb456ca9ccfd111250"
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}

{% tab title="789" %}

```json
{
    "CodeResult": "789",
    "CountRegenerate": 0,
    "ErrorMessage": "TemplateId is not config"
}
```

**Template chưa được cấu hình cho OA ID bạn đang sử dụng.**
{% endtab %}
{% endtabs %}

* **Cấu trúc trả về của response:**

<table><thead><tr><th width="145.53326416015625">Thuộc tính</th><th width="138.86669921875">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Request được gửi đến ESMS thành công.<br><br><strong>Lưu ý:</strong> Mã phản hồi <strong>100</strong> chỉ xác nhận rằng yêu cầu đã được gửi thành công đến hệ thống ESMS, <strong>không phản ánh việc tin nhắn đã được gửi đến số điện thoại người nhận hay chưa</strong>.<br>Để theo dõi trạng thái cuối cùng của tin nhắn, quý khách vui lòng truyền thêm tham số <strong>CallbackUrl</strong>; hệ thống ESMS sẽ tự động gửi phản hồi (callback) đến địa chỉ này khi có trạng thái cuối của tin.</td></tr><tr><td>SMSID</td><td>string</td><td>ID của tin nhắn mới được tạo ra trên hệ thống eSMS. Dùng ID này để query lấy trạng thái tin nhắn.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi).</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu của các ngôn ngữ ở link:**</mark>* [**Link Code mẫu .**](https://samplefordevelopers.esms.vn/#621e424e-1e47-4215-8d8a-21ef56f017b9)


# Tin nhắn Zalo sử dụng hash phone

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> [https://rest.esms.vn/MainService.svc/json/SendZaloMessage\_V6/hash\_phone/](http://rest.esms.vn/MainService.svc/json/SendZaloMessage_V6/hash_phone/)

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

#### Lưu ý khi dùng api hashphone:

* Chỉ hỗ trợ đầu số điện thoại 84. Hash từ các đầu +84 hoặc 0 sẽ bị lỗi sai số điện thoại
* Số điện thoại cần được mã hóa SHA-256 (hash) trước khi truyền vào.

{% code overflow="wrap" %}

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/SendZaloMessage_V6/hash_phone/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "ApiKey": "APIKEYCUABAN",
    "SecretKey": "SECRETKEYCUABAN",
    "OAID": "4097311281936189049",
    "HashPhone": "475dee020cb340c58b059ba9ff5e4cf75444f49cce993283b5f6bcaa5b27f8cf",
    "TempData": {
        "customer_name": "Đinh Thái Hà",
        "order_code": "HD00001",
        "address": "140-142 Đường Số 1, KDC Vạn Phúc, Hiệp Bình Phước, Thủ Đức",
        "phone": "0901888484",
        "email": "dinhthaiha@vihatgroup.com",
        "product_name": "Gói duy trì OA Zalo Premium 1 năm",
        "quantity": "1",
        "payment_amount": "4308000",
        "delivery_date": "01/08/2024"
    },
    "TempID": "200607",
    "campaignid": "Xác nhận mua hàng",
    "RequestId": "96accf59-0c41-4bc7-a5c4-4a466c2e41c2",
    "CallbackUrl": "https://esms.vn/webhook/"
}'
```

{% endcode %}

* **Cấu trúc body của request:**

<table><thead><tr><th width="152">Tham số</th><th width="120">Kiểu dữ liệu</th><th width="130" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>HashPhone</td><td>string</td><td>true</td><td>Số điện thoại của người nhận. <br>Lưu ý: Số điện thoại cần được mã hóa SHA-256 (hash) trước khi truyền vào.</td></tr><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey eSMS cung cấp.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>SecretKey eSMS cung cấp.</td></tr><tr><td>OAID</td><td>string</td><td>true</td><td>Zalo OA ID, là ID của trang Zalo Offical Account của doanh nghiệp. Doanh nghiệp cần đăng nhập vào trang quản trị của Zalo OA để lấy phần Zalo OA ID này. <br><strong>Chú ý: sẽ phải đăng ký trước khi sử dụng.</strong></td></tr><tr><td>TempData</td><td>JSON object</td><td>true</td><td>Các thuộc tính của template mà khách hàng eSMS đã đăng ký với Zalo.<br><strong>Chú ý: Cấu trúc TempData</strong> <strong>được quy định riêng ứng với từng template.</strong></td></tr><tr><td>SendDate</td><td>string</td><td>false</td><td>Thời gian hẹn gửi của tin. <br>Không truyền khi tin muốn tin nhắn gửi đi liền.<br>Định dạng: yyyy-mm-dd hh:MM:ss.</td></tr><tr><td>TempID </td><td>string</td><td>true</td><td>Template của Zalo OA mà khách hàng đăng kí với eSMS.</td></tr><tr><td>campaignid</td><td>string</td><td>false</td><td>Tên chiến dịch gửi tin, tối đa 254 ký tự.</td></tr><tr><td>Sandbox</td><td>string</td><td>false</td><td>1: Tin gửi ở môi trường test, dùng để kiểm tra kết nối và các thông số tích hợp, không về tin nhắn, không trừ tiền.<br>0: Tin gửi ở môi trường bình thường, có về tin nhắn.</td></tr><tr><td>CallbackUrl</td><td>string</td><td>false</td><td>URL nhận kết quả gửi tin.<br>Xem body mẫu <a href="https://samplefordevelopers.esms.vn/#b98ca55e-3001-4446-b5bb-a4ab86127b0b">ở đây</a><strong>.</strong> <br>Xem chi tiết <a href="/pages/HxTrJlnDLexPUwac9BWb">ở đây</a><strong>.</strong></td></tr><tr><td>SendingMode</td><td>string</td><td>false</td><td>Chế độ gửi: <br><kbd><strong>1</strong></kbd> (Default): Gửi thường, tin ZNS được gửi theo cơ chế thông thường. <br><kbd><strong>3</strong></kbd>: Gửi vượt hạn mức, cho phép OA gửi tin ZNS tag 3 vượt hạn mức. <br><br><strong>Lưu ý</strong>: Chế độ Gửi vượt hạn mức (SendingMode = 3) chỉ áp dụng cho các OA được whitelist. Vui lòng liên hệ đội ngũ CSKH nếu có nhu cầu gửi ở chế độ Gửi vượt hạn mức.</td></tr><tr><td>RequestId</td><td>string</td><td>false</td><td>ID đối tác truyền sang để chặn trùng và đối soát khi cần.<br>Độ dài tối đa 50 ký tự.<br><strong>Mỗi RequestId truyền sang có hiệu lực chặn trong 24h.</strong></td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d8e0f1f0702544b2acb456ca9ccfd111250"
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}

{% tab title="789" %}

```json
{
    "CodeResult": "789",
    "CountRegenerate": 0,
    "ErrorMessage": "TemplateId is not config"
}
```

**Template chưa được cấu hình cho OA ID bạn đang sử dụng.**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

<table><thead><tr><th width="141.66668701171875">Thuộc tính</th><th width="145.333251953125">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Request được gửi đến ESMS thành công.<br><br><strong>Lưu ý:</strong> Mã phản hồi <strong>100</strong> chỉ xác nhận rằng yêu cầu đã được gửi thành công đến hệ thống ESMS, <strong>không phản ánh việc tin nhắn đã được gửi đến số điện thoại người nhận hay chưa</strong>.<br>Để theo dõi trạng thái cuối cùng của tin nhắn, quý khách vui lòng truyền thêm tham số <strong>CallbackUrl</strong>; hệ thống ESMS sẽ tự động gửi phản hồi (callback) đến địa chỉ này khi có trạng thái cuối của tin.</td></tr><tr><td>SMSID</td><td>string</td><td>ID của tin nhắn mới được tạo ra trên hệ thống eSMS. Dùng ID này để query lấy trạng thái tin nhắn.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi).</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu của các ngôn ngữ ở link**</mark>*<mark style="color:yellow;">:</mark> [**Link code mẫu** ](https://samplefordevelopers.esms.vn/#11cf40ab-2970-4d03-9cc6-374177bfc103)**.**


# Tin Zalo Tư vấn dạng văn bản

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> [https://rest.esms.vn/MainService.svc/json/SendZaloFollowerMessage\_V4\_post\_json/](http://rest.esms.vn/MainService.svc/json/SendZaloFollowerMessage_V5_post_json/)

* **Content Type:** <mark style="color:orange;">text/plain</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location 'https://rest.esms.vn/mainservice.svc/json/SendZaloFollowerMessage_V4_post_json/' \
--header 'Content-Type: application/json' \
--data '{
   "ApiKey":"{{ApiKey}}",
   "SecretKey":"{{SecretKey}}",
   "OAID":"{{OAID}}",
   "User_id":"{{User_id}}",
   "Content":"Tin Zalo Tư vấn dạng văn bản",
   "RequestId": "96accf59-0c41-4bc7-a5c4-4a466c2e41c2",
   "CallbackUrl":{{CallbackUrl}}"
}'
```

* **Cấu trúc body của request:**

<table><thead><tr><th width="125">Tham số</th><th width="123">Kiểu dữ liệu </th><th width="134" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey eSMS cung cấp.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>SecretKey eSMS cung cấp.</td></tr><tr><td>OAID</td><td>string</td><td>true</td><td>Zalo OA ID, là ID của trang Zalo Offical Account của doanh nghiệp. Doanh nghiệp cần đăng nhập vào trang quản trị của Zalo OA để lấy phần Zalo OA ID này. <br><strong>Chú ý: sẽ phải đăng ký trước khi sử dụng.</strong></td></tr><tr><td>User_id</td><td>string</td><td>true</td><td>Userid cần gửi đến, đây là userid của zalo.</td></tr><tr><td>Content</td><td>string</td><td>true</td><td>Tiêu đề của ảnh<br>Giới hạn tối đa là 2.000 ký tự</td></tr><tr><td>RequestId</td><td>string</td><td>false</td><td>ID đối tác truyền sang để chặn trùng và đối soát khi cần.<br>Độ dài tối đa 50 ký tự.<br><strong>Mỗi RequestId truyền sang có hiệu lực chặn trong 24h.</strong></td></tr><tr><td>CallbackUrl</td><td>string</td><td>false</td><td>eSMS sẽ trả về kết quả của tin nhắn này.<br>Xem body mẫu <a href="https://samplefordevelopers.esms.vn/#cd0e23a3-5aa5-4198-a8bb-be0d8e450df9">ở đây</a>.<br>Xem chi tiết <a href="/pages/HxTrJlnDLexPUwac9BWb">ở đây</a>.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d8e0f1f0702544b2acb456ca9ccfd111250"
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

<table><thead><tr><th width="156.199951171875">Thuốc tính </th><th width="145.6666259765625">Kiểu dữ liệu </th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Request được gửi đến ESMS thành công.<br><br><strong>Lưu ý:</strong> Mã phản hồi <strong>100</strong> chỉ xác nhận rằng yêu cầu đã được gửi thành công đến hệ thống ESMS, <strong>không phản ánh việc tin nhắn đã được gửi đến số điện thoại người nhận hay chưa</strong>.<br>Để theo dõi trạng thái cuối cùng của tin nhắn, quý khách vui lòng truyền thêm tham số <strong>CallbackUrl</strong>; hệ thống ESMS sẽ tự động gửi phản hồi (callback) đến địa chỉ này khi có trạng thái cuối của tin.</td></tr><tr><td>SMSID</td><td>string</td><td>ID tin nhắn do esms trả về.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi)</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [**Link code mẫu**](https://samplefordevelopers.esms.vn/#c0e00f1f-0c1f-4be1-8aac-f730d14e0e29)**.**


# Tin Zalo Tư vấn đính kèm ảnh

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> [https://rest.esms.vn/MainService.svc/json/SendZaloFollowerMessage\_V5\_post\_json/](http://rest.esms.vn/MainService.svc/json/SendZaloFollowerMessage_V5_post_json/)

* **Content Type:** <mark style="color:orange;">text/plain</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/SendZaloFollowerMessage_V5_post_json/' \
--header 'Content-Type: text/plain' \
--data '{
    "ApiKey": "{{ApiKey}}",
    "SecretKey": "{{SecretKey}}",
    "OAID": "{{OAID}}",
    "RequestId": "96accf59-0c41-4bc7-a5c4-4a466c2e41c2", 
    "Payload": {
        "recipient": {
            "user_id": "{{user_id}}"
        },
        "message": {
            "text": "Tin Zalo Tư vấn đính kèm ảnh",
            "attachment": {
                "type": "template",
                "payload": {
                    "template_type": "media",
                    "elements": [
                        {
                            "media_type": "image",
                            "url": "https://minio.esms.vn/blogimg/agent-1/BlogImg/full_3f8df17c-2d15-4ecb-b9fd-3bcc9cb0d97b.png"
                        }
                    ]
                }
            }
        }
    }
}'

// Truyền \r\n để gửi nội dung xuống dòng
```

* **Cấu trúc body của request:**

<table><thead><tr><th width="135">Tham số</th><th width="109">Kiểu dữ liệu </th><th width="136" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey eSMS cung cấp.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>SecretKey eSMS cung cấp.</td></tr><tr><td>OAID</td><td>string</td><td>true</td><td>Zalo OA ID, là ID của trang Zalo Offical Account của doanh nghiệp. Doanh nghiệp cần đăng nhập vào trang quản trị của Zalo OA để lấy phần Zalo OA ID này. <br><strong>Chú ý: sẽ phải đăng ký trước khi sử dụng.</strong></td></tr><tr><td>RequestId</td><td>string</td><td>false</td><td>ID đối tác truyền sang để chặn trùng và đối soát khi cần.<br>Độ dài tối đa 50 ký tự.<br><strong>Mỗi RequestId truyền sang có hiệu lực chặn trong 24h.</strong></td></tr><tr><td>CallbackUrl</td><td>string</td><td>false</td><td>eSMS sẽ trả về kết quả của tin nhắn này.<br>Xem body mẫu <a href="https://samplefordevelopers.esms.vn/#cd0e23a3-5aa5-4198-a8bb-be0d8e450df9">ở đây</a>.<br>Xem chi tiết <a href="/pages/HxTrJlnDLexPUwac9BWb">ở đây</a>.</td></tr><tr><td>SendDate</td><td>string</td><td>false</td><td>Thời gian hẹn gửi của tin.<br>Không truyền khi tin muốn tin nhắn gửi đi liền.<br>Định dạng: yyyy-mm-dd hh:MM:ss</td></tr><tr><td>Payload</td><td>Object</td><td>true</td><td>Chứa nội dung cần gửi</td></tr></tbody></table>

***

**Cấu trúc thuộc tính recipient**

<table><thead><tr><th width="136.99993896484375">Tham số</th><th width="113.888916015625">Kiểu dữ liệu </th><th width="139.5555419921875" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>user_id</td><td>string</td><td>true</td><td>ID của người nhận.</td></tr></tbody></table>

**Cấu trúc thuộc tính message**

<table><thead><tr><th width="143.22216796875">Tham số</th><th width="119.7777099609375">Kiểu dữ liệu </th><th width="125.5555419921875" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>text</td><td>string</td><td>true</td><td>Tiêu đề của ảnh<br>Giới hạn tối đa là 2.000 ký tự</td></tr><tr><td>attachment</td><td>Object</td><td>true</td><td>Attachment cần gửi.</td></tr></tbody></table>

**Cấu trúc thuộc tính message.attachment**

<table><thead><tr><th width="142.33331298828125">Tham số</th><th width="127.7777099609375">Kiểu dữ liệu </th><th width="126.8887939453125" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>type</td><td>string</td><td>true</td><td><p>Loại attachment.<br>Giá trị nhận vào bắt buộc:</p><ul><li><code>type</code> = template</li></ul></td></tr><tr><td>payload</td><td>Object</td><td>true</td><td>Chứa payload của attachment muốn gửi.</td></tr></tbody></table>

**Cấu trúc thuộc tính message.attachment.payload**

<table><thead><tr><th width="147">Tham số</th><th width="127.111083984375">Kiểu dữ liệu </th><th width="125.77783203125" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>template_type</td><td>string</td><td>true</td><td><p>Loại template<br>Với template gửi thông báo theo mẫu đính kèm ảnh, giá trị nhận vào là:</p><ul><li><code>template_type</code> = media</li></ul></td></tr><tr><td>elements</td><td>array</td><td>true</td><td>Các đối tượng của template.<br><strong>Lưu ý:</strong> Cấu trúc element thay đổi tùy theo loại template. <br>Với template media, danh sách element bao gồm tối đa 1 phần tử.</td></tr></tbody></table>

#### Cấu trúc thuộc tính message.attachment.payload.element <a href="#cau-truc-thuoc-tinh-messageattachmentpayloadelement" id="cau-truc-thuoc-tinh-messageattachmentpayloadelement"></a>

<table><thead><tr><th width="143.22216796875">Tham số</th><th width="127.7777099609375">Kiểu dữ liệu </th><th width="134" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>media_type</td><td>string</td><td>true</td><td><p>Loại media.</p><p></p><p>Các giá trị nhận vào:</p><ul><li>image: ảnh tĩnh</li><li>gif: ảnh động</li></ul></td></tr><tr><td>url</td><td>string</td><td>true</td><td><p>Đường dẫn đến ảnh<br>Các định dạng ảnh hỗ trợ: jpg và png<br>Dung lượng tối đa: 1MB<br><br><strong>Lưu ý:</strong></p><ul><li>kích thước ảnh tối ưu 16:9 và vùng safe zone 14:9</li></ul></td></tr></tbody></table>

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d8e0f1f0702544b2acb456ca9ccfd111250"
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

<table><thead><tr><th width="145.53326416015625">Thuốc tính </th><th width="130.4000244140625">Kiểu dữ liệu </th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Request được gửi đến ESMS thành công.<br><br><strong>Lưu ý:</strong> Mã phản hồi <strong>100</strong> chỉ xác nhận rằng yêu cầu đã được gửi thành công đến hệ thống ESMS, <strong>không phản ánh việc tin nhắn đã được gửi đến số điện thoại người nhận hay chưa</strong>.<br>Để theo dõi trạng thái cuối cùng của tin nhắn, quý khách vui lòng truyền thêm tham số <strong>CallbackUrl</strong>; hệ thống ESMS sẽ tự động gửi phản hồi (callback) đến địa chỉ này khi có trạng thái cuối của tin.</td></tr><tr><td>SMSID</td><td>string</td><td>ID tin nhắn do esms trả về.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi)</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [**Link code mẫu**](https://samplefordevelopers.esms.vn/#c0e00f1f-0c1f-4be1-8aac-f730d14e0e29)**.**


# Tin Zalo Tư vấn dạng button

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> [https://rest.esms.vn/MainService.svc/json/SendZaloFollowerMessage\_V5\_post\_json/](http://rest.esms.vn/MainService.svc/json/SendZaloFollowerMessage_V5_post_json/)

* **Content Type:** <mark style="color:orange;">text/plain</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

{% code overflow="wrap" %}

```json

curl --location --request POST 'https://rest.esms.vn/MainService.svc/json/SendZaloFollowerMessage_V5_post_json/' \
--header 'Content-Type: text/plain' \
--data-raw '{
    "ApiKey": "{{ApiKey}}",
    "SecretKey": "{{SecretKey}}",
    "OAID": "{{OAID}}",
    "RequestId": "96accf59-0c41-4bc7-a5c4-4a466c2e41c2", 
    "Payload": {
        "recipient": {
            "user_id": "{{user_id}}"
        },
        "message": {
            "text": "Chào mừng bạn đến với hệ thống eSMS. Đây là tin nhắn zalo dạng button.",
            "attachment": {
                "type": "template",
                "payload": {
                    "buttons": [
                        {
                            "title": "Link url",
                            "payload": {
                                "url": "https://developers.esms.vn/esms-api/ham-gui-tin/tin-zalo-tu-van-dang-button"
                            },
                            "type": "oa.open.url"
                        },
                        {
                            "title": "QUERY SHOW",
                            "type": "oa.query.show",
                            "payload": "#callback_data"
                        },
                        {
                            "title": "QUERY HIDE",
                            "type": "oa.query.hide",
                            "payload": "#callback_data"
                        },
                        {
                            "title": "OPEN SMS",
                            "type": "oa.open.sms",
                            "payload": {
                                "content": "Cảm ơn quý khách đã sử dụng dịch vụ của chúng tôi. Chúc quý khách một ngày mới tốt lành!",
                                "phone_code": "0901888484"
                            }
                        },
                        {
                            "title": "OPEN PHONE",
                            "type": "oa.open.phone",
                            "payload": {
                                "phone_code": "0901888484"
                            }
                        }
                    ]
                }
            }
        }
    }
}'

// Truyền \r\n để gửi nội dung xuống dòng
```

{% endcode %}

* **Cấu trúc body của request:**

<table><thead><tr><th width="135">Tham số</th><th width="109">Kiểu dữ liệu </th><th width="136" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey eSMS cung cấp.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>SecretKey eSMS cung cấp.</td></tr><tr><td>OAID</td><td>string</td><td>true</td><td>Zalo OA ID, là ID của trang Zalo Offical Account của doanh nghiệp. Doanh nghiệp cần đăng nhập vào trang quản trị của Zalo OA để lấy phần Zalo OA ID này. <br><strong>Chú ý: sẽ phải đăng ký trước khi sử dụng.</strong></td></tr><tr><td>RequestId</td><td>string</td><td>false</td><td>ID đối tác truyền sang để chặn trùng và đối soát khi cần.<br>Độ dài tối đa 50 ký tự.<br><strong>Mỗi RequestId truyền sang có hiệu lực chặn trong 24h.</strong></td></tr><tr><td>CallbackUrl</td><td>string</td><td>false</td><td>eSMS sẽ trả về kết quả của tin nhắn này.<br>Xem body mẫu <a href="https://samplefordevelopers.esms.vn/#cd0e23a3-5aa5-4198-a8bb-be0d8e450df9">ở đây</a>.<br>Xem chi tiết <a href="/pages/HxTrJlnDLexPUwac9BWb">ở đây</a>.</td></tr><tr><td>SendDate</td><td>string</td><td>false</td><td>Thời gian hẹn gửi của tin.<br>Không truyền khi tin muốn tin nhắn gửi đi liền.<br>Định dạng: yyyy-mm-dd hh:MM:ss</td></tr><tr><td>Payload</td><td>Object</td><td>true</td><td>Chứa nội dung cần gửi</td></tr></tbody></table>

***

**Cấu trúc thuộc tính recipient**

<table><thead><tr><th width="131.66668701171875">Tham số</th><th width="109.800048828125">Kiểu dữ liệu </th><th width="140.066650390625" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>user_id</td><td>string</td><td>true</td><td>ID của người nhận.</td></tr></tbody></table>

**Cấu trúc thuộc tính message**

<table><thead><tr><th width="131.66668701171875">Tham số</th><th width="112.800048828125">Kiểu dữ liệu </th><th width="136.8665771484375" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>text</td><td>string</td><td>true</td><td>Tiêu đề của button<br>Giới hạn tối đa là 2.000 ký tự</td></tr><tr><td>attachment</td><td>Object</td><td>true</td><td>Attachment cần gửi.</td></tr></tbody></table>

**Cấu trúc thuộc tính message.attachment**

<table><thead><tr><th width="133.800048828125">Tham số</th><th width="111.800048828125">Kiểu dữ liệu </th><th width="137.933349609375" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>type</td><td>string</td><td>true</td><td><p>Loại attachment. <br><br>Giá trị nhận vào bắt buộc:</p><ul><li><code>type</code> = template</li></ul></td></tr><tr><td>payload</td><td>Object</td><td>true</td><td>Dữ liệu của action. <br>Cấu trúc của payload phải phù hợp với từng loại action và được cho ở bảng bên dưới</td></tr></tbody></table>

**Cấu trúc payload cho các loại action được hỗ trợ**

<table><thead><tr><th width="139.13330078125">Giá trị type</th><th width="184.4000244140625">Kiểu dữ liệu của payload</th><th>Giá trị payload và kết quả khi người quan tâm bấm vào</th></tr></thead><tbody><tr><td>oa.open.url</td><td>string</td><td><p>Data là một Url sẽ được mở trong ứng dụng Zalo khi người quan tâm bấm vào button. Ví dụ: </p><p><code>{</code><br>    <code>"title": "OPEN URL",</code><br>    <code>"payload" : {</code><br>    <code>"url": "https://developers.zalo.me/"</code><br>    <code>},</code><br>    <code>"type": "oa.open.url"</code><br><code>}</code></p><ul><li><strong>Chú ý:</strong> Giới hạn cho thuộc tính "title" là 100 kí tự.</li></ul></td></tr><tr><td>oa.query.show</td><td>string</td><td><p>Data là một chuỗi ký tự ví dụ “#callback_data”. Khi người quan tâm bấm vào button, hệ thống sẽ gửi một tin nhắn có nội dung chứa trong data từ người quan tâm đến Official Account. Tin nhắn này sẽ hiện trên cửa sổ chat trên máy của người quan tâm. Ví dụ: <br><code>{</code><br>    <code>"title": "QUERY SHOW",</code><br>    <code>"type": "oa.query.show",</code><br>    <code>"payload": "#callback_data"</code><br><code>}</code></p><ul><li><p><strong>Chú ý:</strong></p><ul><li>Giới hạn cho thuộc tính "title" là 100 kí tự.</li><li>Giới hạn cho thuộc tính "payload" là 1000 kí tự.</li></ul></li></ul></td></tr><tr><td>oa.query.hide</td><td>string</td><td><p>Data là một chuỗi ký tự ví dụ “#callback_data”. Khi người quan tâm bấm vào button, hệ thống sẽ gửi một tin nhắn có nội dung chứa trong data từ người quan tâm đến Official Account. Tin nhắn này sẽ bị ẩn trên cửa sổ chat trên máy của người quan tâm. Ví dụ: </p><p><code>{</code><br>    <code>"title": "QUERY HIDE",</code><br>    <code>"type": "oa.query.hide",</code><br>    <code>"payload": "#callback_data"</code><br><code>}</code></p><ul><li><p><strong>Chú ý:</strong></p><ul><li>Giới hạn cho thuộc tính "title" là 100 kí tự.</li><li>Giới hạn cho thuộc tính "payload" là 1000 kí tự.</li></ul></li></ul></td></tr><tr><td>oa.open.sms</td><td>object</td><td><p>Data đối tượng json chứa 2 thuộc tính “content” và “phoneCode”. Ví dụ: </p><p><code>{</code><br>    <code>"title": "OPEN SMS",</code><br>    <code>"type": "oa.open.sms",</code><br>    <code>"payload": {</code><br>    <code>"content":"alo",</code><br>    <code>"phone_code":"84919018791"</code><br>    <code>}</code><br><code>}</code></p><p>Khi người quan tâm click vào button, cửa sổ sms trên điện thoại của người quan tâm sẽ được mở với 2 thông tin sẵn có là phone code và nội dung tin nhắn trong data.</p><ul><li><p><strong>Chú ý:</strong></p><ul><li>Giới hạn cho thuộc tính "title" là 100 kí tự.</li><li>Thuộc tính "content" có giới hạn là 160 kí tự.</li></ul></li></ul></td></tr><tr><td>oa.open.phone</td><td>object</td><td><p>Data số điện thoại sẽ nhập vào khi bật ứng dụng gọi điện, ví dụ: </p><p><code>{</code><br>    <code>"title": "OPEN PHONE",</code><br>    <code>"type": "oa.open.phone",</code><br>    <code>"payload":{</code><br>    <code>"phone_code":"84919018791"</code><br>    }<br>}</p><p>Khi người quan tâm click vào button, cửa sổ call trên điện thoại của người quan tâm sẽ được mở với thông tin sẵn có là phone number trong data.</p><ul><li><strong>Chú ý:</strong> Giới hạn cho thuộc tính "title" là 100 kí tự.</li></ul></td></tr></tbody></table>

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d8e0f1f0702544b2acb456ca9ccfd111250"
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

<table><thead><tr><th width="149.79998779296875">Thuốc tính </th><th width="119.7999267578125">Kiểu dữ liệu </th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Request được gửi đến ESMS thành công.<br><br><strong>Lưu ý:</strong> Mã phản hồi <strong>100</strong> chỉ xác nhận rằng yêu cầu đã được gửi thành công đến hệ thống ESMS, <strong>không phản ánh việc tin nhắn đã được gửi đến số điện thoại người nhận hay chưa</strong>.<br>Để theo dõi trạng thái cuối cùng của tin nhắn, quý khách vui lòng truyền thêm tham số <strong>CallbackUrl</strong>; hệ thống ESMS sẽ tự động gửi phản hồi (callback) đến địa chỉ này khi có trạng thái cuối của tin.</td></tr><tr><td>SMSID</td><td>string</td><td>ID tin nhắn do esms trả về.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi)</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [**Link code mẫu**](https://samplefordevelopers.esms.vn/#c0e00f1f-0c1f-4be1-8aac-f730d14e0e29)**.**


# Tin Zalo giao dịch

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> [https://rest.esms.vn/mainservice.svc/json/SendZaloFollowerMessage\_V5\_post\_json/](http://rest.esms.vn/mainservice.svc/json/SendZaloFollowerMessage_V5_post_json/)

* **Content Type:** <mark style="color:orange;">text/plain</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

{% code overflow="wrap" %}

```json
curl --location 'https://rest.esms.vn/mainservice.svc/json/SendZaloFollowerMessage_V5_post_json/' \
--header 'Content-Type: text/plain' \
--data '{
    "ApiKey": "{{ApiKey}}",
    "SecretKey": "{{SecretKey}}",
    "OAID": "{{OAID}}",
    "RequestId": "96accf59-0c41-4bc7-a5c4-4a466c2e41c2", 
    "Payload": {
        "recipient": {
            "user_id": "{{user_id}}"
        },
        "message": {
            "attachment": {
                "type": "template",
                "payload": {
                    "template_type": "transaction_order",
                    "language": "VI",
                    "elements": [
                        {
                            "image_url": "https://minio.esms.vn/blogimg/agent-1/BlogImg/full_cccc34d4-3a46-4644-8613-1b226203c5d5.png",
                            "type": "banner"
                        },
                        {
                            "type": "header",
                            "content": "Trạng thái đơn hàng",
                            "align": "left"
                        },
                        {
                            "type": "text",
                            "align": "left",
                            "content": "• Cảm ơn bạn đã mua hàng tại cửa hàng.<br>• Thông tin đơn hàng của bạn như sau:"
                        },
                        {
                            "type": "table",
                            "content": [
                                {
                                    "value": "eSMS-001",
                                    "key": "Mã khách hàng"
                                },
                                {
                                    "style": "yellow",
                                    "value": "Đang giao",
                                    "key": "Trạng thái"
                                },
                                {
                                    "value": "250,000đ",
                                    "key": "Giá tiền"
                                }
                            ]
                        },
                        {
                            "type": "text",
                            "align": "center",
                            "content": "📲 Lưu ý điện thoại. Xin cảm ơn!"
                        }
                    ],
                    "buttons": [
                        {
                            "title": "Kiểm tra lộ trình",
                            "image_icon": "https://img.icons8.com/?size=100&id=kJlyCVWJrclv&format=png&color=000000",
                            "type": "oa.open.url",
                            "payload": {
                                "url": "https://esms.vn/huong-dan/huong-dan-tich-hop/huong-dan-tich-hop-api-cua-esms-vao-website"
                            }
                        },
                        {
                            "title": "Xem lại giỏ hàng",
                            "image_icon": "https://img.icons8.com/?size=100&id=S2Z1vzGMFT1v&format=png&color=000000",
                            "type": "oa.open.url",
                            "payload": {
                                "url": "https://esms.vn/huong-dan/huong-dan-su-dung"
                            }
                        },
                        {
                            "title": "Liên hệ tổng đài",
                            "image_icon": "https://img.icons8.com/?size=100&id=KKBDB20a4V6t&format=png&color=000000",
                            "type": "oa.open.phone",
                            "payload": {
                                "phone_code": "0901888484"
                            }
                        }
                    ]
                }
            }
        }
    }
}'
```

{% endcode %}

* **Cấu trúc body của request:**

<table><thead><tr><th width="158">Tham số</th><th width="120">Kiểu dữ liệu</th><th width="121" data-type="checkbox">Tính bắt buộc</th><th>Định nghĩa</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Secretkey của tài khoản.</td></tr><tr><td>OAID</td><td>string</td><td>true</td><td>Zalo OA ID, là ID của trang Zalo Offical Account của doanh nghiệp. Doanh nghiệp cần đăng nhập vào trang quản trị của Zalo OA để lấy phần Zalo OA ID này. <br><strong>Chú ý: sẽ phải đăng ký trước khi sử dụng.</strong></td></tr><tr><td>RequestId</td><td>string</td><td>false</td><td>ID đối tác truyền sang để chặn trùng và đối soát khi cần.<br>Độ dài tối đa 50 ký tự.<br><strong>Mỗi RequestId truyền sang có hiệu lực chặn trong 24h.</strong></td></tr><tr><td>Sandbox</td><td>string</td><td>false</td><td>1: Tin gửi ở môi trường test, dùng để kiểm tra kết nối và các thông số tích hợp, không về tin nhắn, không trừ tiền.<br>0: Tin gửi ở môi trường bình thường, có về tin nhắn.</td></tr><tr><td>CallbackUrl</td><td>string</td><td>false</td><td>eSMS sẽ trả về kết quả của tin nhắn này. Xem body mẫu <a href="https://samplefordevelopers.esms.vn/#cd0e23a3-5aa5-4198-a8bb-be0d8e450df9">ở đây</a>. <br>Xem chi tiết <a href="https://developers.esms.vn/esms-api/callback-url">ở đây</a>.</td></tr><tr><td>SendDate</td><td>string</td><td>false</td><td>Thời gian hẹn gửi của tin.<br>Không truyền khi tin muốn tin nhắn gửi đi liền.<br>Định dạng: yyyy-mm-dd hh:MM:ss</td></tr><tr><td>Payload</td><td>Object</td><td>true</td><td>Chứa nội dung cần gửi</td></tr></tbody></table>

**Cấu trúc thuộc tính recipient**

<table><thead><tr><th width="151.933349609375">Tham số</th><th width="130.5333251953125">Kiểu dữ liệu</th><th width="124.2666015625" data-type="checkbox">Tính bắt buộc</th><th>Định nghĩa</th></tr></thead><tbody><tr><td>user_id</td><td>string</td><td>true</td><td>ID của người nhận.</td></tr></tbody></table>

**Cấu trúc thuộc tính message**

<table><thead><tr><th width="153">Tham số</th><th width="125.2667236328125">Kiểu dữ liệu</th><th width="126.2667236328125" data-type="checkbox">Tính bắt buộc</th><th>Định nghĩa</th></tr></thead><tbody><tr><td>attachment</td><td>object</td><td>true</td><td>Attachment cần gửi</td></tr></tbody></table>

**Cấu trúc thuộc tính message.attachment**

<table><thead><tr><th width="151.933349609375">Tham số</th><th width="125.199951171875">Kiểu dữ liệu</th><th width="131.5333251953125" data-type="checkbox">Tính bắt buộc</th><th>Định nghĩa</th></tr></thead><tbody><tr><td>type</td><td>string</td><td>true</td><td><p>Loại attachment<br></p><p>Giá trị nhận vào bắt buộc:</p><ul><li><code>type</code> = template</li></ul></td></tr><tr><td>payload</td><td>object</td><td>true</td><td>Chứa payload của attachment muốn gửi.</td></tr></tbody></table>

**Cấu trúc thuộc tính message.attachment.payload**

<table><thead><tr><th width="154.066650390625">Tham số</th><th width="123.2000732421875">Kiểu dữ liệu</th><th width="113.4000244140625" data-type="checkbox">Tính bắt buộc</th><th>Định nghĩa</th></tr></thead><tbody><tr><td>template_type</td><td>string</td><td>true</td><td>Xem thêm mục Tham số message.attachment.payload.template_type bên dưới</td></tr><tr><td>language</td><td>string</td><td>false</td><td><p>Ngôn ngữ sử dụng của tin<br><br>Giá trị nhận vào:</p><ul><li><code>language</code> = <strong>VI</strong></li></ul><p>hoặc</p><ul><li><code>language</code> = <strong>EN</strong></li></ul><p>Khi chọn ngôn ngữ các nội dung mặc định của mẫu tin sẽ chuyển sang ngôn ngữ tương ứng</p></td></tr><tr><td>elements</td><td>array</td><td>true</td><td>Các đối tượng của template.<br><br>Xem thêm mục <strong>message.attachment.payload.elements</strong> bên dưới</td></tr><tr><td>buttons</td><td>array</td><td>false</td><td>Các nút nhấn CTA (tùy chọn có hoặc không, tối đa 4 button) <br>Xem thêm mục <strong>message.attachment.payload.buttons</strong> bên dưới</td></tr></tbody></table>

**Tham số message.attachment.payload.template\_type**

<table><thead><tr><th width="57.93328857421875">STT</th><th width="252.13348388671875">Mã template</th><th width="212.5333251953125">Loại tin (VN)</th><th>Message Type (EN)</th></tr></thead><tbody><tr><td>1</td><td>transaction_billing</td><td>Hóa đơn</td><td>Billing</td></tr><tr><td>2</td><td>transaction_order</td><td>Đơn hàng</td><td>Order</td></tr><tr><td>3</td><td>transaction_reward</td><td>Tích điểm</td><td>Reward</td></tr><tr><td>4</td><td>transaction_contract</td><td>Hợp đồng</td><td>Contract</td></tr><tr><td>5</td><td>transaction_booking</td><td>Lịch hẹn</td><td>Booking</td></tr><tr><td>6</td><td>transaction_membership</td><td>Thành viên</td><td>Membership</td></tr><tr><td>7</td><td>transaction_event</td><td>Sự kiện</td><td>Event</td></tr><tr><td>8</td><td>transaction_transaction</td><td>Giao dịch</td><td>Transaction</td></tr><tr><td>9</td><td>transaction_account</td><td>Tài khoản</td><td>Account</td></tr><tr><td>10</td><td>transaction_internal</td><td>Nội bộ</td><td>Internal</td></tr><tr><td>11</td><td>transaction_partnership</td><td>Đối tác</td><td>Partnership</td></tr><tr><td>12</td><td>transaction_education</td><td>Học vụ</td><td>Education</td></tr><tr><td>13</td><td>transaction_rating</td><td>Đánh giá</td><td>Rating</td></tr></tbody></table>

**Cấu trúc tham số message.attachment.payload.elements**

<table><thead><tr><th width="104.99993896484375">Type</th><th width="112.933349609375">Thuộc tính</th><th width="106.13330078125">Kiểu dữ liệu</th><th width="116.800048828125" data-type="checkbox">Tính bắt buộc</th><th>Định nghĩa</th></tr></thead><tbody><tr><td><strong>banner</strong></td><td>image_url</td><td>string</td><td>true</td><td><strong>image_url</strong> : Đường dẫn đến ảnh<br>Các định dạng ảnh hỗ trợ: jpg và png<br>Dung lượng tối đa: 1MB<br>Tỉ lệ kích thước ảnh (height :width): từ 1:5 đến 1:1 (ảnh vuông)</td></tr><tr><td><strong>header</strong></td><td>content</td><td>string</td><td>true</td><td>Nội dung của header, tối đa 100 ký tự.</td></tr><tr><td></td><td>align</td><td>string</td><td>false</td><td><p>Chấp nhận 3 giá trị<br></p><ul><li>left (hoặc để trống): canh lề bên trái</li><li>center: canh lề giữa</li><li>right: canh lề bên phải</li></ul></td></tr><tr><td><strong>text (lưu ý tối đa được 2 đoạn text)</strong></td><td>content</td><td>string</td><td>true</td><td>Nội dung của text, tối đa 250 ký tự mỗi đoạn</td></tr><tr><td></td><td>align</td><td>string</td><td>false</td><td><p>Chấp nhận 3 giá trị<br></p><ul><li>left (hoặc để trống): canh lề bên trái</li><li>center: canh lề giữa</li><li>right: canh lề bên phải</li></ul></td></tr><tr><td><strong>table</strong></td><td>content</td><td>array</td><td>true</td><td><p>Cấu trúc 1 phần tử trong table là:<br>{<br>"key": "giá trị của key" // maxlength = 25<br>"value": "giá trị của value" // maxlength = 100<br>}<br><mark style="background-color:orange;">Trong đó bắt buộc phải có 1 trong 2 phần tử dưới đây:</mark><br>VI:<br>{<br>"key": "Mã..." // bắt đầu là "Mã", dùng định danh người nhận<br>"value": "Giá trị tự do"<br>}</p><p>EN:<br>{<br>"key": "...Code..." // bắt buộc có chứa "Code" trong key<br>"value": "Giá trị tự do"<br>}<br><mark style="background-color:orange;">Hoặc:</mark><br>VI:</p><p>{<br>"key": "Tên khách hàng" // key có giá trị cố định "Tên khách hàng" "value": "Giá trị tự do"<br>}</p><p>EN:</p><p>{<br>"key": "Customer Name" // key có giá trị cố định "Customer Name" "value": "Giá trị tự do"<br>}<br><mark style="background-color:orange;">Key “Trạng thái” / “Status” là key duy nhất hiện tại được phép sử dụng tham số “Style”:</mark><br>VN:<br>{<br>"key": "Trạng thái" // key có giá trị cố định "Trạng thái"<br>"value": "Giá trị tự do"<br>"style": "yellow" // Giá trị hợp lệ: green, blue, yellow, red, grey<br>}</p><p>EN:<br>{<br>"key": "Status" // key có giá trị cố định "Status"<br>"value": "Giá trị tự do"<br>"style": "yellow" // Giá trị hợp lệ: green, blue, yellow, red, grey<br>}<br>****<strong>Lưu ý</strong>: có thể khai báo thêm tối đa 5 phần tử tùy ý.</p></td></tr></tbody></table>

**Cấu trúc tham số message.attachment.payload.buttons**

<table><thead><tr><th width="114.60015869140625">Thuộc tính</th><th width="106.7333984375">Kiểu dữ liệu</th><th width="113.4666748046875" data-type="checkbox">Tính bắt buộc</th><th>Định nghĩa</th></tr></thead><tbody><tr><td>title</td><td>string</td><td>true</td><td><p>Tiêu đề của button</p><p>Lưu ý: Tiêu đề không được vượt quá 35 ký tự</p></td></tr><tr><td>image_icon</td><td>string</td><td>true</td><td><p>Có thể tryền:</p><ul><li>image url của hình ảnh</li><li>attachment_id sau khi sử dụng API upload hình ảnh</li><li>để trống hoặc “default”: để sử dụng imaeg icon mặc định của Zalo</li></ul><p>Lưu ý: Kích thước hình ảnh tối ưu: 100px * 100px</p></td></tr><tr><td>type, payload</td><td>object</td><td>true</td><td>Xem thêm mục <strong>Cấu trúc payload cho các loại action được hỗ trợ</strong> bên dưới</td></tr></tbody></table>

**Cấu trúc payload cho các loại action được hỗ trợ**

<table><thead><tr><th width="135.933349609375">Giá trị type</th><th width="195.666748046875">Kiểu dữ liệu của payload</th><th>Giá trị payload và kết quả khi người quan tâm bấm vào</th></tr></thead><tbody><tr><td>oa.open.url</td><td>string</td><td><p>Data là một Url sẽ được mở trong ứng dụng Zalo khi người quan tâm bấm vào button. Ví dụ:<br><code>{</code><br>    <code>"title": "OPEN URL",</code><br>    <code>"payload" : {</code><br>    <code>"url": "https://developers.zalo.me/"</code><br>    <code>},</code><br>    <code>"type": "oa.open.url"</code><br><code>}</code></p><ul><li><strong>Chú ý:</strong>  Giới hạn cho thuộc tính "title" là 100 kí tự.</li></ul></td></tr><tr><td>oa.query.show</td><td>string</td><td><p>Data là một chuỗi ký tự ví dụ “#callback_data”. Khi người quan tâm bấm vào button, hệ thống sẽ gửi một tin nhắn có nội dung chứa trong data từ người quan tâm đến Official Account. Tin nhắn này sẽ hiện trên cửa sổ chat trên máy của người quan tâm. Ví dụ:<br><code>{</code><br>    <code>"title": "QUERY SHOW",</code><br>    <code>"type": "oa.query.show",</code><br>    <code>"payload": "#callback_data"</code><br><code>}</code><br></p><ul><li><p><strong>Chú ý:</strong>  </p><ul><li>Giới hạn cho thuộc tính "title" là 100 kí tự.</li><li>Giới hạn cho thuộc tính "payload" là 1000 kí tự.</li></ul></li></ul></td></tr><tr><td>oa.query.hide</td><td>string</td><td><p>Data là một chuỗi ký tự ví dụ “#callback_data”. Khi người quan tâm bấm vào button, hệ thống sẽ gửi một tin nhắn có nội dung chứa trong data từ người quan tâm đến Official Account. Tin nhắn này sẽ bị ẩn trên cửa sổ chat trên máy của người quan tâm. Ví dụ:<br><code>{</code><br>    <code>"title": "QUERY HIDE",</code><br>    <code>"type": "oa.query.hide",</code><br>    <code>"payload": "#callback_data"</code><br><code>}</code><br></p><ul><li><p><strong>Chú ý:</strong>  </p><ul><li>Giới hạn cho thuộc tính "title" là 100 kí tự.</li><li>Giới hạn cho thuộc tính "payload" là 1000 kí tự.</li></ul></li></ul></td></tr><tr><td>oa.open.sms</td><td>object</td><td><p>Data đối tượng json chứa 2 thuộc tính “content” và “phoneCode”. Ví dụ:<br><code>{</code><br>    <code>"title": "OPEN SMS",</code><br>    <code>"type": "oa.open.sms",</code><br>    <code>"payload": {</code><br>    <code>"content":"alo",</code><br>    <code>"phone_code":"84919018791"</code><br><code>}</code><br><code>}</code><br></p><p>Khi người quan tâm click vào button, cửa sổ sms trên điện thoại của người quan tâm sẽ được mở với 2 thông tin sẵn có là phone code và nội dung tin nhắn trong data.</p><ul><li><p><strong>Chú ý:</strong></p><ul><li>Giới hạn cho thuộc tính "title" là 100 kí tự.</li><li>Thuộc tính "content" có giới hạn là 160 kí tự.</li></ul></li></ul></td></tr><tr><td>oa.open.phone</td><td>object</td><td><p>Data số điện thoại sẽ nhập vào khi bật ứng dụng gọi điện, ví dụ:<br><code>{</code><br>    <code>"title": "OPEN PHONE",</code><br>    <code>"type": "oa.open.phone",</code><br>    <code>"payload":{</code><br>    <code>"phone_code":"84919018791"</code><br><code>}</code><br><code>}</code><br></p><p>Khi người quan tâm click vào button, cửa sổ call trên điện thoại của người quan tâm sẽ được mở với thông tin sẵn có là phone number trong data.</p><ul><li><strong>Chú ý:</strong>  Giới hạn cho thuộc tính "title" là 100 kí tự.</li></ul></td></tr></tbody></table>

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d8e0f1f0702544b2acb456ca9ccfd111250"
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

<table><thead><tr><th width="146.93330891927081">Thuốc tính</th><th width="127.2000732421875">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Request được gửi đến ESMS thành công.<br><br><strong>Lưu ý:</strong> Mã phản hồi <strong>100</strong> chỉ xác nhận rằng yêu cầu đã được gửi thành công đến hệ thống ESMS, <strong>không phản ánh việc tin nhắn đã được gửi đến số điện thoại người nhận hay chưa</strong>.<br>Để theo dõi trạng thái cuối cùng của tin nhắn, quý khách vui lòng truyền thêm tham số <strong>CallbackUrl</strong>; hệ thống ESMS sẽ tự động gửi phản hồi (callback) đến địa chỉ này khi có trạng thái cuối của tin.</td></tr><tr><td>SMSID</td><td>string</td><td>ID tin nhắn do esms trả về.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi).</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [***Link code mẫu***](https://samplefordevelopers.esms.vn/#eb8ca6b8-796c-463e-95b7-3601c8f49b33)***.***


# Tin Zalo Tư vấn dạng yêu cầu thông tin người dùng

## HTTP request

\ <mark style="color:yellow;">**POST**</mark> [https://rest.esms.vn/MainService.svc/json/SendZaloFollowerMessage\_V5\_post\_json/](http://rest.esms.vn/MainService.svc/json/SendZaloFollowerMessage_V5_post_json/)

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/SendZaloFollowerMessage_V5_post_json/' \
--header 'Content-Type: application/json' \
--data '{
"ApiKey": "{{ApiKey}}",
"SecretKey": "{{SecretKey}}",
"OAID": "{{OAID}}",
"RequestId": "96accf59-0c41-4bc7-a5c4-4a466c2e41c2", 
"Payload": {
        "recipient": {
            "user_id": "{{UserID}}"
        },
        "message": {
            "attachment": {
                "type": "template",
                "payload": {
                    "template_type": "request_user_info",
                    "elements": [
                        {
                            "title": "OA Chatbot",
                            "subtitle": "Đang yêu cầu thông tin từ bạn",
                            "image_url": "https://minio.esms.vn/blogimg/agent-1/BlogImg/full_cccc34d4-3a46-4644-8613-1b226203c5d5.png"
                        }
                    ]
                }
            }
        }
    }
}'
```

* **Cấu trúc body của request:**

<table><thead><tr><th width="135">Tham số</th><th width="120">Kiểu dữ liệu</th><th width="152" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Secretkey của tài khoản.</td></tr><tr><td>OAID</td><td>string</td><td>true</td><td>Zalo OA ID, là ID của trang Zalo Offical Account của doanh nghiệp. Doanh nghiệp cần đăng nhập vào trang quản trị của Zalo OA để lấy phần Zalo OA ID này. <br><strong>Chú ý: sẽ phải đăng ký trước khi sử dụng.</strong></td></tr><tr><td>RequestId</td><td>string</td><td>false</td><td>ID đối tác truyền sang để chặn trùng và đối soát khi cần.<br>Độ dài tối đa 50 ký tự.<br><strong>Mỗi RequestId truyền sang có hiệu lực chặn trong 24h.</strong></td></tr><tr><td>CallbackUrl</td><td>string</td><td>false</td><td>URL nhận kết quả gửi tin. <br>Xem body mẫu <a href="https://samplefordevelopers.esms.vn/#aabcd08e-e84a-4e9a-9598-c894af957d5b">ở đây</a>. <br>Xem chi tiết <a href="https://developers-v2.esms.vn/esms-api/callback-url">ở đây</a>.</td></tr><tr><td>SendDate</td><td>string</td><td>false</td><td>Thời gian hẹn gửi của tin.<br>Không truyền khi tin muốn tin nhắn gửi đi liền.<br>Định dạng: yyyy-mm-dd hh:MM:ss</td></tr><tr><td>Payload</td><td>Object</td><td>true</td><td>Chứa nội dung cần gửi</td></tr></tbody></table>

**Cấu trúc thuộc tính recipient**

<table><thead><tr><th width="141.26666259765625">Tham số</th><th width="115.2666015625">Kiểu dữ liệu</th><th width="152.199951171875" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>user_id</td><td>string</td><td>true</td><td>ID của người nhận.</td></tr></tbody></table>

**Cấu trúc thuộc tính message**

<table><thead><tr><th width="140.199951171875">Tham số</th><th width="118.466796875">Kiểu dữ liệu</th><th width="146.933349609375" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>attachment</td><td>Object</td><td>true</td><td>Chứa payload của attachment muốn gửi</td></tr><tr><td>type</td><td>string</td><td>true</td><td><p>Loại attachment.<br></p><p>Giá trị nhận vào bắt buộc:</p><ul><li><code>type</code> = template</li></ul></td></tr></tbody></table>

**Cấu trúc thuộc tính message.attachment**

<table><thead><tr><th width="141.26666259765625">Tham số</th><th width="117.400146484375">Kiểu dữ liệu</th><th width="145.8665771484375" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>title</td><td>string</td><td>true</td><td>Tiêu đề hiển thị của template<br>Lưu ý: Hỗ trợ tối đa 100 ký tự</td></tr><tr><td>subtitle</td><td>string</td><td>true</td><td>Tiêu đề phụ của template<br>Lưu ý: Hỗ trợ tối đa 500 ký tự</td></tr><tr><td>image_url</td><td>string</td><td>true</td><td>Đường dẫn đến ảnh.</td></tr></tbody></table>

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d8e0f1f0702544b2acb456ca9ccfd111250"
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

<table><thead><tr><th width="146.33331298828125">Thuốc tính</th><th width="122.6666259765625">Kiểu dữ liệu </th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Request được gửi đến ESMS thành công.<br><br><strong>Lưu ý:</strong> Mã phản hồi <strong>100</strong> chỉ xác nhận rằng yêu cầu đã được gửi thành công đến hệ thống ESMS, <strong>không phản ánh việc tin nhắn đã được gửi đến số điện thoại người nhận hay chưa</strong>.<br>Để theo dõi trạng thái cuối cùng của tin nhắn, quý khách vui lòng truyền thêm tham số <strong>CallbackUrl</strong>; hệ thống ESMS sẽ tự động gửi phản hồi (callback) đến địa chỉ này khi có trạng thái cuối của tin.</td></tr><tr><td>SMSID</td><td>string</td><td>ID tin nhắn do esms trả về.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi).</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [***Link code mẫu***](https://samplefordevelopers.esms.vn/#a8181709-4215-4375-bdb3-3e6c5a0a23c4)***.***


# Tin Zalo hành trình

\
Hàm cho phép bạn gửi tin nhắn đến số điện thoại đã đăng kí Zalo.&#x20;

Để có thể gửi được tin Zalo bạn cần tiến hành:\
\- Đăng ký và xác thực Zalo Offical Account (Zalo OA).\
\- Đăng ký template tin nhắn là template TIN NHẮN HÀNH TRÌNH với ZALO.\
Để hoàn thành các việc trên vui lòng liên hệ nhân viên kinh doanh hỗ trợ của bạn hoặc Hotline 0901888484.\
Ví dụ một mẫu tin Zalo hành trình.

<figure><img src="/files/QKfppgw4hZRwLZHhQ234" alt=""><figcaption></figcaption></figure>

## HTTP request

<mark style="color:yellow;">**`POST`**</mark> [https://rest.esms.vn/MainService.svc/json/SendZaloMessage\_V4\_post\_json/](http://rest.esms.vn/MainService.svc/json/SendZaloMessage_V4_post_json/)

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location 'https://rest.esms.vn//MainService.svc/json/SendZaloMessage_V4_post_json/' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey": "{{APIKEY}}",
    "SecretKey": "{{SecretKey}}",
    "Phone": "{{Phone}}",
    "Params": ["{{PARAM1}}","{{PARAM2}}","{{PARAM3}}"],
    "IsJourney": true,
    "OrderId": "{{ORDERID}}",
    "TempID": "{{TempID}}",
    "OAID": "{{OAID}}",
    "RequestId": "{{RequestId}}",
    "campaignid": "{{campaignid}}",
    "CallbackUrl":"{{CallbackUrl}}"
}'
```

* **Cấu trúc body của request:**

<table><thead><tr><th width="142">Tham số</th><th width="148">Kiểu dữ liệu </th><th width="141" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Secretkey của tài khoản.</td></tr><tr><td>Phone</td><td>string</td><td>true</td><td>Số điện thoại nhận tin.</td></tr><tr><td>Params</td><td>Array</td><td>true</td><td><p></p><p>Giá trị cần truyền cho các biến trong Template </p><p>*Lưu ý:</p><ol><li>Các tham số truyền vào phải đúng thứ tự như template bạn đăng ký.</li><li>Nếu tham số trùng nhau chỉ cần truyền vào một tham số.</li></ol></td></tr><tr><td>IsJourney</td><td>string</td><td>true</td><td>True: Là tính tin nhắn hành trình.<br>Fale: Không phải tin nhắn hành trình.</td></tr><tr><td>OrderId</td><td>string</td><td>true</td><td>Id của hành trình, dùng để đánh dấu hành trình, bắt buộc có khi gửi tin ZNS Journey.</td></tr><tr><td>TempID</td><td>string</td><td>true</td><td>Template của Zalo OA mà khách hàng đăng kí với eSMS.<br>Đối với loại tin ZNS Journey thì cần phải đăng ký với Zalo mới sử dụng được.</td></tr><tr><td>OAID </td><td>string</td><td>true</td><td>Zalo OA ID, là ID của trang Zalo Offical Account của doanh nghiệp. Doanh nghiệp cần đăng nhập vào trang quản trị của Zalo OA để lấy phần Zalo OA ID này. <br><strong>Chú ý: sẽ phải đăng ký trước khi sử dụng.</strong></td></tr><tr><td>campaignid</td><td>string</td><td>false</td><td>ID Tin nhắn của đối tác, dùng để kiểm tra ID này đã được hệ thống esms tiếp nhận trước đó hay chưa. <br>Ví dụ: RequestId=123456.</td></tr><tr><td>RequestId</td><td>string</td><td>false</td><td>ID đối tác truyền sang để chặn trùng và đối soát khi cần.<br>Độ dài tối đa 50 ký tự.<br><strong>Mỗi RequestId truyền sang có hiệu lực chặn trong 24h.</strong></td></tr><tr><td>CallbackUrl</td><td>string</td><td>false</td><td>URL nhận kết quả gửi tin. <br>Xem body mẫu <a href="https://samplefordevelopers.esms.vn/#995461aa-e59a-4659-9710-cc36e7078010">ở đây</a>. <br>Xem chi tiết <a href="https://developers-v2.esms.vn/esms-api/callback-url">ở đây</a>.</td></tr><tr><td>Sandbox</td><td>string</td><td>false</td><td>1: Tin gửi ở môi trường test, dùng để kiểm tra kết nối và các thông số tích hợp, không về tin nhắn, không trừ tiền.<br>0: Tin gửi ở môi trường bình thường, có về tin nhắn.</td></tr></tbody></table>

***

* Response:

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d8e0f1f0702544b2acb456ca9ccfd111250"
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

<table><thead><tr><th width="143.66668701171875">Thuốc tính</th><th width="118.93343098958331">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Request được gửi đến ESMS thành công.<br><br><strong>Lưu ý:</strong> Mã phản hồi <strong>100</strong> chỉ xác nhận rằng yêu cầu đã được gửi thành công đến hệ thống ESMS, <strong>không phản ánh việc tin nhắn đã được gửi đến số điện thoại người nhận hay chưa</strong>.<br>Để theo dõi trạng thái cuối cùng của tin nhắn, quý khách vui lòng truyền thêm tham số <strong>CallbackUrl</strong>; hệ thống ESMS sẽ tự động gửi phản hồi (callback) đến địa chỉ này khi có trạng thái cuối của tin.</td></tr><tr><td>SMSID</td><td>string</td><td>ID tin nhắn do esms trả về.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi).</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [***Link code mẫu***](https://samplefordevelopers.esms.vn/#bdf6fa30-e725-4347-bcfc-84d388f64674)***.***


# Tạo và gửi mã xác thực tự động bằng tin nhắn SMS

Để đáp ứng nhu cầu của người dùng về việc tự động tạo mã xác thực và gửi qua tin nhắn thương hiệu (SMS Brandname), chúng tôi đã thiết kế hai API: GENCODE để tạo mã và CHECKCODE để kiểm tra mã, giúp tối ưu hóa quy trình xác thực.

GENCODE: Tạo mã xác thực/mã OTP tự động, sau đó gửi tin nhắn đến máy khách hàng qua tin nhắn SMS.

CHECKCODE: Kiểm tra xem mã đã tạo có hợp lệ hay không, giúp xác minh tính đúng đắn và đảm bảo an toàn khi sử dụng.

{% hint style="warning" %}
Khách hàng cần đăng ký brandname và template trước khi sử dụng API này.
{% endhint %}

* [x] **GENCODE: tạo và gửi mã xác thực tự động**

<mark style="color:green;">**`GET`**</mark> <https://rest.esms.vn/MainService.svc/json/SendMessageAutoGenCode_V4_get?Phone={{Phone}}&ApiKey={{ApiKey}}&SecretKey={{SecretKey}}&TimeAlive={{TimeAlive}}&NumCharOfCode={{NumCharOfCode}}&Brandname={{Brandname}}&Type=2&message={{Content}}><br>

* **Response Type:** <mark style="color:orange;">application/json</mark>

{% code overflow="wrap" %}

```json
curl --location --globoff 'https://rest.esms.vn/MainService.svc/json//SendMessageAutoGenCode_V4_get?Phone=0901888484&ApiKey={{ApiKey}}&SecretKey={{SecretKey}}&TimeAlive=2&Brandname=Baotrixemay&Type=2&message={OTP} la ma xac minh dang ky Baotrixemay cua ban'
```

{% endcode %}

* **Cấu trúc body của request:**

<table><thead><tr><th width="183">Tham số</th><th width="117">Kiểu dữ liệu </th><th width="147" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>Phone</td><td>string</td><td>true</td><td>Số điện thoại nhận tin.</td></tr><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Secretkey của tài khoản.</td></tr><tr><td>TimeAlive</td><td>string</td><td>false</td><td>Thời gian hiệu lực của mã code. <br>Đơn vị tính: Phút. <br>Giới hạn từ 2 phút đến 10 phút.<br>Không truyền tham số này hiệu lực mặc định 5 phút.</td></tr><tr><td>NumCharOfCode</td><td>string</td><td>false</td><td>Số lượng ký tự của mã code. Mặc định khi không truyền là 6 ký tự.</td></tr><tr><td>Brandname</td><td>string</td><td>true</td><td>Tên Brandname (tên công ty hay tổ chức khi gửi tin sẽ hiển thị trên tin nhắn đó). <br><strong>Chú ý: sẽ phải đăng ký trước khi sử dụng.</strong></td></tr><tr><td>Type</td><td>string</td><td>true</td><td>2: Gửi chăm sóc khách hàng.</td></tr><tr><td>message</td><td>string</td><td>true</td><td>Nội dung tin nhắn<br>Thay thế mã code OTP bằng {OTP}<br>- Ví dụ: <br>Muốn nhận tin nhắn về máy với nội dung:<br>"686868 la ma xac minh dang ky Baotrixemay cua ban". Thì ở mục message truyền: "{OTP} la ma xac minh dang ky Baotrixemay cua ban".</td></tr><tr><td>IsNumber</td><td>string</td><td>false</td><td>0: code chứa chữ và số.<br>1: code chỉ chứa số.</td></tr></tbody></table>

***

* **Response:**&#x20;

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d533459ee42b2b9525ba9eabf6a8156"
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

<table><thead><tr><th width="199">Thuốc tính </th><th width="160">Kiểu dữ liệu </th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Mã trả về.</td></tr><tr><td>SMSID</td><td>string</td><td>ID tin nhắn do esms trả về.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi).</td></tr></tbody></table>

* [x] **CHECKCODE: Kiểm tra xem mã đã tạo có hợp lệ hay không**

<mark style="color:green;">**`GET`**</mark> <https://rest.esms.vn/MainService.svc/json/CheckCodeGen_V4_get?ApiKey={{ApiKey}}&SecretKey={{SecretKey}}&Phone={{{Phone}}&Code={{Code}}>

* **Response Type:** <mark style="color:orange;">application/json</mark>

{% code overflow="wrap" %}

```
curl --location --globoff 'https://rest.esms.vn/MainService.svc/json/CheckCodeGen_V4_get?ApiKey={{ApiKey}}&SecretKey={{SecretKey}}&Phone=0901888484&Code=1NTTJ6'
```

{% endcode %}

* **Cấu trúc body của request:**

<table><thead><tr><th>Tham số</th><th width="187">Kiểu dữ liệu</th><th data-type="checkbox">Tính bắt buộc</th><th width="277">Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Secretkey của tài khoản.</td></tr><tr><td>Phone</td><td>string</td><td>true</td><td>Số điện thoại người nhận code.</td></tr><tr><td>Code</td><td>string</td><td>true</td><td>Mã code cần check.</td></tr></tbody></table>

* **Response:**

{% tabs %}
{% tab title="100" %}

```
{
 "CodeResult": "100",
 "CountRegenerate": 0,
 "ErrorMessage": "0901888484, Content: Success!"
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}

{% tab title="117" %}

```
{
    "CodeResult": "117",
    "CountRegenerate": 0,
    "ErrorMessage": "0901888484, Content: 1NTTJ6 Code Invalid"
}
```

**Mã code đã được sử dụng hoặc hết thời gian hiệu lực.**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

<table><thead><tr><th width="145.86663818359375">Thuộc tính</th><th width="136.2667236328125">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Request được gửi đến ESMS thành công.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi).</td></tr><tr><td>Content</td><td>string</td><td>Trạng thái của code.</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [**Link code mẫu**](https://samplefordevelopers.esms.vn/#a3a8616e-f2bc-4ad4-8f41-b5affda6c85d)**.**


# Tạo và gửi mã xác thực tự động đa kênh: Zalo => SMS

Không giống như API tạo và gửi mã xác thực tự động qua tin nhắn SMS, API tạo và gửi mã tự động đa kênh mang lại nhiều lợi ích hơn, giúp người dùng tối ưu chi phí bằng cách lựa chọn kênh gửi phù hợp, đồng thời cải thiện trải nghiệm nhận mã với nội dung sinh động, trực quan hơn trên ứng dụng Zalo.

GENCODE: Tạo mã xác thực/mã OTP tự động, sau đó ưu tiên gửi qua ứng dụng Zalo, khi tin nhắn gửi qua Zalo thất bại sẽ tự động chuyển sang tin nhắn SMS với cùng một mã.

Các trường hợp thường gặp nhất khi gửi Zalo thất bại: số điện thoại người dùng không đăng ký zalo, Zalo OA không chưa mua gói duy trì,...

CHECKCODE: Kiểm tra xem mã đã tạo có hợp lệ hay không, giúp xác minh tính đúng đắn và đảm bảo an toàn khi sử dụng.

{% hint style="warning" %}

* Quý khách cần đăng ký Zalo OA, template Zalo, brandname CSKH và template brandname CSKH trước khi sử dụng.

* Khi có nhu cầu sử dụng API này, quý khách vui lòng gửi các thông tin sau đây cho bộ phận kinh doanh để cấu hình gửi: OAID, templateID zalo, brandname CSKH, template brandname CSKH.
  {% endhint %}

* [x] **GENCODE: tạo và gửi mã xác thực tự động**

\ <mark style="color:yellow;">**`POST`**</mark> [https://rest.esms.vn/MainService.svc/json/SendMessageAutoGenCode\_V5](http://rest.esms.vn/MainService.svc/json/SendMessageAutoGenCode_V5)

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

{% code overflow="wrap" %}

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/SendMessageAutoGenCode_V5' \
--header 'Content-Type: application/json' \
--data '{
     "ApiKey": "{{ApiKey}}",
     "Phone": "0901888484",
     "TimeAlive": "2",
     "SecretKey": "{{SecretKey}}",
     "MultiChannelTempId": "22575",
     "TypeId":"2"
}'
```

{% endcode %}

* **Cấu trúc body của request:**

<table><thead><tr><th width="207">Tham số</th><th width="124">Kiểu dữ liệu </th><th width="143" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>Phone</td><td>string</td><td>true</td><td>Số điện thoại nhận tin.</td></tr><tr><td>TimeAlive</td><td>string</td><td>false</td><td>Thời gian hiệu lực của mã code. <br>Đơn vị tính: Phút. </td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Secretkey của tài khoản.</td></tr><tr><td>MultiChannelTempId</td><td>string</td><td>true</td><td>Id do ViHAT cung cấp. Khi muốn sử dụng hàm này tài khoản của bạn phản có OA ZNS và brandname. Bạn cung cấp tempid của ZNS và template của tin SMS cho nhân viên kinh doanh để tạo MultiChannelTempId.</td></tr><tr><td>TypeId</td><td>string</td><td>true</td><td>1: Chỉ tạo ra mã Code.<br>2: Tạo ra và gửi tin nhắn về máy.</td></tr></tbody></table>

***

* Response:&#x20;

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d533459ee42b2b9525ba9eabf6a8156"
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

| Thuốc tính   | Kiểu dữ liệu | Mô tả                             |
| ------------ | ------------ | --------------------------------- |
| CodeResult   | string       | Mã trả về.                        |
| SMSID        | string       | ID tin nhắn do esms trả về.       |
| ErrorMessage | string       | Thông tin lỗi trả về (nếu có lỗi) |

* [x] **CHECKCODE: Kiểm tra xem mã đã tạo có hợp lệ hay không**

<mark style="color:green;">**`GET`**</mark> <https://rest.esms.vn/MainService.svc/json/CheckCodeGen_V4_get?ApiKey={{ApiKey}}&SecretKey={{SecretKey}}&Phone={{{Phone}}&Code={{Code}}>

* **Response Type:** <mark style="color:orange;">application/json</mark>

{% code overflow="wrap" %}

```
curl --location --globoff 'https://rest.esms.vn/MainService.svc/json/CheckCodeGen_V4_get?ApiKey={{ApiKey}}&SecretKey={{SecretKey}}&Phone=0901888484&Code=1NTTJ6'
```

{% endcode %}

* **Cấu trúc body của request:**

<table><thead><tr><th>Tham số</th><th width="136">Kiểu dữ liệu</th><th data-type="checkbox">Tính bắt buộc</th><th width="270">Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Secretkey của tài khoản.</td></tr><tr><td>Phone</td><td>string</td><td>true</td><td>Số điện thoại người nhận code.</td></tr><tr><td>Code</td><td>string</td><td>true</td><td>Mã code cần check.</td></tr></tbody></table>

* **Response:**

{% tabs %}
{% tab title="100" %}

```
{
 "CodeResult": "100",
 "CountRegenerate": 0,
 "ErrorMessage": "0901888484, Content: Success!"
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}

{% tab title="117" %}

```
{
    "CodeResult": "117",
    "CountRegenerate": 0,
    "ErrorMessage": "0901888484, Content: 1NTTJ6 Code Invalid"
}
```

**Mã code đã được sử dụng hoặc hết thời gian hiệu lực.**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

<table><thead><tr><th width="146.60003662109375">Thuộc tính</th><th width="124">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Request được gửi đến ESMS thành công.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi).</td></tr><tr><td>Content</td><td>string</td><td>Trạng thái của code.</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [**Link code mẫu**](https://samplefordevelopers.esms.vn/#3ccbb0ef-9dec-4574-96db-397674952f88)**.**


# Tin Viber

Cho phép bạn gửi tin nhắn đến số điện thoại đang sử dụng Viber.

<figure><img src="/files/PnzjK4oRa8QU1lfODV0g" alt=""><figcaption><p>Hình mẫu tin nhắn Viber</p></figcaption></figure>

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> [https://rest.esms.vn/MainService.svc/json/Send\_Multiple\_Sms\_OTT/](http://rest.esms.vn/MainService.svc/json/Send_Multiple_Sms_OTT/)

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

{% code overflow="wrap" %}

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/Send_Multiple_Sms_OTT/' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey": "{{ApiKey}}",
    "SecretKey": "{{SecretKey}}",
    "Brandname": "{{Brandname}}",
    "Content": "🍀 🍀 Chúng tôi vừa mở bán căn hộ ĐẸP NHẤT thuộc siêu dự án- Đất nền sổ đỏ sở hữu lâu dài.\r\n🌼 🌼 THANH TOÁN 15%  SỞ HỮU ngay Căn Hộ hiện đại & đẳng cấp nhất. 🏚 🏚  ƯU ĐÃI GIỮ CHỔ SỚM 3% cùng CHIẾT KHẤU lên đến 15%.\r\n🔆 🔆   CĂN ĐẸP GIÁ TỐT cho khách hàng nhanh tay booking. NHẬN BÁO GIÁ NGAY!! 🍀 🍀🍀",
    "OttImgUrl": "https://minio.esms.vn/shared/fbff4ff5694a44c688d4f93eda4572af.png",
    "OttLabel": "Dịch vụ SMS Viber",
    "OttUrl": "https://esms.vn/dich-vu/dich-vu-sms-viber",
    "Phones": [
        "0901888484"
    ],
    "SmsType": "23",
    "RequestId": "96accf59-0c41-4bc7-a5c4-4a466c2e41c2"
}'
// Truyền \r\n để gửi nội dung xuống dòng
// Gửi tin đến nhiều số điện thoại khác nhau sẽ truyền theo cú pháp: "0901888484","0918238965"
```

{% endcode %}

<mark style="color:orange;">**`Lưu ý:`**</mark> Tin nhắn Viber có 4 kiểu nội dung để lựa chọn như sau:\
\- <mark style="color:green;">**Kiểu Văn bản - Ảnh- Nút**</mark> => Khi request truyền các tham số: Content, OttImgUrl, OttUrl, OTTLabel.\
\- <mark style="color:green;">**Kiểu Văn bản - Nút**</mark> => Khi request truyền các tham số: Content, OttUrl, OTTLabel.\
\- <mark style="color:green;">**Kiểu Ảnh**</mark> => Khi request truyền các tham số: OttImgUrl.\
\- <mark style="color:green;">**Kiểu Văn bản**</mark> => Khi request truyền các tham số: Content.

* **Cấu trúc body của request:**

<table><thead><tr><th width="136.77777099609375">Tham số</th><th width="109.7777099609375">Kiểu dữ liệu</th><th width="118.1112060546875" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Secretkey của tài khoản</td></tr><tr><td>Brandname</td><td>string</td><td>true</td><td>Tên Brandname (tên công ty hay tổ chức khi gửi tin sẽ hiển thị trên tin nhắn đó). Chú ý: sẽ phải đăng ký trước khi sử dụng.</td></tr><tr><td>SmsType</td><td>number</td><td>true</td><td>Loại tin nhắn<br>23: Tin nhắn OTT Viber.</td></tr><tr><td>Content</td><td>string</td><td>true</td><td>Nội dung gửi đến người nhận</td></tr><tr><td>OttImgUrl</td><td>string</td><td>false</td><td>Đường dẫn hình ảnh.</td></tr><tr><td>OTTLabel</td><td>string</td><td>false</td><td>Tên nút.</td></tr><tr><td>OttUrl</td><td>string</td><td>false</td><td>Đường dẫn tên nút.</td></tr><tr><td>Phones</td><td>array</td><td>true</td><td><p>Số điện thoại người nhận. </p><p></p><p>Truyền nhiều số điện thoại theo cú pháp</p><p>[ "0901888484","0918238965","..." ]</p></td></tr><tr><td>IsSandBox</td><td>number</td><td>false</td><td>1: Tin gửi ở môi trường test, dùng để kiểm tra kết nối và các thông số tích hợp, không về tin nhắn, không trừ tiền.<br>0: Tin gửi ở môi trường bình thường, có về tin nhắn.</td></tr><tr><td>CallbackUrl</td><td>string</td><td>false</td><td>URL nhận kết quả gửi tin. <br>Xem body mẫu <a href="https://samplefordevelopers.esms.vn/#6acfe1fc-8601-4bce-9549-65bf17f279b1">ở đây</a>. <br>Xem chi tiết <a href="https://developers-v2.esms.vn/esms-api/callback-url">ở đây</a>.</td></tr><tr><td>RequestId</td><td>string</td><td>false</td><td>ID đối tác truyền sang để chặn trùng và đối soát khi cần.<br>Độ dài tối đa 50 ký tự.<br><strong>Mỗi RequestId truyền sang có hiệu lực chặn trong 24h.</strong></td></tr><tr><td>SendDate</td><td>string</td><td>false</td><td>Thời gian hẹn gửi của tin.<br>Không truyền khi tin muốn tin nhắn gửi đi liền.<br>Định dạng: yyyy-mm-dd hh:MM:ss</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d8e0f1f0702544b2acb456ca9ccfd111250"
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}

{% tab title="104" %}

```json
{
    "CodeResult": "104",
    "CountRegenerate": 0,
    "ErrorMessage": "Brand name code is not exist"
}
```

**Brandname truyền chưa đúng hoặc chưa được active.**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

<table><thead><tr><th width="163.666748046875">Thuộc tính</th><th width="121.3333740234375">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Request được gửi đến ESMS thành công.<br><br><strong>Lưu ý:</strong> Mã phản hồi <strong>100</strong> chỉ xác nhận rằng yêu cầu đã được gửi thành công đến hệ thống ESMS, <strong>không phản ánh việc tin nhắn đã được gửi đến số điện thoại người nhận hay chưa</strong>.<br>Để theo dõi trạng thái cuối cùng của tin nhắn, quý khách vui lòng truyền thêm tham số <strong>CallbackUrl</strong>; hệ thống ESMS sẽ tự động gửi phản hồi (callback) đến địa chỉ này khi có trạng thái cuối của tin.</td></tr><tr><td>SMSID</td><td>string</td><td>ID tin nhắn do esms trả về.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi).</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [**Link code mẫu**](https://samplefordevelopers.esms.vn/#9a4ce369-8f02-43cb-9693-f2e9ab827af3)**.**


# Tin SMS quảng cáo

API dùng để gửi tin Quảng cáo đến khách hàng. Mỗi request tối thiểu 30 số để được duyệt tin và tối đa 5000 số.

## **HTTP request**&#x20;

\ <mark style="color:yellow;">**`POST`**</mark> [https://rest.esms.vn/MainService.svc/json/SendMultipleSMSBrandname\_json/](http://rest.esms.vn/MainService.svc/json/SendMultipleSMSBrandname_json/)

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/SendMultipleSMSBrandname_json/' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey": "{{SecretKey}}",
    "SecretKey": "{{SecretKey}}",
    "Brandname": "{{Brandname}}",
    "Content": "{{Content}}",
    "RequestId": "96accf59-0c41-4bc7-a5c4-4a466c2e41c2", 
    "Phones": [
        "0918238965",
        "0901888484",
        "..."
    ],
    "SmsType": "1"
}'
// Mỗi request tối thiểu 30 số và tối đa 5000 số.
```

* **Cấu trúc body của request:**

<table><thead><tr><th width="170">Tham số</th><th width="141">Kiểu dữ liệu</th><th width="136" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey </td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SecretKey </td><td>string</td><td>true</td><td>Secretkey của tài khoản.</td></tr><tr><td>Content </td><td>string</td><td>true</td><td>Nội dung tin nhắn.</td></tr><tr><td>SmsType </td><td>string</td><td>true</td><td>Loại tin nhắn<br>1: Tin quảng cáo.</td></tr><tr><td>Brandname </td><td>string</td><td>true</td><td>Tên Brandname (tên công ty hay tổ chức khi gửi tin sẽ hiển thị trên tin nhắn đó). <br><strong>Chú ý: sẽ phải đăng ký trước khi sử dụng.</strong></td></tr><tr><td>Phones </td><td>array</td><td>true</td><td><p>Số điện thoại người nhận. </p><p></p><p>Truyền nhiều số điện thoại theo cú pháp:</p><p>[ "0901888484","0918238965","..." ]</p></td></tr><tr><td>RequestId</td><td>string</td><td>false</td><td>ID đối tác truyền sang để chặn trùng và đối soát khi cần.<br>Độ dài tối đa 50 ký tự.<br><strong>Mỗi RequestId truyền sang có hiệu lực chặn trong 24h.</strong></td></tr><tr><td>SendDate</td><td>string</td><td>false</td><td>Thời gian hẹn gửi của tin. <br>Không truyền khi tin muốn tin nhắn gửi đi liền.<br>Định dạng: yyyy-mm-dd hh:MM:ss</td></tr><tr><td>Sandbox</td><td>string</td><td>false</td><td>1: Tin gửi ở môi trường test, dùng để kiểm tra kết nối và các thông số tích hợp, không về tin nhắn, không trừ tiền.<br>0: Tin gửi ở môi trường bình thường, có về tin nhắn.</td></tr><tr><td>campaignid</td><td>string</td><td>false</td><td>Tên chiến dịch gửi tin, tối đa 254 ký tự.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d533459ee42b2b9525ba9eabf6a8156"
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}

{% tab title="104" %}

```json
{
    "CodeResult": "104",
    "CountRegenerate": 0,
    "ErrorMessage": "Brand name code is not exist"
}
```

**Brandname truyền chưa đúng hoặc chưa được active.**
{% endtab %}

{% tab title="107" %}

```json
{
    "CodeResult": "107",
    "CountRegenerate": 0,
    "ErrorMessage": "Each request has at least 30 numbers to be approved"
}
```

**Tạo tin không thành công. Mỗi request phải có ít nhất 30 số điện thoại hợp lệ.**
{% endtab %}

{% tab title="124" %}

```json
{
    "CodeResult": "124",
    "CountRegenerate": 0,
    "ErrorMessage": "Request exist 1"
}
```

**Trùng RequestId. Mỗi RequestId chỉ được gửi cho 1 request.**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

<table><thead><tr><th width="141.66668701171875">Thuộc tính</th><th width="137.6666259765625">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Request được gửi đến ESMS thành công.<br><br><strong>Lưu ý:</strong> Mã phản hồi <strong>100</strong> chỉ xác nhận rằng yêu cầu đã được gửi thành công đến hệ thống ESMS, <strong>không phản ánh việc tin nhắn đã được gửi đến số điện thoại người nhận hay chưa</strong>.<br>Để theo dõi trạng thái cuối cùng của tin nhắn, quý khách vui lòng truyền thêm tham số <strong>CallbackUrl</strong>; hệ thống ESMS sẽ tự động gửi phản hồi (callback) đến địa chỉ này khi có trạng thái cuối của tin.</td></tr><tr><td>SMSID</td><td>string</td><td>ID tin nhắn do esms trả về.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi).</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [***Link code mẫu.***](https://samplefordevelopers.esms.vn/#001e2636-af74-42d3-b25a-173b1dd1faed)
* *<mark style="color:orange;">**Để lấy kết quả gửi tin quảng cáo, vui lòng sử dụng api tại link:**</mark>* [***Link hàm***](https://developers.esms.vn/esms-api/ham-truy-xuat-va-dang-ky/ham-kiem-tra-trang-thai-tin-nhan-theo-khoang-thoi-gian) .


# Tin Voice OTP

Cần liên hệ CSKH để có tỉ lệ nhận tin nhắn cao.

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> [https://rest.esms.vn/MainService.svc/json/SendMultipleMessage\_V4\_post\_json/](http://rest.esms.vn/MainService.svc/json/SendMultipleMessage_V4_post_json/)<br>

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/SendMultipleMessage_V4_post_json/' \
--header 'Content-Type: application/json' \
--data '{
   "ApiKey": "{{ApiKey}}",
   "SecretKey": "{{SecretKey}}",
   "Content": "686868",
   "Phone": "0901888484",
   "SmsType": "8",
   "RequestId": "96accf59-0c41-4bc7-a5c4-4a466c2e41c2"
}'
```

* **Cấu trúc body của request:**

<table><thead><tr><th width="145">Tham số</th><th width="121">Kiểu dữ liệu</th><th width="147" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey eSMS cung cấp.</td></tr><tr><td>Content</td><td>string</td><td>true</td><td>Nội dung tin nhắn.</td></tr><tr><td>Phone</td><td>string</td><td>true</td><td>Số điện thoại nhận tin nhắn.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>SecretKey eSMS cung cấp.</td></tr><tr><td>SmsType</td><td>string</td><td>true</td><td>Loại tin nhắn<br>8: Tin Cố định giá rẻ</td></tr><tr><td>Unicode</td><td>string</td><td>false</td><td><p>Gửi nội dung có dấu<br>1: Có dấu.</p><p>0: Không dấu.</p></td></tr><tr><td>Sandbox</td><td>string</td><td>false</td><td>1: Tin gửi ở môi trường test, dùng để kiểm tra kết nối và các thông số tích hợp, không về tin nhắn, không trừ tiền.<br>0: Tin gửi ở môi trường bình thường, có về tin nhắn.</td></tr><tr><td>campaignid</td><td>string</td><td>false</td><td>Tên chiến dịch.</td></tr><tr><td>RequestId</td><td>string</td><td>false</td><td>ID đối tác truyền sang để chặn trùng và đối soát khi cần.<br>Độ dài tối đa 50 ký tự.<br><strong>Mỗi RequestId truyền sang có hiệu lực chặn trong 24h.</strong></td></tr><tr><td>CallbackUrl</td><td>string</td><td>false</td><td>URL nhận kết quả gửi tin. <br>Xem body mẫu <a href="https://samplefordevelopers.esms.vn/#20f85e1f-3d9e-4ff4-bc4f-8d9c9edbc88a">ở đây</a>.<br>Xem chi tiết <a href="/pages/HxTrJlnDLexPUwac9BWb">ở đây</a>.</td></tr><tr><td>SendDate</td><td>string</td><td>false</td><td>Thời gian hẹn gửi của tin. <br>Không truyền khi tin muốn tin nhắn gửi đi liền.<br>Định dạng: yyyy-mm-dd hh:MM:ss</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d8e0f1f0702544b2acb456ca9ccfd111250"
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}

{% tab title="99" %}

```
{
  "error": "Invalid request"
}
```

**Kiểm tra lại thông tin kết nối hoặc liên hệ bộ phận chăm sóc khách hàng để được hỗ trợ khi gặp lỗi này.**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

<table><thead><tr><th width="137.59991455078125">Thuộc tính</th><th width="143.86669921875">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Request được gửi đến ESMS thành công.<br><br><strong>Lưu ý:</strong> Mã phản hồi <strong>100</strong> chỉ xác nhận rằng yêu cầu đã được gửi thành công đến hệ thống ESMS, <strong>không phản ánh việc tin nhắn đã được gửi đến số điện thoại người nhận hay chưa</strong>.<br>Để theo dõi trạng thái cuối cùng của tin nhắn, quý khách vui lòng truyền thêm tham số <strong>CallbackUrl</strong>; hệ thống ESMS sẽ tự động gửi phản hồi (callback) đến địa chỉ này khi có trạng thái cuối của tin.</td></tr><tr><td>SMSID</td><td>string</td><td>ID của tin nhắn mới được tạo ra trên hệ thống eSMS. Dùng ID này để query lấy trạng thái tin nhắn.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi).</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu của các ngôn ngữ ở link:**</mark>* [**Link code mẫu.**](https://samplefordevelopers.esms.vn/#562c21f1-e073-4352-8a24-eac62657953b)


# Hàm truy xuất và đăng ký

Version: v2\_08\_2022


# Hàm lấy số dư tài khoản

Đây là hàm cơ bản đầu tiên mà bạn nên thử, hàm giúp bạn lấy về số dư trong tài khoản của bạn.

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> <https://rest.esms.vn/MainService.svc/json/GetBalance_json>

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/GetBalance_json' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey": "{{ApiKey}}",
    "SecretKey": "{{SecretKey}}"
}'
```

* **Cấu trúc body của request:**

<table><thead><tr><th width="164.20001220703125">Tham số</th><th width="140">Kiểu dữ liệu</th><th width="142.199951171875" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey eSMS cung cấp.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>SecretKey eSMS cung cấp.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "Balance": 36693,
    "CodeResponse": "100",
    "UserID": 9999
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```json
{
    "Balance": 0,
    "CodeResponse": "101",
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}
{% endtabs %}

**Cấu trúc body của response:**

| Thuộc tính   | Kiểu dữ liệu | Mô tả                           |
| ------------ | ------------ | ------------------------------- |
| Balance      | string       | Số dư tài khoản chính.          |
| CodeResponse | string       | Mã trả về.                      |
| UserID       | string       | Id user tài khoản của hệ thống. |

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [**Link code mẫu**](https://samplefordevelopers.esms.vn/#571b0b39-3ce0-4102-817c-132beb05c7d8)**.**


# Hàm kiểm tra trạng thái tin nhắn theo khoảng thời gian

API cho phép đối tác lấy sản lượng tin nhắn trong một khoảng thời gian.

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> [https://rest.esms.vn/MainService.svc/json/GetSmsSentData\_V2](http://rest.esms.vn/MainService.svc/json/GetSmsSentData_V2')

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/GetSmsSentData_V2' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey": "{{ApiKey}}",
    "SecretKey": "{{SecretKey}}",
    "SmsType": "2",
    "From": "2025-01-01 06:00:00",
    "To": "2025-01-02 18:00:00",
    "Page": 1,
    "PageSize": 500
}'
```

**Cấu trúc body của request:**

<table><thead><tr><th width="172">Tham số</th><th width="133">Kiểu dữ liệu</th><th width="180" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey eSMS cung cấp.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>SecretKey eSMS cung cấp.</td></tr><tr><td>From </td><td>string</td><td>true</td><td>Lấy dữ liệu từ ngày nào (theo ngày tạo tin)<br> Định dạng: yyyy-MM-dd HH:mm:ss.</td></tr><tr><td>To</td><td>string</td><td>true</td><td>Lấy dữ liệu đến ngày nào (theo ngày tạo tin).<br>Định dạng: yyyy-MM-dd HH:mm:ss.</td></tr><tr><td>Page</td><td>string</td><td>true</td><td>Lấy bắt đầu từ trang bao nhiêu.</td></tr><tr><td>PageSize</td><td>string</td><td>true</td><td>Số lượng tin nhắn cần xem (tối đa 500 tin nhắn).</td></tr><tr><td>SmsType</td><td>string</td><td>true</td><td>Loại tin nhắn<br>1: Tin quảng cáo.<br>2: Tin CSKH.<br>8: Tin Cố định giá rẻ.<br>23: Tin Viber.<br>24: Zalo ưu tiên.<br>25: Zalo bình thường.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```
{
    "CodeResult": "100",
    "CountTotal": 2
    "SentData": [
        {
            "Campaign": "Chiến dịch 02/10/2023",
            "Content": "Cam on quy khach da su dung dich vu cua chung toi. Chuc quy khach mot ngay tot lanh!",
            "Phone": "0901888484",
            "ReferenceId": "35781d6c25524e40a035c26663189549",
            "SellPrice": 345.0,
            "SendResult": 0,
            "SendStatus:5,
            "SentTime": "/Date(1705484048995+0700)/",
            "SmsId": 29028845,
            "SmsType": 2
        },
        {
            "Campaign": "Chiến dịch 02/10/2023",
            "Content": "Cam on quy khach da su dung dich vu cua chung toi. Chuc quy khach mot ngay tot lanh!",
            "Phone": "0901888484",
            "ReferenceId": "0aac72e0-ba9b-4348-8530-d18d105778db18",
            "SellPrice": 790.0000,
            "SendResult": 1,
            "SendStatus:5,
            "SentTime": "/Date(1705484048995+0700)/",
            "SmsId": 29028845,
            "SmsType": 2
        }
    ]
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "ErrorMessage": "Authorize Failed."
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}
{% endtabs %}

**Cấu trúc body của response:**

<table><thead><tr><th width="140.79998779296875">Thuộc tính</th><th width="130.5999755859375">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td> CodeResult</td><td>string</td><td> Mã trả về.</td></tr><tr><td>CountTotal</td><td>string</td><td>Tổng số tin nhắn.</td></tr><tr><td>SentData</td><td>array</td><td>Chi tiết tin nhắn.</td></tr></tbody></table>

**Câu trúc thuộc tính từng object trong SentData**

<table><thead><tr><th width="142.60003662109375">Thuộc tính</th><th width="134">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>Campaign</td><td>string</td><td><p>Tên chiến dịch.</p><p><br>Lấy dữ liệu của tham số campaignid khi request gửi tin.</p></td></tr><tr><td>Content</td><td>string</td><td>Nội dung tin nhắn.</td></tr><tr><td>Phone</td><td>string</td><td>Số điện thoại nhận tin nhắn.</td></tr><tr><td>ReferenceId</td><td>string</td><td>SmsId trả về từ các hàm gửi tin nhắn.</td></tr><tr><td>SellPrice</td><td>string</td><td>Giá của tin.</td></tr><tr><td>SendResult</td><td>string</td><td><p>Kết quả cuối của tin nhắn<br></p><p>1: Tin đã được gửi thành công. <br>0: Tin thất bại. <br>2: Tin chưa xác định trạng thái.</p></td></tr><tr><td>SendStatus</td><td>string</td><td>Trạng thái tin nhắn:<br><br>0: Đang soạn thảo.<br>1: Chờ duyệt.<br>2: Chờ gửi.<br>4: Từ chối.<br>5: Đã gửi xong (Kiểm tra thêm SendResult để biết tin gửi thành công hay thất bại).<br>7: Đã gửi chờ báo cáo</td></tr><tr><td>SentTime</td><td>string</td><td>Thời gian gửi tin.</td></tr><tr><td>SmsId</td><td>string</td><td>Id của tin nhắn trên giao diện eSMS<br><img src="/files/3wUEulrv0Q9ckify7nlR" alt=""></td></tr><tr><td>SmsType</td><td>string</td><td>Loại tin nhắn<br>1: Tin quảng cáo.<br>2: Tin CSKH.<br>8: Tin Cố định giá rẻ.<br>23: Tin Viber.<br>24: Zalo ưu tiên.<br>25: Zalo bình thường.</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [**Link code mẫu**](https://samplefordevelopers.esms.vn/#282f1bec-d093-4c68-8f99-f4d25024e9f8)**.**


# Hàm kiểm tra tin nhắn theo SMSID

Hàm giúp bạn kiểm tra trạng thái của tin nhắn đã gửi đi. Lưu ý: Chỉ lấy dữ liệu các tin trong vòng 7 ngày gần nhất.

#### HTTP Request

\ <mark style="color:green;">**`GET`**</mark> <https://rest.esms.vn/MainService.svc/json/GetSendStatus?RefId={{SMSID}}&ApiKey={{ApiKey}}&SecretKey={{SecretKey}}>

* **Response Type:** <mark style="color:orange;">application/json</mark>

{% code overflow="wrap" %}

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/GetSendStatus?RefId=6007b4bc6db546b194062c19620cc820200&ApiKey={{ApiKey}}&SecretKey={{SecretKey}}' \
```

{% endcode %}

* **Câu trúc body của request:**

<table><thead><tr><th width="139">Tham số</th><th width="129">Kiểu dữ liệu </th><th width="155" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>RefId</td><td>string</td><td>true</td><td>SmsId hệ thống trả về từ mỗi hàm gửi tin nhắn.</td></tr><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey eSMS cung cấp.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>SecretKey eSMS cung cấp.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```
{
    "CodeResponse": "100",
    "SMSID": "434a124c-7818-4f45-bdf2-7f7b07fff210100",
    "SendFailed": 0,
    "SendStatus": 5,
    "SendSuccess": 1,
    "TotalPrice": 850.0000,
    "TotalReceiver": 1,
    "TotalSent": 1
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResponse": "101",
    "SMSID": "47756317-0cbe-494a-9d02-c85703a1baff20"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}
{% endtabs %}

**Cấu trúc body của response:**

<table><thead><tr><th width="174">Thuộc tính</th><th width="155">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResponse</td><td>string</td><td>Mã trả về.</td></tr><tr><td>SMSID</td><td>string</td><td>SmsId kiểm tra.</td></tr><tr><td>SendFailed</td><td>string</td><td>Số lượng tin thất bại.</td></tr><tr><td>SendStatus</td><td>string</td><td>Trạng thái tin nhắn<br>1: Chờ Duyệt<br>2: Chờ gửi.<br>5: Đã gửi xong.</td></tr><tr><td>SendSuccess</td><td>string</td><td>Số lượng tin thành công.</td></tr><tr><td>TotalPrice</td><td>string</td><td>Tổng tiền của đơn.</td></tr><tr><td>TotalReceiver</td><td>string</td><td>Số lượng người nhận.</td></tr><tr><td>TotalSent</td><td>string</td><td>Số lượng gửi.</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [**Link code mẫu**](https://samplefordevelopers.esms.vn/#17b5d3c2-11b8-4748-ad0a-442a42d43532)**.**


# Hàm kiểm tra chi tiết từng số trong tin nhắn

Hàm lấy danh sách SĐT của một tin nhắn đã gửi (dựa trên SmsID hệ thống trả về) kèm theo trạng thái gửi (SĐT đó đã gửi thành công chưa?). Lưu ý: Chỉ lấy dữ liệu các tin trong vòng 7 ngày gần nhất.

## HTTP request

\ <mark style="color:green;">**`GET`**</mark> [https://rest.esms.vn/MainService.svc/json/GetSmsReceiverStatus\_get?ApiKey={{ApiKey}}\&SecretKey={{SecretKey}}\&RefId={{SMSID}}](http://rest.esms.vn/MainService.svc/json/GetSmsReceiverStatus_get?ApiKey={{ApiKey}}\&SecretKey={{SecretKey}}\&RefId={{SMSID}})

* **Response Type:** <mark style="color:orange;">application/json</mark>

{% code overflow="wrap" %}

```
curl --location --globoff 'https://rest.esms.vn/MainService.svc/json/GetSmsReceiverStatus_get?ApiKey={{ApiKey}}&SecretKey={{SecretKey}}&RefId=1e8caf001e494a9b873cc70535ad8b15'
```

{% endcode %}

* **Cấu trúc body của request:**

<table><thead><tr><th width="139">Tham số</th><th width="131">Kiểu dữ liệu</th><th width="149" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey eSMS cung cấp.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>SecretKey eSMS cung cấp.</td></tr><tr><td>RefId</td><td>string</td><td>true</td><td>SmsId hệ thống trả về từ mỗi hàm gửi tin nhắn.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "ReceiverList": [
        {
            "IsSent": true,
            "NetworkName": "Viettel",
            "Phone": "0901888484",
            "Retry": 0,
            "SentResult": true
        },
        {
            "IsSent": true,
            "NetworkName": "Vinaphone",
            "Phone": "0918238965",
            "Retry": 0,
            "SentResult": false
        },
        {
            "IsSent": true,
            "NetworkName": "Mobifone",
            "Phone": "0765418062",
            "Retry": 0,
            "SentResult": false
        }
    ]
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}
{% endtabs %}

**Cấu trúc body của response:**

<table><thead><tr><th width="145.99993896484375">Thuộc tính</th><th width="151.39990234375">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Mã trả về.</td></tr><tr><td>ReceiverList</td><td>array</td><td>Chi tiết từng số trong tin nhắn.</td></tr></tbody></table>

**Cấu trúc thuộc tính từng object trong ReceiverList**

<table><thead><tr><th width="145">Thuộc tính</th><th width="154.5999755859375">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>IsSent</td><td>string</td><td>Trạng thái đi tin:<br>true: tin đã được gửi.<br>false: tin chưa được gửi.</td></tr><tr><td>NetworkName</td><td>string</td><td>Nhà mạng của số điện thoại.</td></tr><tr><td>Phone</td><td>string</td><td>Số điện thoại.</td></tr><tr><td>Retry</td><td>string</td><td>Số lần gửi lại tin nhắn.</td></tr><tr><td>SentResult</td><td>string</td><td>Kết quả tin nhắn:<br>True: Gửi thành công.<br>False: Gửi thất bại.</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [**Link code mẫu**](https://samplefordevelopers.esms.vn/#1c1433bf-69be-4882-87d4-dd0c686f565c)**.**


# Hàm lấy danh sách Brandname

## HTTP request

\ <mark style="color:green;">**`GET`**</mark> <https://rest.esms.vn/MainService.svc/json/GetListBrandname/{{ApiKey}}/{{SecretKey}}>

* **Response Type:** <mark style="color:orange;">application/json</mark>

{% code overflow="wrap" %}

```json
curl --location --globoff 'https://rest.esms.vn/MainService.svc/json/GetListBrandname/{{ApiKey}}/{{SecretKey}}'
```

{% endcode %}

* **Câu trúc body của request:**

<table><thead><tr><th width="158.20001220703125">Tham số</th><th width="152">Kiểu dữ liệu</th><th width="134" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Secretkey của tài khoản.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResponse": "100",
    "ListBrandName": [
        {
            "Brandname": "Baotrixemay",
            "Type": 2
        },
        {
            "Brandname": "QC_ONLINE",
            "Type": 1
        },
        {
            "Brandname": "BAT DONG SAN GIA TOT",
            "Type": 23
        }
    ]
}
```

Request hợp lệ.
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}
{% endtabs %}

**Cấu trúc body của response:**

<table><thead><tr><th width="181.4000244140625">Thuộc tính</th><th width="189.7999267578125">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td> CodeResponse</td><td>string</td><td>Mã trả về.</td></tr><tr><td>ListBrandName</td><td>array</td><td>Danh sách brandname hiện đang kích hoạt ở tài khoản.</td></tr></tbody></table>

**Cấu trúc thuộc tính từng object ListBrandName**

<table><thead><tr><th width="185">Thuộc tính</th><th width="190.60009765625">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>Brandname</td><td>string</td><td>Tên brandname.</td></tr><tr><td>Type</td><td>string</td><td>Loại brandname<br><br>1: brandname quảng cáo.<br>2: brandname CSKH.<br>23: brandname Viber.</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [**Link code mẫu**](https://samplefordevelopers.esms.vn/#3133a801-03e9-4e81-8de1-ac27549fb966)**.**


# Hàm lấy danh sách template tin chăm sóc khách hàng

Đối với các tin nhắn CSKH, doanh nghiệp cần đăng ký trước các mẫu tin nhắn (Template) với nhà mạng trước khi gửi. Hàm này cho phép truy xuất danh sách Template của một Brandname thuộc tài khoản.

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark>[ ](http://rest.esms.vn/MainService.svc/json/GetTemplate/)<https://rest.esms.vn/MainService.svc/json/GetTemplate/>

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/GetTemplate/' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey": "{{ApiKey}}",
    "SecretKey": "{{SecretKey}}",
    "SmsType": "2",
    "Brandname": "Baotrixemay"
}'
```

* **Cấu trúc body của request:**

<table><thead><tr><th>Tham số</th><th width="136">Kiểu dữ liệu</th><th width="167" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Secretkey của tài khoản.</td></tr><tr><td>SmsType</td><td>string</td><td>true</td><td>Loại tin nhắn<br>2: Loại tin Chăm sóc khách hàng.</td></tr><tr><td>BrandName</td><td>string</td><td>true</td><td>Tên brandname.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "BrandnameTemplates": [
        {
            "NetworkID": 6,
            "TempContent": "{P1,20} la ma xac minh dang ky Baotrixemay cua ban",
            "TempId": 458
        },
        {
            "NetworkID": 4,
            "TempContent": "Baotrixemay da nhan duoc so tien thanh toan {P2,20} VND luc {P2,20} cho don hang {P1,20}. Cam on quy khach!",
            "TempId": 466
        },
        {
            "NetworkID": 2,
            "TempContent": "Cam on quy khach da su dung dich vu cua chung toi. Chuc quy khach mot ngay tot lanh!",
            "TempId": 12640
        },
        {
            "NetworkID": 5,
            "TempContent": "Cam on quy khach da su dung dich vu cua chung toi. Chuc quy khach mot ngay tot lanh!",
            "TempId": 12647
        },
        {
            "NetworkID": 3,
            "TempContent": "Chuc mung sinh nhat {P2,50}. Kinh chuc QK co nhieu suc khoe, thanh cong va hanh phuc! Nhan dip sinh nhat xin gui den {P2,50} coupon {P2,20}. Tran trong.",
            "TempId": 12899
        },
        {
            "NetworkID": 1,
            "TempContent": "Cam on quy khach da su dung dich vu cua chung toi. Chuc quy khach mot ngay tot lanh!",
            "TempId": 12884
        }
    ],
    "CodeResult": "100",
    "ErrorMessage": "success"
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

{% endtab %}

{% tab title="104" %}

```
```

{% endtab %}
{% endtabs %}

**Cấu trúc body của response:**

<table><thead><tr><th width="186.5999755859375">Thuộc tính</th><th width="167.199951171875">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>BrandnameTemplates</td><td>array</td><td>Thông tin chi tiết template.</td></tr><tr><td>CodeResult</td><td>string</td><td>Mã trả về</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi)</td></tr></tbody></table>

**Cấu trúc thuộc tính từng object trong BrandnameTemplates**

<table><thead><tr><th width="183.79998779296875">Thuộc tính</th><th width="170.800048828125">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>NetworkID</td><td>string</td><td>Template có thể gửi với nhà mạng nào<br><br>1: Viettel<br>2: Mobi<br>3: Vinaphone<br>4: Vietnammobile<br>5: Gtel<br>6: Itel<br>7: Reddi</td></tr><tr><td>TempContent</td><td>string</td><td>Nội dung template đã đăng ký.</td></tr><tr><td>TempId</td><td>string</td><td>TempId của nhà mạng</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu của các ngôn ngữ ở link:**</mark>* [**Code mẫu**](https://samplefordevelopers.esms.vn/#ca4176c1-a1af-4d93-bf29-81cd9dc3a85c) **.**


# Hàm tạm tính giá tin nhắn CSKH

## HTTP request

\ <mark style="color:green;">**`GET`**</mark> <https://rest.esms.vn/MainService.svc/json/SummaryMultipleMessage_V4_get?Phone={{Phone}}&Content={{Content}}&ApiKey={{ApiKey}}&SecretKey={{SecretKey}}&SmsType=2&BrandName={{BrandName}}>

* **Response Type:** <mark style="color:orange;">application/json</mark>

{% code overflow="wrap" %}

```
curl --location 'https://rest.esms.vn/MainService.svc/json/SummaryMultipleMessage_V4_get?Phone=0901888484&Content=456756756%20la%20ma%20xac%20minh%20dang%20ky%20Baotrixemay%20cua%20ban&ApiKey={{ApiKey}}&SecretKey={{SecretKey}}&SmsType=2&BrandName=Baotrixemay'
```

{% endcode %}

* **Cấu trúc body của request:**

<table><thead><tr><th width="184">Tham số</th><th width="137">Kiểu dữ liệu</th><th width="154" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>SecretKey của tài khoản.</td></tr><tr><td>Brandname</td><td>string</td><td>true</td><td>Tên thương hiệu.</td></tr><tr><td>SmsType</td><td>string</td><td>true</td><td>Loại tin nhắn, SmsType = 2: Loại tin chăm sóc khách hàng.</td></tr><tr><td>Phone</td><td>string</td><td>true</td><td>Số điện thoại nhận tin.</td></tr><tr><td>Content</td><td>string</td><td>true</td><td>Nội dung tin nhắn.</td></tr><tr><td>IsUnicode</td><td>string</td><td>false</td><td>Nội dung có chứ Unicode:<br>0: Nội dung không dấu.<br>1: Nội dung có dấu.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "ErrorMessage": "success",
    "TotalPrice": 850,
    "TotalReceiver": 1
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "ErrorMessage": "Authorize Failed."
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}

{% tab title="104" %}

```
{
    "CodeResult": "104",
    "ErrorMessage": "Brand name code is not exist"
}
```

**Brandname truyền chưa đúng hoặc chưa được active.**
{% endtab %}
{% endtabs %}

**Cấu trúc body của response:**

| Thuộc tính    | Kiểu dữ liệu | Mô tả                        |
| ------------- | ------------ | ---------------------------- |
| CodeResult    | string       | Mã trả về.                   |
| ErrorMessage  | string       | Nội dung thông báo.          |
| TotalPrice    | string       | Tổng tiền tin.               |
| TotalReceiver | string       | Tổng số điện thoại nhận tin. |

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [**Link code mẫu**](https://samplefordevelopers.esms.vn/#b80773ed-fabf-49ee-bb78-c5eefe447d74)**.**


# Hàm tạm tính giá tin nhắn quảng cáo

## HTTP request&#x20;

\ <mark style="color:yellow;">**`POST`**</mark> <https://rest.esms.vn/MainService.svc/json/SummaryMultipleSMSBrandname/>

* **Content Type:** <mark style="color:orange;">text/plain</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```
curl --location 'https://rest.esms.vn/MainService.svc/json/SummaryMultipleSMSBrandname/' \
--header 'Content-Type: text/plain' \
--data '<RQST>
<APIKEY>{{APIKEY}}</APIKEY>
<SECRETKEY>{{SECRETKEY}}</SECRETKEY>
<CONTENT>{{CONTENT}}</CONTENT>
<SMSTYPE>1</SMSTYPE>
<BRANDNAME>{{BRANDNAME}}</BRANDNAME>
<CONTACTS>
<CUSTOMER><PHONE>{{PHONE}}</PHONE></CUSTOMER>
<CUSTOMER><PHONE>{{PHONE}}</PHONE></CUSTOMER>
<CUSTOMER><PHONE>{{PHONE}}</PHONE></CUSTOMER>
<CUSTOMER><PHONE>{{PHONE}}</PHONE></CUSTOMER>
<CUSTOMER><PHONE>{{PHONE}}</PHONE></CUSTOMER>
<CUSTOMER><PHONE>{{PHONE}}</PHONE></CUSTOMER>
</CONTACTS>
</RQST>'
```

* **Cấu trúc body của request:**

<table><thead><tr><th width="187">Thuốc tính</th><th width="146">Kiểu dữ liệu</th><th width="137" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>APIKEY</td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SECRETKEY</td><td>string</td><td>true</td><td>SecretKey của tài khoản.</td></tr><tr><td>CONTENT</td><td>string</td><td>true</td><td>Nội dung tin nhắn.</td></tr><tr><td>SMSTYPE</td><td>string</td><td>true</td><td>Loại tin nhắn<br><br>1: Loại tin Quảng cáo</td></tr><tr><td>BRANDNAME</td><td>string</td><td>true</td><td>Tên thương hiệu.</td></tr><tr><td>PHONE</td><td>string</td><td>true</td><td>Số điện thoại nhận tin.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "ErrorMessage": "success",
    "TotalPrice": 1691300.0000,
    "TotalReceiver": 2997
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}

{% tab title="104" %}

```json
{
    "CodeResult": "104",
    "ErrorMessage": "Brand name code is not exist"
}
```

**Brandname truyền chưa đúng hoặc chưa được active.**
{% endtab %}
{% endtabs %}

**Cấu trúc body của response:**

<table><thead><tr><th width="181">Thuốc tính</th><th width="153">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td> CodeResult</td><td>string</td><td>Mã trả về.</td></tr><tr><td> ErrorMessage</td><td>string</td><td>Nội dung thông báo.</td></tr><tr><td>TotalPrice</td><td>string</td><td>Tổng tiền tin.</td></tr><tr><td>TotalReceiver</td><td>string</td><td>Tổng số điện thoại nhận tin.</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman**</mark>**:*** [**Link code mẫu**](https://samplefordevelopers.esms.vn/#938df6e6-b2fb-45b0-a036-2852f508cf74)**.**


# Hàm lấy danh sách Zalo OA

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> <https://rest.esms.vn/MainService.svc/json/ZNS/GetListZOA/>

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/ZNS/GetListZOA/' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey": "{{ApiKey}}",
    "SecretKey": "{{SecretKey}}"
}'
```

* **Cấu trúc body trong request:**

<table><thead><tr><th width="162">Tham số</th><th width="136">Kiểu dữ liệu</th><th width="143" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>SecretKey của tài khoản.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "ErrorMessage": "success",
    "ZOAList": [
        {
            "OAID": "745830328927467685",
            "OAName": "Hệ thống ESMS Marketing"
        },
        {
            "OAID": "4097311281936189049",
            "OAName": "SVoucher"
        }
    ]
}   
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "ErrorMessage": "Authorize Failed."
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}
{% endtabs %}

**Cấu trúc body của response:**

<table><thead><tr><th width="165.800048828125">Thuốc tính</th><th width="168.60009765625">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Mã trả về.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi).</td></tr><tr><td>ZOAList</td><td>array</td><td>Danh sách OA đang hoạt động của tài khoản.</td></tr></tbody></table>

**Cấu trúc thuộc tính từng object trong ZOAList**

<table><thead><tr><th width="168">Thuốc tính</th><th width="165">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>OAID</td><td>string</td><td>Zalo OA ID, là ID của trang Zalo Offical Account của doanh nghiệp. <br>Doanh nghiệp cần đăng nhập vào trang quản trị của Zalo OA để lấy phần Zalo OA ID này.<br><strong>Chú ý: sẽ phải đăng ký trước khi sử dụng.</strong></td></tr><tr><td>OAName</td><td>string</td><td>Tên của OA.</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [**Link code mẫu**](https://samplefordevelopers.esms.vn/#cb86e533-d5cc-40cd-844f-465c8cb8dc38)**.**


# Hàm lấy danh sách template Zalo

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> <https://rest.esms.vn/MainService.svc/json/GetTemplate/>

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

{% code overflow="wrap" %}

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/GetTemplate/' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey": "{{ApiKey}}",
    "SecretKey": "{{SecretKey}}",
    "OAId": "4097311281936189049",
    "SmsType": "24"
}'
```

{% endcode %}

* **Cấu trúc body của request:**

<table><thead><tr><th width="159">Tham số</th><th width="126">Kiểu dữ liệu </th><th width="155" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Secretkey của tài khoản.</td></tr><tr><td>OAId</td><td>string</td><td>true</td><td>ID của OA cần lấy template.</td></tr><tr><td>SmsType</td><td>string</td><td>true</td><td>Loại tin<br>24: Zalo ưu tiên.<br>25: Zalo bình thường.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```
{
    "CodeResult": "100",
    "ErrorMessage": "success",
    "ZNSTemplates": [
        {
            "TempContent": "<div class=\"group-desc\" style=\"box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); color: #131820; font-family: Muli, sans-serif; font-size: 16px;\"> <p style=\"box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); margin: 0px; padding: 0px; color: #394e60; font-size: 0.875rem; line-height: 20px;\">Mã OTP của bạn là</p> </div> <p><span class=\"otp-code\" style=\"box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-weight: bold; color: #131820; font-size: 1.5rem; letter-spacing: 3.75px; line-height: 24px; display: block; padding: 12px 0px; font-family: Muli, sans-serif;\">{{otp}}</span></p> <div class=\"group-desc\" style=\"box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); color: #131820; font-family: Muli, sans-serif; font-size: 16px;\"> <p style=\"box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); margin: 0px; padding: 0px; color: #394e60; font-size: 0.875rem; line-height: 20px;\">Không tiết lộ cho bất kỳ ai, Mã xác nhận sẽ có hiệu lực trong 5 phút.</p> </div>",
            "TempId": 205644,
            "TempName": "Xác nhận đăng ký dịch vụ",
            "ZNSTempDetail": [
                {
                    "Limit": 10,
                    "Param": "otp",
                    "ParamLevel": 1,
                    "RequireType": "type_text"
                }
            ]
        }
    ]
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```
{
    "CodeResult": "101",
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}
{% endtabs %}

**Cấu trúc body response:**

<table><thead><tr><th width="174.5999755859375">Thuộc tính</th><th width="136.4000244140625">Kiểu dữ liệu </th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Mã trả về.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi).</td></tr><tr><td>ZNSTemplates</td><td>object</td><td>Thông tin chi tiết template.</td></tr></tbody></table>

**Cấu trúc thuộc tính từng object trong ZNSTemplates**

<table><thead><tr><th width="174">Thuộc tính</th><th width="141.800048828125">Kiểu dữ liệu </th><th>Mô tả</th></tr></thead><tbody><tr><td>TempContent</td><td>string</td><td>Nội dung của template.</td></tr><tr><td>Tempid</td><td>string</td><td>Template ID.</td></tr><tr><td>TempName</td><td>string</td><td>Tên template.</td></tr><tr><td>ZNSTempDetail</td><td>object</td><td>Thông tin chi tiết kiểu biến.</td></tr></tbody></table>

**Cấu trúc thuộc tính từng object trong ZNSTempDetail**

<table><thead><tr><th width="172.199951171875">Thuộc tính</th><th width="144.60009765625">Kiểu dữ liệu </th><th>Mô tả</th></tr></thead><tbody><tr><td>Limit</td><td>string</td><td>Giới hạn độ dài nội dung truyền vào.<br>Khi gửi quá giới hạn này sẽ bị sai template.</td></tr><tr><td>Param</td><td>string</td><td>Tên biến.</td></tr><tr><td>ParamLevel</td><td>string</td><td>Thứ tự của biến</td></tr><tr><td>RequireType</td><td>string</td><td>Kiểu dữ liệu của biến.<br><br>- type_text<br>- type_number <strong>(chỉ truyền số từ 0 đến 9, tối đa là 12 số)</strong><br>- type_date <strong>(truyền theo định dạng dd/MM/yyyy)</strong><br>- type_cta_url</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [**Link code mẫu**](https://samplefordevelopers.esms.vn/#d201e3b3-5f46-4db7-b829-2b730a29b6b4)**.**


# Hàm tạm tính giá tin Zalo

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> <https://rest.esms.vn/MainService.svc/json/SummaryZaloMessage_V4_post_json/><br>

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

{% code overflow="wrap" %}

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/SummaryZaloMessage_V4_post_json/' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey": "{{ApiKey}}",
    "SecretKey": "{{SecretKey}}",
    "Phone": "0901888484",
    "Params": [
        "Anh",
        "2506007899",
        "02/05/2024",
        "360.000"
    ],
    "TempID": "200975",
    "OAID": "4097311281936189049"
}'
```

{% endcode %}

* **Cấu trúc body request:**

<table><thead><tr><th width="146">Tham số</th><th width="132">Kiểu dữ liệu </th><th width="143" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>SecretKey của tài khoản.</td></tr><tr><td>Phone</td><td>string</td><td>true</td><td>Số điện thoại nhận tin.</td></tr><tr><td>Params</td><td>string</td><td>true</td><td><p></p><p>Nội dung gửi đến người nhận <br><strong>*Lưu ý:</strong></p><ol><li><strong>Các tham số truyền vào phải đúng thứ tự như template bạn đăng ký.</strong></li><li><strong>Nếu tham số trùng nhau chỉ cần truyền vào một tham số.</strong></li></ol></td></tr><tr><td>TempID</td><td>string</td><td>true</td><td>Template của Zalo OA mà khách hàng đăng kí với eSMS.</td></tr><tr><td>OAID</td><td>string</td><td>true</td><td>Zalo OA ID, là ID của trang Zalo Offical Account của doanh nghiệp. <br>Doanh nghiệp cần đăng nhập vào trang quản trị của Zalo OA để lấy phần Zalo OA ID này.<br><strong>Chú ý: sẽ phải đăng ký trước khi sử dụng.</strong></td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```
{
    "CodeResult": "100",
    "ErrorMessage": "success",
    "TotalPrice": 660.0000,
    "TotalReceiver": 1
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```
{
    "CodeResult": "101",
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}
{% endtabs %}

**Câu trúc body response:**

<table><thead><tr><th width="194">Thuốc tính</th><th width="189">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Mã trả về.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi).</td></tr><tr><td>TotalPrice</td><td>string</td><td>Tổng tiền tạm tính.</td></tr><tr><td>TotalReceiver</td><td>string</td><td>Tổng số điện thoại nhận tin.</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [**Link code mẫu**](https://samplefordevelopers.esms.vn/#a1b040da-0c02-4e53-b1da-c14e254a197d)**.**


# Lấy quota tin zalo theo OAID

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> <https://rest.esms.vn/MainService.svc/json/ZNS/GetQuota/><br>

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/ZNS/GetQuota/' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey": "{{ApiKey}}",
    "SecretKey": "{{SecretKey}}",
    "OAID": "4097311281936189049"
}'
```

* **Câu trúc body của request:**

<table><thead><tr><th width="151">Tham số</th><th width="134">Kiểu dữ liệu </th><th width="141" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>SecretKey của tài khoản.</td></tr><tr><td>OAID</td><td>string</td><td>true</td><td>Zalo OA ID, là ID của trang Zalo Offical Account của doanh nghiệp. <br>Doanh nghiệp cần đăng nhập vào trang quản trị của Zalo OA để lấy phần Zalo OA ID này.<br><strong>Chú ý: sẽ phải đăng ký trước khi sử dụng.</strong></td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```
{
    "CodeResult": "100",
    "ErrorMessage": "success",
    "DailyQuota": 5000,
    "DailyQuotaPromotion": 0,
    "EstimatedNextMonthPromotionQuota": 425,
    "MonthlyPromotionQuota": 403,
    "RemainingMonthlyPromotionQuota": 403,
    "RemainingQuota": 4992,
    "RemainingQuotaPromotion": 0
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```
{
    "CodeResult": "101",
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}
{% endtabs %}

**Cấu trúc body của response:**

<table><thead><tr><th width="262.4000244140625">Thuộc tính</th><th width="137.800048828125">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Mã trả về.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi).</td></tr><tr><td>DailyQuota</td><td>int</td><td>Số thông báo ZNS OA được gửi trong 1 ngày.<br>Lưu ý: Hạn mức gửi ZNS mỗi ngày của OA sẽ tự động được điều chỉnh dựa theo chất lượng và nhu cầu gửi.</td></tr><tr><td>DailyQuotaPromotion</td><td>int</td><td>Số tin ZNS hậu mãi OA được gửi trong ngày.</td></tr><tr><td>EstimatedNextMonthPromotionQuota</td><td>int</td><td>Số tin ZNS hậu mãi dự kiến mà OA có thể gửi trong tháng tiếp theo.</td></tr><tr><td>MonthlyPromotionQuota</td><td>int</td><td>Số tin ZNS hậu mãi OA được gửi trong tháng.</td></tr><tr><td>RemainingMonthlyPromotionQuota</td><td>int</td><td>Số tin ZNS hậu mãi còn lại OA được gửi trong tháng.</td></tr><tr><td>RemainingQuota</td><td>int</td><td>Số thông báo ZNS OA được gửi trong ngày còn lại.</td></tr><tr><td>RemainingQuotaPromotion</td><td>int</td><td>Số tin ZNS hậu mãi còn lại OA được gửi trong ngày.</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [**Link code mẫu**](https://samplefordevelopers.esms.vn/#f7a3f3f8-3bb2-4b53-af42-66afe6966a69)**.**


# Hàm lấy thông tin đánh giá của khách hàng

Lưu ý: Tối đa mỗi request giới hạn 50 đánh giá.

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> <https://rest.esms.vn/MainService.svc/json/ZNS/GetRating/><br>

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

{% code overflow="wrap" %}

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/ZNS/GetRating/' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey": "APIKEYCUABAN",
    "SecretKey": "SECRETKEYCUABAN",
    "OAID": "4097311281936189049",
    "TemplateID": "266986",
    "FromTime": "2024-07-28 00:00:00",
    "ToTime": "2024-07-30 23:59:59",
    "Offset": "0",
    "Limit": "50"
}'
```

{% endcode %}

* **Cấu trúc body của request:**

<table><thead><tr><th width="156">Tham số</th><th width="122">Kiểu dữ liệu</th><th width="137" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>SecretKey của tài khoản.</td></tr><tr><td>OAID</td><td>string</td><td>true</td><td>Zalo OA ID, là ID của trang Zalo Offical Account của doanh nghiệp. <br>Doanh nghiệp cần đăng nhập vào trang quản trị của Zalo OA để lấy phần Zalo OA ID này.<br><strong>Chú ý: sẽ phải đăng ký trước khi sử dụng.</strong></td></tr><tr><td>TemplateID</td><td>string</td><td>true</td><td>Template của Zalo OA mà khách hàng đăng kí với eSMS.</td></tr><tr><td>FromTime</td><td>string</td><td>true</td><td>Thời gian bắt đầu lấy đánh giá. Định dạng: yyyy-mm-dd hh:mm:ss .</td></tr><tr><td>ToTime</td><td>string</td><td>true</td><td>Thời gian kết thúc lấy đánh giá. Định dạng: yyyy-mm-dd hh:mm:ss .</td></tr><tr><td>Offset</td><td>string</td><td>true</td><td>Vị trí thứ tự đánh giá đầu tiên trả về. Bắt đầu từ vị trí 0.</td></tr><tr><td>Limit</td><td>string</td><td>true</td><td>Số lượng đánh giá cần xem.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "ErrorMessage": "success",
    "Data": [
        {
            "feedbacks": [
                "Nhân viên tư vấn nhiệt tình, thái độ vui vẻ, dễ thương",
                "Chính sách hỗ trợ rõ ràng, đầy đủ và dễ hiểu",
                "Chất lượng sản phẩm rất tốt",
                "Giao hàng nhanh",
                "Dịch vụ chăm sóc rất tốt"
            ],
            "msgId": "5dcf84fe1fd8bd85e4ca",
            "note": "",
            "rate": 5,
            "submitDate": "1659750276218",
            "trackingId": ""
        }
    ],
    "Total": 1
}    
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}
{% endtabs %}

**Cấu trúc body response:**

<table><thead><tr><th width="172.59991455078125">Thuốc tính</th><th width="125.7999267578125">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Mã trả về</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi)</td></tr><tr><td>Data</td><td>array</td><td>Chi tiết đánh giá.</td></tr><tr><td>Total</td><td>string</td><td>Tổng số lượt đánh giá.</td></tr></tbody></table>

**Cấu trúc thuộc tính từng object trong Data**

<table><thead><tr><th width="170.4000244140625">Thuốc tính</th><th width="130.199951171875">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>feedbacks</td><td>string</td><td>Tổng số tin được gửi trong ngày.</td></tr><tr><td>msgId</td><td>string</td><td>SmsId của zalo.</td></tr><tr><td>note</td><td>string</td><td>Ghi chút của khách hàng cho đánh giá.</td></tr><tr><td>rate</td><td>string</td><td>Số sao khách hàng đánh giá.</td></tr><tr><td>submitDate</td><td>string</td><td>submitDate: Thời điểm khách hàng submit đánh giá. Biến submitDate sẽ có giá trị trong khoảng thời gian từ from_time đến to_time (được truyền vào từ request). <br><strong>Lưu ý: Tính theo timestamp (millisecond).</strong></td></tr><tr><td>trackingId</td><td>string</td><td>Là giá trị của tham số RequestId khách hàng truyền vào khi gửi tin Zalo.</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [**Link code mẫu**](https://samplefordevelopers.esms.vn/#c36498c6-2153-494c-9795-36c85330aa33)**.**


# Hàm kiểm tra chất lượng OA

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> <https://rest.esms.vn/MainService.svc/json/ZNS/GetQuality/><br>

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/ZNS/GetQuality/' \
--header 'Content-Type: application/json' \
--data '{
     "ApiKey": "APIKEYCUABAN",
     "SecretKey": "SECRETKEYCUABAN",
     "OAID": "4097311281936189049"
}'
```

* **Cấu trúc body request:**

<table><thead><tr><th width="142">Tham số</th><th width="133">Kiểu dữ liệu</th><th width="148" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>SecretKey của tài khoản.</td></tr><tr><td>OAID</td><td>string</td><td>true</td><td>Zalo OA ID, là ID của trang Zalo Offical Account của doanh nghiệp. <br>Doanh nghiệp cần đăng nhập vào trang quản trị của Zalo OA để lấy phần Zalo OA ID này.<br><strong>Chú ý: sẽ phải đăng ký trước khi sử dụng.</strong></td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "ErrorMessage": "success",
    "Oa7dayQuality": "HIGH",
    "OaCurrentQuality": "MEDIUM"
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}
{% endtabs %}

**Cấu trúc body của response:**

<table><thead><tr><th width="183">Thuốc tính</th><th width="159">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Mã trả về.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi).</td></tr><tr><td>Oa7dayQuality</td><td>string</td><td><p>Chất lượng gửi thông báo ZNS trong 7 ngày gần nhất của OA. Các giá trị trả về:</p><p></p><ul><li>HIGH - Mức độ chất lượng tốt.</li><li>MEDIUM - Mức độ chất lượng trung bình.</li><li>LOW - Mức độ chất lượng kém.</li><li>UNDEFINED - Mức độ chất lượng OA chưa được xác định (trường hợp OA không gửi thông báo ZNS nào trong khung thời gian đánh giá).</li></ul></td></tr><tr><td>OaCurrentQuality</td><td>string</td><td><p>Chất lượng gửi thông báo ZNS trong 48 giờ gần nhất của OA. Các giá trị trả về:</p><ul><li>HIGH - Mức độ chất lượng tốt .</li><li>MEDIUM - Mức độ chất lượng trung bình .</li><li>LOW - Mức độ chất lượng kém .</li><li>UNDEFINED - Mức độ chất lượng OA chưa được xác định (trường hợp OA không gửi thông báo ZNS nào trong khung thời gian đánh giá).</li></ul></td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu của các ngôn ngữ ở link:**</mark>* [**Code mẫu**](https://samplefordevelopers.esms.vn/#b03f9576-0e10-4061-bdd0-4cecc82ef6c5) **.**


# Hàm lấy danh sách Zalo Followers

## HTTP request&#x20;

\ <mark style="color:yellow;">**`POST`**</mark> <https://rest.esms.vn/MainService.svc/json/ZNS/GetFollowers/><br>

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/ZNS/GetFollowers/' \
--header 'Content-Type: application/json' \
--data '{
 "ApiKey":"{{ApiKey}}",
 "SecretKey":"{{SecretKey}}",
 "OAID":"{{OAID}}",
 "Offset": {{Offset}},
 "Count": {{Count}}
}'
```

* **Cấu trúc body của request:**

<table><thead><tr><th width="143">Tham số</th><th width="129">Kiểu dữ liệu</th><th width="152" data-type="checkbox">Tính băt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>SecretKey của tài khoản.</td></tr><tr><td>OAID</td><td>string</td><td>true</td><td>Zalo OA ID, là ID của trang Zalo Offical Account của doanh nghiệp. <br>Doanh nghiệp cần đăng nhập vào trang quản trị của Zalo OA để lấy phần Zalo OA ID này.<br><strong>Chú ý: sẽ phải đăng ký trước khi sử dụng.</strong></td></tr><tr><td>Offset</td><td>string</td><td>true</td><td>Lấy bắt đầu từ đánh giá thứ bao nhiêu.</td></tr><tr><td>Limit</td><td>string</td><td>true</td><td>Số lượng đánh giá cần xem.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "ErrorMessage": "success",
    "Followers": [
        {
            "User_Id": "7800378501923859642"
        },
        {
            "User_Id": "4176617840488517388"
        },
        {a
            "User_Id": "7000997455428487634"
        },
        {
            "User_Id": "5889364632581220929"
        }
    ],
    "Total": 208
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

<table><thead><tr><th width="168">Thuốc tính</th><th width="183">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>Followers</td><td>string</td><td>Danh sách UserId Zalo follow OA.</td></tr><tr><td>Total</td><td>string</td><td>Tổng UserId follow OA.</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [**Link code mẫu**](https://samplefordevelopers.esms.vn/#eff6317f-9595-43ed-9950-102dc8b5c95e)**.**


# Hàm lấy danh sách UID có tương tác theo khoảng thời gian

## HTTP request&#x20;

<mark style="color:yellow;">**`POST`**</mark> [https://rest.esms.vn/MainService.svc/json/QueryListUID/](https://rest.esms.vn/MainService.svc/json/SubServicePreviewJson/)

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/QueryListUID/' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey": "{{ApiKey}}",
    "SecretKey": "{{SecretKey}}",
    "OAID": "4097311281936189049",
    "Offset": 0, 
    "Count": 50, 
    "FromDate": "01/09/2024",
    "ToDate": "13/10/2024",
    "IsFollower": "",
    "TagName": "" 
}'
```

* **Cấu trúc body của request:**

<table><thead><tr><th width="143">Tham số</th><th width="129">Kiểu dữ liệu</th><th width="143" data-type="checkbox">Tính băt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>SecretKey của tài khoản.</td></tr><tr><td>OAID</td><td>string</td><td>true</td><td>Zalo OA ID, là ID của trang Zalo Offical Account của doanh nghiệp. <br>Doanh nghiệp cần đăng nhập vào trang quản trị của Zalo OA để lấy phần Zalo OA ID này.<br><strong>Chú ý: sẽ phải đăng ký trước khi sử dụng.</strong></td></tr><tr><td>Offset</td><td>string</td><td>true</td><td><p>Thứ tự của UID trong danh sách trả về.</p><p><strong>Hỗ trợ tối đa 9.950 (tương ứng 10.000 UID, 50 UID/request)</strong>.</p></td></tr><tr><td>Count</td><td>string</td><td>true</td><td>Số lượng UID cần lấy. <br><strong>Tối đa mỗi lần request là 50 UID.</strong></td></tr><tr><td>FromDate</td><td>string</td><td>true</td><td>Thời gian bắt đầu lấy UID có tương tác.</td></tr><tr><td>ToDate</td><td>string</td><td>true</td><td>Thời gian kết thúc lấy UID có tương tác.</td></tr><tr><td>IsFollower</td><td>string</td><td>false</td><td><p></p><p>Trạng thái quan tâm OA của UID</p><ul><li>1: UID đang quan tâm OA.</li><li>0: UID chưa quan tâm OA.</li><li>Rỗng: lấy tất cả.</li></ul></td></tr><tr><td>TagName</td><td>string</td><td>false</td><td><p>Tên của nhãn được gắn cho UID. <br>Khi bạn sử dụng tham số này, API sẽ trả về danh sách UID theo nhãn tương ứng.</p><p>Lưu ý: Trường hợp không truyền vào TagName, API sẽ trả về toàn bộ UID người dùng.</p></td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "Data": {
        "Count": 50,
        "Offset": 0,
        "Total": 4,
        "Users": [
            "7406454492343693107",
            "7210831021380318952",
            "961919545811768483",
            "6559140676281540092"
        ]
    }
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}

{% tab title="161" %}

```
{
    "CodeResult": "161",
    "ErrorMessage": "FromDate is invalid date format."
}
{
    "CodeResult": "161",
    "ErrorMessage": "ToDate is invalid date format."
}
```

**Sai định dạng ngày.**
{% endtab %}

{% tab title="162" %}

```
{
    "CodeResult": "162",
    "ErrorMessage": "Offset is invalid."
}
{
    "CodeResult": "162",
    "ErrorMessage": "Count is invalid."
}
```

**Thứ tự lấy UID hoặc số lượng UID cần lấy không hợp lệ.**
{% endtab %}
{% endtabs %}

**Cấu trúc body của response:**

<table><thead><tr><th width="165.44439697265625">Thuốc tính</th><th width="145.22216796875">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Mã trả về.</td></tr><tr><td>Data</td><td>object</td><td>Chi tiết thông tin UI.</td></tr></tbody></table>

**Cấu trúc thuộc tính từng object trong Data**

<table><thead><tr><th width="168">Thuốc tính</th><th width="145">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>Count</td><td>string</td><td>Kết quả của request.</td></tr><tr><td>Offset</td><td>string</td><td>Thứ tự UID trong danh sách trả về</td></tr><tr><td>Tatal</td><td>string</td><td>Tổng UID thoả yêu cầu reque</td></tr><tr><td>Users</td><td>array</td><td>Danh sách UID lấy được</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [**Link code mẫu.**](https://samplefordevelopers.esms.vn/#2f26fb8e-2b78-4bbc-89a7-d739a7c32ff7)


# Hàm lấy thông tin callback tin nhắn Zalo

Hàm này chỉ dùng đối với những tin nhắn khi request gửi tin khách hàng có truyền trường CallbackUrl để nhận thông tin trạng thái tin nhắn qua callback.

Những SMSID khi request không truyền CallbackUrl, dùng hàm này sẽ không có thông tin.

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> <https://status-sms.esms.vn/ZaloCallback/GetCallback><br>

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location 'https://status-sms.esms.vn/ZaloCallback/GetCallback' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey":"{{ApiKey}}",
    "SecretKey":"{{SecretKey}}",
    "ListRefid": [
        "{{Refid}}",
        "{{Refid}}",
        "{{Refid}}"
    ],
    "OAId": "{{OAId}}"
}'
```

* **Cấu trúc body của request:**

<table><thead><tr><th width="137">Tham số</th><th width="152">Kiểu dữ liệu</th><th width="160" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>SecretKey của tài khoản.</td></tr><tr><td>ListRefid</td><td>array</td><td>true</td><td>Danh sách ReferenceId đã gửi tin.<br>Giới hạn 200 RefId, truyền nhiều hơn sẽ chỉ lấy callback của 200 RefId theo thứ tự từ trên xuống.</td></tr><tr><td>OAId</td><td>string</td><td>true</td><td>Id của OA đã gửi tin</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "Code": 100,
    "Message": "Success",
    "Data_callback": [
        {
            "SMSID": "4a496110-9fd3-4838-ac8b-bcaa36616f7011",
            "SendFailed": 1,
            "SendSuccess": 0,
            "SendStatus": 5,
            "TotalPrice": 0.0,
            "TotalReceiver": 1,
            "TotalSent": 1,
            "RequestId": null,
            "TypeId": 25,
            "Telcoid": 1,
            "PhoneNumber": "0909090909",
            "CallbackUrl": "https://api.esms.vn/zalo-zns/zns/receive-callback",
            "Partnerids": "7984e9b198c40e9957d6",
            "ErrorInfo": "{\"error\":-124,\"message\":\"Access token is invalid\"}Object reference not set to an instance of an object.",
            "OAId": "1090257973118325189",
            "ZnsTempId": "228386"
        } 
                    ]
  } 
```

**Request hợp lệ.**
{% endtab %}
{% endtabs %}

**Cấu trúc body của response:**

<table><thead><tr><th width="166.333251953125">Thuộc tính</th><th width="156.6666259765625">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>Code</td><td>string</td><td>Mã trả về.</td></tr><tr><td>Message</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi)</td></tr><tr><td>Data_callback</td><td>array</td><td>Data callback chi tiết.</td></tr></tbody></table>

**Cấu trúc thuộc tính từng object trong Data\_callback**

<table><thead><tr><th width="168.33333333333331">Thuộc tính</th><th width="158">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>SMSID</td><td>string</td><td>ReferenceId của tin nhắn muốn xem callback.</td></tr><tr><td>SendFailed</td><td>string</td><td>Tổng số tin thất bại.</td></tr><tr><td>SendSuccess</td><td>string</td><td>Tổng số tin thành công.</td></tr><tr><td>SendStatus</td><td>string</td><td>Trạng thái tin nhắn.</td></tr><tr><td></td><td></td><td><ul><li>Trạng thái 2: Chờ gửi .</li><li>Trạng thái 5: Đã gửi .</li></ul></td></tr><tr><td>TotalPrice</td><td>string</td><td>Tổng số tiền của tin.</td></tr><tr><td>TotalReceiver</td><td>string</td><td>Tổng số tin.</td></tr><tr><td>TotalSent</td><td>string</td><td>Tổng số tin đã gửi.</td></tr><tr><td>RequestId</td><td>string</td><td>Request mà KH truyền vào API để gửi tin.</td></tr><tr><td>TypeId</td><td>string</td><td><p>Loại tin nhắn.</p><ul><li>Type 24: Zalo Ưu Tiên.</li><li>Type 25: Zalo Bình Thường.</li></ul></td></tr><tr><td>Telcoid</td><td>string</td><td><p>Mạng viễn thông của thuê bao nhận tin.</p><ul><li>Mạng số 1: Viettel</li><li>Mạng số 2: Mobifone</li><li>Mạng số 3: Vinaphone</li><li>Mạng số 4: Vietnammobile</li><li>Mạng số 5: Gmobile</li><li>Mạng số 6: Itel</li><li>Mạng số 7: Reddi</li></ul></td></tr><tr><td>PhoneNumber</td><td>string</td><td>Số điện thoại nhận tin.</td></tr><tr><td>CallbackUrl</td><td>string</td><td>Link nhận callback .</td></tr><tr><td>Partnerids</td><td>string</td><td>Mã của tin nhắn vừa được gửi (do Zalo trả về).</td></tr><tr><td>ErrorInfo</td><td>string</td><td>Mã lỗi và thông tin lỗi của tin nhắn.</td></tr><tr><td>OAId</td><td>string</td><td>Id của OA mà KH gửi tin.</td></tr><tr><td>ZnsTempId</td><td>string</td><td>Id của template KH gửi tin.</td></tr></tbody></table>

{% hint style="warning" %}
Chú ý:

* Số ReferenceId tối đa cho 1 lần request là 200, nhiều hơn 200 sẽ chỉ trả 200 ReferenceId đầu tiên.

* Giới hạn request 20TPS.
  {% endhint %}

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**

* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [<mark style="color:blue;">**Link code mẫu**</mark>](https://samplefordevelopers.esms.vn/#eb870a67-0f33-444d-85e5-bbabf920299d)**.**


# Hàm lấy thông tin chi tiết template Zalo

## HTTP request

\ <mark style="color:green;">**`GET`**</mark> <https://rest.esms.vn/MainService.svc/json/GetZnsTemplateInfo?TemplateId={{TemplateId}}&ApiKey={{ApiKey}}&SecretKey={{SecretKey}}&OAId={{OAId}}>

* **Response Type:** <mark style="color:orange;">application/json</mark>

{% code overflow="wrap" %}

```json
curl --location -g 'https://rest.esms.vn/MainService.svc/json/GetZnsTemplateInfo?TemplateId={{TemplateId}}&ApiKey={{ApiKey}}&SecretKey={{SecretKey}}&OAId={{OAId}}'
```

{% endcode %}

* **Cấu trúc body của request:**

<table><thead><tr><th width="136">Tham số</th><th width="136">Kiểu dữ liệu</th><th width="150" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>TemplateId</td><td>string</td><td>true</td><td>Template của Zalo OA mà khách hàng đăng kí với eSMS.</td></tr><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>SecretKey của tài khoản</td></tr><tr><td>OAId</td><td>string</td><td>true</td><td>Zalo OA ID, là ID của trang Zalo Offical Account của doanh nghiệp. <br>Doanh nghiệp cần đăng nhập vào trang quản trị của Zalo OA để lấy phần Zalo OA ID này.<br><strong>Chú ý: sẽ phải đăng ký trước khi sử dụng.</strong></td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```
{
    "Data": {
        "ListButtons": [
            {
                "Content": "https://oa.zalo.me/4097311281936189049",
                "Title": "Quan tâm OA",
                "Type": 2
            }
        ],
        "ListParams": [
            {
                "AcceptNull": false,
                "MaxLength": 100,
                "MinLength": 0,
                "Name": "customer_name",
                "Require": true,
                "Type": "STRING"
            },
            {
                "AcceptNull": false,
                "MaxLength": 100,
                "MinLength": 0,
                "Name": "product_name",
                "Require": true,
                "Type": "STRING"
            },
            {
                "AcceptNull": false,
                "MaxLength": 30,
                "MinLength": 0,
                "Name": "order_code",
                "Require": true,
                "Type": "STRING"
            },
            {
                "AcceptNull": false,
                "MaxLength": 30,
                "MinLength": 0,
                "Name": "date",
                "Require": true,
                "Type": "STRING"
            }
        ],
        "PreviewUrl": "https://account.zalo.cloud/znspreview/NqFkYJ14yilzdlAXteG_rQ==",
        "Reason": "Template đã được duyệt",
        "Status": "ENABLE",
        "TemplateId": 267247,
        "TemplateName": "Đánh giá dịch vụ - text",
        "TemplateQuality": "null",
        "TemplateTag": "TRANSACTION",
        "Timeout": 7200000
    },
    "Error": 0,
    "Message": "Success"
}
```

**Request lợp lệ.**
{% endtab %}
{% endtabs %}

**Cấu trúc body của response:**

<table><thead><tr><th width="161.888916015625">Thuộc tính</th><th width="164.1109619140625">Kiểu dữ liệu</th><th>Định nghĩa</th></tr></thead><tbody><tr><td>Data</td><td>object</td><td>Thông tin chi tiết template.</td></tr><tr><td>Error</td><td>string</td><td>Mã trả về.</td></tr><tr><td>Message</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi).</td></tr></tbody></table>

**Cấu trúc thuộc tính từng object trong Data**

<table><thead><tr><th width="171">Thuộc tính</th><th width="165">Kiểu dữ liệu</th><th>Định nghĩa</th></tr></thead><tbody><tr><td>PreviewUrl</td><td>string</td><td>Đường dẫn đến bản xem trước của template.</td></tr><tr><td>Reason</td><td>string</td><td>Lý do template có trạng thái hiện tại:<br><br>- DISABLE/REJECT: Chi tiết lý do khi template ở trạng thái Disable hoặc Reject.<br>- ENABLE: Template đã được duyệt.<br>- DELETE: Template đã bị xóa.<br>- PENDING_REVIEW: Template đang được kiểm duyệt.<br></td></tr><tr><td>Status</td><td>string</td><td>Trạng thái template. Các trạng thái bao gồm: <br><br>- ENABLE: Trạng thái template được kích hoạt, có thể sử dụng để gửi thông báo ZNS.<br>- PENDING_REVIEW: Trạng thái template chờ kiểm duyệt. <br>- DELETE: Trạng thái template bị xóa. <br>- REJECT: Trạng thái template bị từ chối. <br>- DISABLE: Trạng thái template bị hủy kích hoạt.</td></tr><tr><td>TemplateId</td><td>string</td><td>ID của template.</td></tr><tr><td>TemplateName</td><td>string</td><td>Tên của template.</td></tr><tr><td>TemplateQuality</td><td>string</td><td>Trả về giá trị null cho trường thông tin này.</td></tr><tr><td>TemplateTag</td><td>string</td><td>Loại nội dung của template. Các giá trị trả về: <br><br>- TRANSACTION: Giao dịch <br>- CUSTOMER_CARE: Chăm sóc khách hàng <br>- PROMOTION: Hậu mãi</td></tr><tr><td>Timeout</td><td>long</td><td>Thời gian timeout của template.</td></tr><tr><td>ListButtons</td><td>array</td><td>Danh sách các buttons/CTAs của template <br>Chỉ áp dụng với 2 loại CTA: primary và secondary. <br>Không hiển thị các CTA từ image module và response button.</td></tr><tr><td>ListParams</td><td>array</td><td>Danh sách các thuộc tính của template.</td></tr></tbody></table>

**Cấu trúc thuộc tính từng object trong ListButtons**

<table><thead><tr><th width="168.11102294921875">Thuộc tính</th><th width="169">Kiểu dữ liệu</th><th>Định nghĩa</th></tr></thead><tbody><tr><td>Content</td><td>string</td><td>Đường dẫn liên kết/số điện thoại.</td></tr><tr><td>Title</td><td>string</td><td>Nội dung Button.</td></tr><tr><td>Type</td><td>integer</td><td><p>Danh sách button:</p><p>1: Đến trang của doanh nghiệp<br>2: Gọi điện <br>3: Đến trang thông tin OA <br>4: Đến ứng dụng Zalo Mini App của doanh nghiệp <br>5: Đến trang tải ứng dụng <br>6: Đến trang phân phối sản phẩm <br>7: Đến trang web/Zalo Mini App khác <br>8: Đến ứng dụng khác</p></td></tr></tbody></table>

**Cấu trúc thuộc tính từng object trong ListParams**

<table><thead><tr><th width="165.44439697265625">Thuộc tính</th><th width="176.333251953125">Kiểu dữ liệu</th><th>Định nghĩa</th></tr></thead><tbody><tr><td>Name</td><td>string</td><td>Tên thuộc tính.</td></tr><tr><td>Require</td><td>boolean</td><td>Tính bắt buộc của thuộc tính.</td></tr><tr><td>Type</td><td>string</td><td>Định dạng validate của thuộc tính.</td></tr><tr><td>MaxLength</td><td>integer</td><td>Số kí tự tối đa được truyền vào thuộc tính.</td></tr><tr><td>MinLength</td><td>integer</td><td>Số kí tự tối thiểu được truyền vào thuộc tính.</td></tr><tr><td>AcceptNull</td><td>boolean</td><td>Thông tin cho biết thuộc tính có thể nhận giá trị rỗng hay không.</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [**Link code mẫu**](https://samplefordevelopers.esms.vn/#43e884e9-36a4-4272-94bd-c388551e7c60)**.**


# Hàm đăng ký mua gói OA

Đây là hàm dùng để đăng ký mua gói OA

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> <https://rest.esms.vn/MainService.svc/json/RegisOAPackageJson/><br>

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/RegisOAPackageJson/' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey":"{{ApiKey}}",
    "SecretKey":"{{SecretKey}}",
    "Dateactive":"{{Dateactive}}",
    "Duaration":"{{Duaration}}",
    "OAID":"{{OAID}}",
    "Package":{{Package}}
}'
```

* **Cấu trúc body của request:**

<table><thead><tr><th width="157">Tham số </th><th width="129">Kiểu dữ liệu </th><th width="154" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>SecretKey của tài khoản.</td></tr><tr><td>Dateactive</td><td>string</td><td>true</td><td><p>Ngày kích hoạt OA:</p><p>Định dạng yyyy- mm - dd</p></td></tr><tr><td>Duaration</td><td>string</td><td>true</td><td>Thời gian gia hạn gói OA.</td></tr><tr><td>OAID</td><td>string</td><td>true</td><td>Zalo OA ID, là ID của trang Zalo Offical Account của doanh nghiệp. Doanh nghiệp cần đăng nhập vào trang quản trị của Zalo OA để lấy phần Zalo OA ID này. <br><strong>Chú ý: sẽ phải đăng ký trước khi sử dụng.</strong></td></tr><tr><td>Package</td><td>string</td><td>true</td><td>Gói OA<br>- 1: Gói dùng thử<br>- 2: Gói nâng cao<br>- 3: Gói premium</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```
{
    "CodeResult": "100",
    "ErrorMessage": "ViHAT is censoring trademark ownership",
    "ServicePreviewId": 52330
}
```

**Request hợp lệ.**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

<table><thead><tr><th>Thuộc tính</th><th width="194">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Kết quả của Request.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông báo kết quả trả về.</td></tr><tr><td>ServicepreviewId</td><td>string</td><td>ID đăng ký OA phía eSMS.</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [**Link code mẫu**](https://samplefordevelopers.esms.vn/#f6fc7a5b-a326-4e4b-b7b1-0023151354f0)**.**


# Hàm đăng ký template Zalo

Đây là hàm dùng để đăng ký template ZNS

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> <https://rest.esms.vn/MainService.svc/json/RegisZNSTemplateJson/><br>

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/RegisZNSTemplateJson/' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey":"{{ApiKey}}",
    "SecretKey":"{{SecretKey}}",
    "Content":"{{Content}}",
    "ImageUrl":"{{ImageUrl}}",
    "CTA1":"{{CTA1}}",
    "CTA2":"{{CTA2}}",
    "OAID":"{{OAID}}",
    "SmsType":"{{SmsType}}",
    "CallbackUrl":"{{CallbackUrl}}"
}'
```

* **Cấu trúc body của request:**

<table><thead><tr><th width="163">Tham số</th><th width="130">Kiểu dữ liệu </th><th width="148" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>SecretKey của tài khoản.</td></tr><tr><td>Content</td><td>string</td><td>true</td><td>Nội dung mẫu của template cần đăng ký.</td></tr><tr><td>ImageURL</td><td>string</td><td>true</td><td>Link hình ảnh LOGO OA, chấp nhận link đuôi PNG, kích thước 400x69, tách nền màu nền đen hoặc trắng.</td></tr><tr><td>CTA 1</td><td>string</td><td>false</td><td>Link CTA thứ nhất.</td></tr><tr><td>CTA 2</td><td>string</td><td>false</td><td>Link CTA thứ hai.</td></tr><tr><td>OAID</td><td>string</td><td>true</td><td>Zalo OA ID, là ID của trang Zalo Offical Account của doanh nghiệp. Doanh nghiệp cần đăng nhập vào trang quản trị của Zalo OA để lấy phần Zalo OA ID này. <br><strong>Chú ý: sẽ phải đăng ký trước khi sử dụng.</strong></td></tr><tr><td>SmsType</td><td>string</td><td>true</td><td>24: khi đăng ký template zalo ưu tiên.<br>25: khi đăng ký template zalo bình thường.</td></tr><tr><td>CallbackUrl</td><td>string</td><td>false</td><td>Link nhận trạng thái template đăng ký<br>0: Đăng ký thất bại.<br>1: eSMS tiếp nhận thành công.<br>2: Đăng ký thành công.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```
{
    "CodeResult": "100",
    "ErrorMessage": "ViHAT is censoring trademark ownership",
    "ServicePreviewId": 52330
}
```

**Request hợp lệ.**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

<table><thead><tr><th width="205">Thuốc tính</th><th width="160">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Kết quả của Request.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông báo kết quả trả về.</td></tr><tr><td>ServicepreviewId</td><td>string</td><td>ID template yêu cầu đăng ký.</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [**Link code mẫu**](https://samplefordevelopers.esms.vn/#f25701ff-8ce7-4c5d-bca6-c7eafd158977)**.**


# Hàm đăng ký template SMS

Đây là hàm dùng để đăng ký template SMS chăm sóc khách hàng.

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> <https://rest.esms.vn/MainService.svc/json/SubServicePreviewJson/><br>

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/SubServicePreviewJson/' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey": "{{ApiKey}}",
    "AssetsUrl": "{{AssetsUrl}}",
    "Brandname": "{{Brandname}}",
    "CallbackUrl": "{{CallbackUrl}}",
    "Content": "{{Content}}",
    "IsUnicode": "{{IsUnicode}}",
    "CustomerEmail": "{{CustomerEmail}}",
    "CustomerName": "{{CustomerName}}",
    "CustomerPhone": "{{CustomerPhone}}",
    "SecretKey": "{{SecretKey}}",
    "ServiceType": 2,
    "SmsType": {{SmsType}}
}'
```

* **Cấu trúc body của request:**

<table><thead><tr><th width="167">Tham số</th><th width="126">Kiểu dữ liệu </th><th width="134" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>SecretKey của tài khoản.</td></tr><tr><td>Content</td><td>string</td><td>true</td><td>Nội dung mẫu của template cần đăng ký<br>Ví dụ: {<strong>Biến</strong>:<strong>Số lượng ký tự mong muốn</strong>}</td></tr><tr><td>AssetsUrl</td><td>string</td><td>false</td><td>Là đường dẫn để tài 1 tài liệu nào đó ở server của đối tác. tài liệu này phục vụ cho việc xác thực đăng ký.</td></tr><tr><td>Brandname</td><td>string</td><td>true</td><td>BrandName cần đăng ký template (lưu ý: Brandname này phải được add vào tài khoản thì mới đăng ký được)</td></tr><tr><td>IsUnicode</td><td>string</td><td>false</td><td>Đăng ký nội dung có dấu<br>1: Có dấu<br>0: Không dấu</td></tr><tr><td>CustomerEmail</td><td>string</td><td>false</td><td>Email tài khoản KH cuối cần đăng ký brandname.</td></tr><tr><td>CustomerName</td><td>string</td><td>false</td><td>Số điện thoại KH cuối cần Đăng ký brandname.</td></tr><tr><td>CustomerPhone</td><td>string</td><td>false</td><td>CustomerPhone.</td></tr><tr><td>ServiceType</td><td>string</td><td>true</td><td>ServiceType = 2 là đăng ký Template CSKH hoặc Cố định giá rẻ.</td></tr><tr><td>SmsType</td><td>string</td><td>true</td><td>2: khi đăng ký template CSKH .<br>8: khi đăng ký template Cố định giá rẻ.</td></tr><tr><td>CallbackUrl</td><td>string</td><td>false</td><td>Sẽ nhận kết quả trả về của eSMS sau khi yêu cầu đăng ký template. <br>0: Đăng ký thất bại.<br>1: eSMS tiếp nhận thành công.<br>2: Đăng ký thành công.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "ErrorMessage": "ViHAT is moderating your template",
    "ServicePreviewId": 52353
}
```

**Request hợp lệ.**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

<table><thead><tr><th width="204">Thuốc tính</th><th width="166">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Kết quả của Request.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông báo kết quả trả về.</td></tr><tr><td>ServicepreviewId</td><td>string</td><td>ID template yêu cầu đăng ký.</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [**Link code mẫu**](https://samplefordevelopers.esms.vn/#12f5e80f-025c-4c9c-9c9c-b42622ea8af2)**.**


# Hàm lấy thông tin trạng thái ZNS

Đây là hàm dùng để truy xuất trạng thái của thông báo ZNS.

{% hint style="warning" %}
**Lưu ý:** Giới hạn tốc độ gọi api này là 30 requests/giây.
{% endhint %}

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> <http://rest.esms.vn/MainService.svc/json/GetZaloMessageStatus><br>

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location 'http://rest.esms.vn/MainService.svc/json/GetZaloMessageStatus' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey": "{{ApiKey}}",
    "SecretKey": "{{SecretKey}}",
    "OAID": "{{OAID}}",
    "MessageId": "{{MessageId}}"
}'
```

* **Cấu trúc body của request:**

<table><thead><tr><th width="167">Tham số</th><th width="126">Kiểu dữ liệu </th><th width="134" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>SecretKey của tài khoản.</td></tr><tr><td>OAID</td><td>string</td><td>true</td><td>Zalo OA ID, là ID của trang Zalo Offical Account của doanh nghiệp.<br>Doanh nghiệp cần đăng nhập vào trang quản trị của Zalo OA để lấy phần Zalo OA ID này.<br><strong>Chú ý: sẽ phải đăng ký trước khi sử dụng.</strong></td></tr><tr><td>MessageId</td><td>string</td><td>true</td><td>ID của thông báo cần lấy thông tin trạng thái ZNS (chính là Partnerids được trả về trong <a href="/pages/5lATRN4OFRbxEy0EkgOD">hàm lấy thông tin  callback tin nhắn zalo</a>)</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "Data": {
        "delivery_time": "1767678030984",
        "message": "The message was delivered to the user's phone",
        "status": 1
    },
    "ErrorMessage": "success. "
}
```

**Request hợp lệ.**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

<table><thead><tr><th width="204">Thuộc tính</th><th width="166">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Kết quả của Request.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông báo kết quả trả về.</td></tr><tr><td>Data</td><td>string</td><td>Thông tin trạng thái của thông báo ZNS .</td></tr></tbody></table>

* **Cấu trúc thuộc tính từng object trong Data:**

<table><thead><tr><th width="174">Thuộc tính</th><th width="171">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>delivery_time</td><td>string</td><td>Thời gian thiết bị của người dùng nhận được thông báo ZNS.</td></tr><tr><td>message</td><td>string</td><td>Mô tả trạng thái thông báo. Các giá trị trả về:<br>-1: Tin nhắn không tồn tại<br>0: Tin nhắn đã được gửi lên máy chủ Zalo nhưng chưa được chuyển đến điện thoại của người dùng<br>1: Tin nhắn đã được chuyển đến điện thoại của người dùng</td></tr><tr><td>status</td><td>int</td><td>Trạng thái của thông báo ZNS.</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [**Link code mẫu**](https://samplefordevelopers.esms.vn/#cab8ca81-d83a-46e5-ab19-b58f29a6f656)**.**


# Hàm kiểm tra trạng thái tin nhắn Zalo

API kiểm tra trạng thái tin nhắn Zalo, bao gồm thông tin kết quả gửi và mã lỗi của tin nhắn.

{% hint style="warning" %}
**Lưu ý:** Giới hạn tốc độ gọi api này là 100 requests/giây.
{% endhint %}

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> <https://rest.esms.vn/MainService.svc/json/QueryZnsStatus/><br>

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/QueryZnsStatus/' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey": "{{ApiKey}}",
    "SecretKey": "{{SecretKey}}",
    "SmsId": "2d00b834cc1d488081ba7ec308da0ec40918238965",
    "SmsType": "25"
}'
```

* **Cấu trúc body của request:**

<table><thead><tr><th width="167">Tham số</th><th width="126">Kiểu dữ liệu </th><th width="134" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>SecretKey của tài khoản.</td></tr><tr><td>SmsId</td><td>string</td><td>true</td><td>SmsId hệ thống trả về từ mỗi hàm gửi tin nhắn.</td></tr><tr><td>SmsType</td><td>string</td><td>true</td><td>Loại tin nhắn. Api này chỉ cho phép lấy trạng thái của hai loại sau:<br>24: Zalo ưu tiên<br>25: Zalo bình thường</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "Data": {
        "ErrorInfo": "0",
        "FinalStatus": "1",
        "SMSID": "59e0c764219c49119063db4468f257fb221",
        "SendFailed": 0,
        "SendStatus": 5,
        "SendSuccess": 1,
        "TotalPrice": 330.0,
        "TotalReceiver": 1,
        "TotalSent": 1,
        "ZaloMsgId": "6dc7499c9ef6baaee3e1"
    }
}
```

**Request hợp lệ.**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

<table><thead><tr><th width="140.8887939453125">Thuộc tính</th><th width="125.111083984375">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Kết quả của Request.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông báo kết quả trả về.</td></tr><tr><td>Data</td><td>object</td><td>Thông tin trạng thái của tin nhắn Zalo .</td></tr></tbody></table>

* **Cấu trúc thuộc tính từng object trong Data:**

<table><thead><tr><th width="174">Thuộc tính</th><th width="128.333251953125">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>ErrorInfo</td><td>string</td><td><p>Mã kết quả xử lý gửi tin nhắn.</p><p>Giá trị trả về:</p><ul><li>0: Tin nhắn gửi thành công.</li><li>1001: Tin nhắn trả trạng thái thất bại do khách hàng không online để nhận tin  trong thời gian quy định.</li><li>null: Tin nhắn chưa được gửi.</li><li>Các giá trị khác: Mã lỗi do hệ thống Zalo trả về. Vui lòng tham khảo <a href="https://developers.zalo.me/docs/zbs-template-message/bang-ma-loi/"><strong>bảng mã lỗi Zalo</strong></a> tại link đính kèm để tra cứu ý nghĩa chi tiết.</li></ul></td></tr><tr><td>FinalStatus</td><td>string</td><td><p>Mô tả trạng thái tin nhắn đã có kết quả cuối cùng hay chưa. </p><p>Các giá trị trả về:<br>1: Đã có trạng thái cuối<br>0: Chưa có trạng thái cuối</p></td></tr><tr><td>SMSID</td><td>string</td><td>SmsId của tin nhắn cần kiểm tra.</td></tr><tr><td>SendFailed</td><td>int</td><td>Số lượng tin thất bại.</td></tr><tr><td>SendStatus</td><td>int</td><td>Trạng thái tin nhắn<br>1: Chờ Duyệt<br>2: Chờ gửi.<br>5: Đã gửi xong.</td></tr><tr><td>SendSuccess</td><td>int</td><td>Số lượng tin thành công.</td></tr><tr><td>TotalPrice</td><td>decimal</td><td>Tổng tiền của đơn.</td></tr><tr><td>TotalReceiver</td><td>int</td><td>Số lượng người nhận.</td></tr><tr><td>TotalSent</td><td>int</td><td>Số lượng gửi.</td></tr><tr><td>ZaloMsgId</td><td>string</td><td>Mã giao dịch của Zalo.</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [**Link code mẫu**](https://samplefordevelopers.esms.vn/#dfb2453d-0f9e-43ec-b7ac-260af32cbac3)**.**


# Các API khác


# Gửi tin chăm sóc khách hàng dạng GET

## HTTP request

\ <mark style="color:green;">**`GET`**</mark> <mark style="color:blue;"><https://rest.esms.vn/MainService.svc/json/SendMultipleMessage\\_V4\\_get?Phone=\\{{Phone\\}}\\&Content=\\{{Content\\}}\\&ApiKey=\\{{ApiKey\\}}\\&SecretKey=\\{{SecretKey\\}}\\&IsUnicode=\\{{IsUnicode\\}}\\&Brandname=\\{{Brandname\\}}\\&SmsType=2\\&CallbackUrl=\\{{CallbackUrl\\}}\\&RequestId=\\{{RequestId\\}}\\&SendDate=\\{{yyyy-mm-dd> HH:mm:hh}}\&SandBox={{SandBox}}</mark>

* **Response Type:** <mark style="color:orange;">application/json</mark>

```
curl --location -g 'https://rest.esms.vn/MainService.svc/json/SendMultipleMessage_V4_get?Phone={{Phone}}&Content={{Content}}&ApiKey={{ApiKey}}&SecretKey={{SecretKey}}&IsUnicode={{IsUnicode}}&Brandname={{Brandname}}&SmsType=2&CallbackUrl={{CallbackUrl}}&RequestId={{RequestId}}&SendDate={{yyyy-mm-dd%20HH%3Amm%3Ahh}}'
```

* **Cấu trúc body request:**

<table><thead><tr><th width="156">Tham số</th><th width="155">Kiểu dữ liệu </th><th width="145" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>Phone</td><td>string</td><td>true</td><td>Số điện thoại nhận tin.</td></tr><tr><td>Content</td><td>string</td><td>true</td><td>Nội dung tin nhắn.</td></tr><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Secretkey của tài khoản.</td></tr><tr><td>Unicode</td><td>string</td><td>false</td><td>Gửi nội dung có dấu<br>1: Có dấu.<br>0: Không dấu.</td></tr><tr><td>Brandname</td><td>string</td><td>true</td><td>Tên Brandname (tên công ty hay tổ chức khi gửi tin sẽ hiển thị trên tin nhắn đó). <br><strong>Chú ý: sẽ phải đăng ký trước khi sử dụng.</strong></td></tr><tr><td>SmsType</td><td>number</td><td>true</td><td>Loại tin nhắn<br>2: Tin CSKH.</td></tr><tr><td>CallbackUrl</td><td>string</td><td>false</td><td>URL nhận kết quả gửi tin. <br>Xem body mẫu <a href="https://samplefordevelopers.esms.vn/#20f85e1f-3d9e-4ff4-bc4f-8d9c9edbc88a">ở đây</a>. <br>Xem chi tiết <a href="/pages/HxTrJlnDLexPUwac9BWb">ở đây</a>.</td></tr><tr><td>RequestId</td><td>string</td><td>false</td><td>D đối tác truyền sang để chặn trùng và đối soát khi cần.<br>Độ dài tối đa 50 ký tự.<br><strong>Mỗi RequestId truyền sang có hiệu lực chặn trong 24h.</strong></td></tr><tr><td>SendDate</td><td>string</td><td>false</td><td>Thời gian hẹn gửi của tin. <br>Không truyền khi tin muốn tin nhắn gửi đi liền.<br>Định dạng: yyyy-mm-dd hh:MM:ss</td></tr><tr><td>SandBox</td><td>string</td><td>false</td><td>1: Tin gửi ở môi trường test, dùng để kiểm tra kết nối và các thông số tích hợp, không về tin nhắn, không trừ tiền.<br>0: Tin gửi ở môi trường bình thường, có về tin nhắn.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "ebe101db-87cd-4285-b97b-6a7a90455ded30"
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}

{% tab title="104" %}

```json
{
    "CodeResult": "104",
    "CountRegenerate": 0,
    "ErrorMessage": "Brand name code is not exist"
}
```

**Brandname truyền chưa đúng hoặc chưa được active.**
{% endtab %}

{% tab title="124" %}

```json
{
    "CodeResult": "124",
    "CountRegenerate": 0,
    "ErrorMessage": "Request exist 1"
}
```

**Trùng RequestId. Mỗi RequestId chỉ được gửi cho 1 request.**
{% endtab %}

{% tab title="99" %}

```json
{
  "error": "Invalid request"
}
```

**Kiểm tra lại thông tin kết nối hoặc liên hệ bộ phận chăm sóc khách hàng để được hỗ trợ khi gặp lỗi này.**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

<table><thead><tr><th width="153.33331298828125">Thuộc tính</th><th width="133">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Request được gửi đến ESMS thành công.<br><br><strong>Lưu ý:</strong> Mã phản hồi <strong>100</strong> chỉ xác nhận rằng yêu cầu đã được gửi thành công đến hệ thống ESMS, <strong>không phản ánh việc tin nhắn đã được gửi đến số điện thoại người nhận hay chưa</strong>.<br>Để theo dõi trạng thái cuối cùng của tin nhắn, quý khách vui lòng truyền thêm tham số <strong>CallbackUrl</strong>; hệ thống ESMS sẽ tự động gửi phản hồi (callback) đến địa chỉ này khi có trạng thái cuối của tin.</td></tr><tr><td>SMSID</td><td>string</td><td>ID tin nhắn do esms trả về.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi).</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [**Link code mẫu**](https://samplefordevelopers.esms.vn/#df0d691e-6423-490b-b75e-d9df2d961615)**.**


# Gửi tin chăm sóc khách hàng dạng POST X-Form

## HTTP request

\ <mark style="color:yellow;">**POST**</mark> <https://rest.esms.vn/MainService.svc/json/SendMultipleMessage_V4_post/>

* **Content Type:** <mark style="color:orange;">application/x-www-form-urlencoded</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```
curl --location 'https://rest.esms.vn/MainService.svc/json/SendMultipleMessage_V4_post/' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'Phone={{Phone}}' \
--data-urlencode 'Content={{Content}}' \
--data-urlencode 'Apikey={{ApiKey}}' \
--data-urlencode 'SecretKey={{SecretKey}}' \
--data-urlencode 'SmsType=2' \
--data-urlencode 'Brandname={{Brandname}}'
```

* **Cấu trúc body của request:**

<table><thead><tr><th width="165">Tham số</th><th width="158">Kiểu dữ liệu </th><th width="137" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>Phone</td><td>string</td><td>true</td><td>Số điện thoại nhận tin.</td></tr><tr><td>Content</td><td>string</td><td>true</td><td>Nội dung tin nhắn.</td></tr><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Secretkey của tài khoản.</td></tr><tr><td>SmsType</td><td>number</td><td>true</td><td>Loại tin nhắn<br>2: Tin CSKH.</td></tr><tr><td>Brandname</td><td>string</td><td>true</td><td>Tên Brandname (tên công ty hay tổ chức khi gửi tin sẽ hiển thị trên tin nhắn đó). <br><strong>Chú ý: sẽ phải đăng ký trước khi sử dụng.</strong></td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d533459ee42b2b9525ba9eabf6a8156"
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}

{% tab title="104" %}

```json
{
    "CodeResult": "104",
    "CountRegenerate": 0,
    "ErrorMessage": "Brand name code is not exist"
}
```

**Brandname truyền chưa đúng hoặc chưa được active.**
{% endtab %}

{% tab title="Untitled" %}

```json
{
  "error": "Invalid request"
}
```

**Kiểm tra lại thông tin kết nối hoặc liên hệ bộ phận chăm sóc khách hàng để được hỗ trợ khi gặp lỗi này.**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

<table><thead><tr><th width="154.800048828125">Thuộc tính</th><th width="130.933349609375">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Request được gửi đến ESMS thành công.<br><br><strong>Lưu ý:</strong> Mã phản hồi <strong>100</strong> chỉ xác nhận rằng yêu cầu đã được gửi thành công đến hệ thống ESMS, <strong>không phản ánh việc tin nhắn đã được gửi đến số điện thoại người nhận hay chưa</strong>.<br>Để theo dõi trạng thái cuối cùng của tin nhắn, quý khách vui lòng truyền thêm tham số <strong>CallbackUrl</strong>; hệ thống ESMS sẽ tự động gửi phản hồi (callback) đến địa chỉ này khi có trạng thái cuối của tin.</td></tr><tr><td>SMSID</td><td>string</td><td>ID tin nhắn do esms trả về.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi).</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [**Link code mẫu**](https://samplefordevelopers.esms.vn/#850974b9-12cf-46f5-946c-e8e15aa3585b)**.**


# Gửi tin chăm sóc khách hàng dạng POST TEXT

API dùng để gửi tin Quảng cáo đến khách hàng. Mỗi request tối thiểu 30 số để được duyệt tin và tối đa 5000 số.

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> <https://rest.esms.vn/MainService.svc/json/SendMultipleMessage_V4>

* **Content Type:** <mark style="color:orange;">application/text/plain</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```
curl --location 'https://rest.esms.vn/MainService.svc/json/SendMultipleMessage_V4/' \
--header 'Content-Type: text/plain' \
--data '<RQST>
<APIKEY>{{ApiKey}}</APIKEY>
<SECRETKEY>{{SecretKey}}</SECRETKEY>
<CONTENT>{{Content}}</CONTENT>
<SMSTYPE>2</SMSTYPE>
<BRANDNAME>{{Brandname}}</BRANDNAME>
<SENDDATE>{{senddate}}</SENDDATE>
<CALLBACKURL>{{callbackUrl}}}</CALLBACKURL>
<CONTACTS>
<CUSTOMER><PHONE>{{Phone}}</PHONE></CUSTOMER>
</CONTACTS>
</RQST>'
```

* **Cấu trúc body của request:**

<table><thead><tr><th width="167">Tham số</th><th width="149">Định nghĩa</th><th width="141" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>APIKEY</td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SECRETKEY</td><td>string</td><td>true</td><td>Secretkey của tài khoản.</td></tr><tr><td>CONTENT</td><td>string</td><td>true</td><td>Nội dung tin nhắn.</td></tr><tr><td>SMSTYPE</td><td>string</td><td>true</td><td>Loại tin nhắn<br>1: Tin quảng cáo.</td></tr><tr><td>BRANDNAME</td><td>string</td><td>true</td><td>Tên Brandname (tên công ty hay tổ chức khi gửi tin sẽ hiển thị trên tin nhắn đó). <br><strong>Chú ý: sẽ phải đăng ký trước khi sử dụng.</strong></td></tr><tr><td>PHONE</td><td>string</td><td>true</td><td>Số điện thoại nhận tin nhắn.</td></tr><tr><td>SENDDATE</td><td>string</td><td>false</td><td>Thời gian hẹn gửi của tin. <br>Không truyền khi tin muốn tin nhắn gửi đi liền.<br>Định dạng: yyyy-mm-dd hh:MM:ss</td></tr><tr><td>CALLBACKURL</td><td>string</td><td>false</td><td>URL nhận kết quả gửi tin. <br>Xem body mẫu <a href="https://samplefordevelopers.esms.vn/#eeaca8c5-ef65-4fed-ac2e-697d0360327b">ở đây</a>. <br>Xem chi tiết <a href="https://developers-v2.esms.vn/esms-api/callback-url">ở đây</a>.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d533459ee42b2b9525ba9eabf6a8156"
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}

{% tab title="104" %}

```json
{
    "CodeResult": "104",
    "CountRegenerate": 0,
    "ErrorMessage": "Brand name code is not exist"
}
```

**Brandname truyền chưa đúng hoặc chưa được active.**
{% endtab %}

{% tab title="107" %}

```
{
    "CodeResult": "107",
    "CountRegenerate": 0,
    "ErrorMessage": "Each request has at least 30 numbers to be approved"
}
```

**Tạo tin không thành công. Mỗi request phải có ít nhất 30 số điện thoại hợp lệ.**
{% endtab %}

{% tab title="124" %}

```
{
    "CodeResult": "124",
    "CountRegenerate": 0,
    "ErrorMessage": "Request exist 1"
}
```

**Trùng RequestId. Mỗi RequestId chỉ được gửi cho 1 request.**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

<table><thead><tr><th width="140.7332763671875">Thuộc tính</th><th width="154.5333251953125">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Request được gửi đến ESMS thành công.<br><br><strong>Lưu ý:</strong> Mã phản hồi <strong>100</strong> chỉ xác nhận rằng yêu cầu đã được gửi thành công đến hệ thống ESMS, <strong>không phản ánh việc tin nhắn đã được gửi đến số điện thoại người nhận hay chưa</strong>.<br>Để theo dõi trạng thái cuối cùng của tin nhắn, quý khách vui lòng truyền thêm tham số <strong>CallbackUrl</strong>; hệ thống ESMS sẽ tự động gửi phản hồi (callback) đến địa chỉ này khi có trạng thái cuối của tin.</td></tr><tr><td>SMSID</td><td>string</td><td>ID tin nhắn do esms trả về.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi).</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [**Link code mẫu**](https://samplefordevelopers.esms.vn/#850974b9-12cf-46f5-946c-e8e15aa3585b)**.**


# Gửi tin cố định giá rẻ dạng GET

## HTTP request

\ <mark style="color:green;">**`GET`**</mark> <mark style="color:blue;"><https://rest.esms.vn/MainService.svc/json/SendMultipleMessage\\_V4\\_get?Phone=\\{{Phone\\}}\\&Content=\\{{Content\\}}\\&ApiKey=\\{{ApiKey\\}}\\&SecretKey=\\{{SecretKey\\}}\\&IsUnicode=\\{{IsUnicode\\}}\\&SmsType=8\\&CallbackUrl=\\{{CallbackUrl\\}}\\&RequestId=\\{{RequestId\\}}\\&SendDate=\\{{yyyy-mm-dd> HH:mm:hh}}</mark>

* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location -g 'https://rest.esms.vn/MainService.svc/json/SendMultipleMessage_V4_get?Phone={{Phone}}&Content={{Content}}&ApiKey={{ApiKey}}&SecretKey={{SecretKey}}&IsUnicode={{IsUnicode}}&SmsType=8&CallbackUrl={{CallbackUrl}}&RequestId={{RequestId}}&SendDate={{yyyy-mm-dd%20HH%3Amm%3Ahh}}'
```

* **Cấu trúc body của request:**

<table><thead><tr><th width="148">Tham số</th><th width="139">Kiểu dữ liệu</th><th width="142" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>Phone</td><td>string</td><td>true</td><td>Số điện thoại nhận tin.</td></tr><tr><td>Content</td><td>string</td><td>true</td><td>Nội dung tin nhắn.</td></tr><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Secretkey của tài khoản.</td></tr><tr><td>Unicode</td><td>string</td><td>false</td><td>Gửi nội dung có dấu<br>1: Có dấu.<br>0: Không dấu.</td></tr><tr><td>SmsType</td><td>string</td><td>true</td><td>Loại tin nhắn<br>8: Tin Cố định giá rẻ.</td></tr><tr><td>CallbackUrl</td><td>string</td><td>false</td><td>URL nhận kết quả gửi tin. <br>Xem body mẫu <a href="https://samplefordevelopers.esms.vn/#20f85e1f-3d9e-4ff4-bc4f-8d9c9edbc88a">ở đây</a>. <br>Xem chi tiết <a href="https://developers-v2.esms.vn/esms-api/callback-url">ở đây</a>.</td></tr><tr><td>RequestId</td><td>string</td><td>false</td><td>ID đối tác truyền sang để chặn trùng và đối soát khi cần.<br>Độ dài tối đa 50 ký tự.<br><strong>Mỗi RequestId truyền sang có hiệu lực chặn trong 24h.</strong></td></tr><tr><td>SendDate</td><td>string</td><td>false</td><td>Thời gian hẹn gửi của tin. <br>Không truyền khi tin muốn tin nhắn gửi đi liền.<br>Định dạng: yyyy-mm-dd hh:MM:ss</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d8e0f1f0702544b2acb456ca9ccfd111250"
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}

{% tab title="99" %}

```json
{
  "error": "Invalid request"
}
```

**Kiểm tra lại thông tin kết nối hoặc liên hệ bộ phận chăm sóc khách hàng để được hỗ trợ khi gặp lỗi này.**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

<table><thead><tr><th width="162.5333251953125">Thuộc tính</th><th width="134.2667236328125">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Request được gửi đến ESMS thành công.<br><br><strong>Lưu ý:</strong> Mã phản hồi <strong>100</strong> chỉ xác nhận rằng yêu cầu đã được gửi thành công đến hệ thống ESMS, <strong>không phản ánh việc tin nhắn đã được gửi đến số điện thoại người nhận hay chưa</strong>.<br>Để theo dõi trạng thái cuối cùng của tin nhắn, quý khách vui lòng truyền thêm tham số <strong>CallbackUrl</strong>; hệ thống ESMS sẽ tự động gửi phản hồi (callback) đến địa chỉ này khi có trạng thái cuối của tin.</td></tr><tr><td>SMSID</td><td>string</td><td>ID tin nhắn do esms trả về.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi).</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* <mark style="color:yellow;">Lấy code mẫu của các ngôn ngữ ở link:</mark> [**Code mẫu**](https://samplefordevelopers.esms.vn/#562c21f1-e073-4352-8a24-eac62657953b) **.**


# Gửi tin quảng cáo dạng POST TEXT

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> <https://rest.esms.vn/MainService.svc/json/SendMultipleSMSBrandname>

* **Content Type:** <mark style="color:orange;">text/plain</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```
curl --location 'https://rest.esms.vn/MainService.svc/json/SendMultipleSMSBrandname' \
--header 'Content-Type: text/plain' \
--data '<RQST>
<APIKEY>{{APIKEY}}</APIKEY>
<SECRETKEY>{{SECRETKEY}}</SECRETKEY>
<CONTENT>{{CONTENT}}</CONTENT>
<SMSTYPE>1</SMSTYPE>
<REQUESTID>{{REQUESTID}}</REQUESTID>
<CAMPAIGNID>khuyến mãi</CAMPAIGNID>
<BRANDNAME>{{BRANDNAME}}</BRANDNAME>
<CONTACTS>
<CUSTOMER><PHONE>{{PHONE}}</PHONE></CUSTOMER>
<CUSTOMER><PHONE>{{PHONE}}</PHONE></CUSTOMER>
<CUSTOMER><PHONE>{{PHONE}}</PHONE></CUSTOMER>
<CUSTOMER><PHONE>{{PHONE}}</PHONE></CUSTOMER>
<CUSTOMER><PHONE>{{PHONE}}</PHONE></CUSTOMER>
</CONTACTS>
</RQST>'
```

* **Cấu trúc body của request:**

<table><thead><tr><th width="157">Tham số</th><th width="130">Kiểu dữ liệu</th><th width="140" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>CONTACTS</td><td>string</td><td>true</td><td>Số điện thoại nhận tin.</td></tr><tr><td>CONTENT</td><td>string</td><td>true</td><td>Nội dung tin nhắn.</td></tr><tr><td>APIKEY</td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SECRETKEY</td><td>string</td><td>true</td><td>Secretkey của tài khoản.</td></tr><tr><td>SMSTYPE</td><td>string</td><td>true</td><td>Loại tin nhắn<br>2: Tin CSKH.</td></tr><tr><td>REQUESTID</td><td></td><td>false</td><td>ID đối tác truyền sang để chặn trùng và đối soát khi cần.<br>Độ dài tối đa 50 ký tự.<br><strong>Mỗi RequestId truyền sang có hiệu lực chặn trong 24h.</strong></td></tr><tr><td>BRANDNAME</td><td>string</td><td>true</td><td>Tên Brandname (tên công ty hay tổ chức khi gửi tin sẽ hiển thị trên tin nhắn đó). <br><strong>Chú ý: sẽ phải đăng ký trước khi sử dụng.</strong></td></tr><tr><td>CAMPAIGNID</td><td>string</td><td>false</td><td>Tên chiến dịch gửi tin, tối đa 254 ký tự</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d533459ee42b2b9525ba9eabf6a8156"
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}

{% tab title="104" %}

```json
{
    "CodeResult": "104",
    "CountRegenerate": 0,
    "ErrorMessage": "Brand name code is not exist"
}
```

**Brandname truyền chưa đúng hoặc chưa được active.**
{% endtab %}

{% tab title="107" %}

```json
{
    "CodeResult": "107",
    "CountRegenerate": 0,
    "ErrorMessage": "Each request has at least 30 numbers to be approved"
}
```

**Tạo tin không thành công. Mỗi request phải có ít nhất 30 số điện thoại hợp lệ.**
{% endtab %}

{% tab title="124" %}

```json
{
    "CodeResult": "124",
    "CountRegenerate": 0,
    "ErrorMessage": "Request exist 1"
}
```

**Trùng RequestId. Mỗi RequestId chỉ được gửi cho 1 request.**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

<table><thead><tr><th width="159.79998779296875">Thuộc tính</th><th width="137.8665771484375">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Request được gửi đến ESMS thành công.<br><br><strong>Lưu ý:</strong> Mã phản hồi <strong>100</strong> chỉ xác nhận rằng yêu cầu đã được gửi thành công đến hệ thống ESMS, <strong>không phản ánh việc tin nhắn đã được gửi đến số điện thoại người nhận hay chưa</strong>.<br>Để theo dõi trạng thái cuối cùng của tin nhắn, quý khách vui lòng truyền thêm tham số <strong>CallbackUrl</strong>; hệ thống ESMS sẽ tự động gửi phản hồi (callback) đến địa chỉ này khi có trạng thái cuối của tin.</td></tr><tr><td>SMSID</td><td>string</td><td>ID tin nhắn do esms trả về.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi).</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [***Link code mẫu***](https://developers-v2.esms.vn/esms-api/ham-gui-tin/tin-sms-quang-cao#http-request)


# Hàm gửi tin Zalo V4

Hàm cho phép bạn gửi tin nhắn đến 1 hoặc nhiều số điện thoại đã đăng kí Zalo. Để có thể gửi được tin ZNS bạn cần tiến hành:\
\- Đăng ký và xác thực Zalo Offical Account (Zalo OA)\
\- Đăng ký template tin nhắn\
Để hoàn thành các việc trên vui lòng liên hệ nhân viên kinh doanh hỗ trợ của bạn hoặc Hotline 0901888484\
Ví dụ 1 mẫu tin ZNS<br>

<figure><img src="/files/B23SH9MOntqgUVi2ncqj" alt=""><figcaption><p>Một tin ZNS mẫu</p></figcaption></figure>

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> <https://rest.esms.vn/MainService.svc/json/SendZaloMessage_V4_post_json/>

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

{% code overflow="wrap" %}

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/SendZaloMessage_V4_post_json/' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey": "{{ApiKey}}",
    "SecretKey": "{{SecretKey}}",
    "Phone": "{{Phone}}",
    "Params": [
        "{{value1}}",
        "{{value2}}",
        "{{value3}}"
    ],
    "TempID": "{{TempID}}",
    "OAID": "{{OAID}}",
    "SendDate": "{{SendDate}}",
    "Sandbox": "0",
    "RequestId": "{{RequestId}}",
    "campaignid": "{{campaignid}}",
    "CallbackUrl": "{{CallbackUrl}}"
}'
```

{% endcode %}

* **Cấu trúc body của request:**

<table><thead><tr><th width="156">Tham số</th><th width="145">Kiểu dữ liệu</th><th width="132" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Secretkey của tài khoản.</td></tr><tr><td>Phone</td><td>string</td><td>true</td><td>Số điện thoại nhận tin.</td></tr><tr><td>Params</td><td>string</td><td>true</td><td><p></p><p>Giá trị cần truyền cho các biến trong Template *Lưu ý:</p><ol><li>Các tham số truyền vào phải đúng thứ tự như template bạn đăng ký</li><li>Nếu tham số trùng nhau chỉ cần truyền vào một tham số</li></ol></td></tr><tr><td>TempID</td><td>string</td><td>true</td><td>Template của Zalo OA mà khách hàng đăng kí với eSMS.</td></tr><tr><td>OAID</td><td>string</td><td>true</td><td>Zalo OA ID, là ID của trang Zalo Offical Account của doanh nghiệp. Doanh nghiệp cần đăng nhập vào trang quản trị của Zalo OA để lấy phần Zalo OA ID này. <br><strong>Chú ý: sẽ phải đăng ký trước khi sử dụng.</strong></td></tr><tr><td>SendDate</td><td>string</td><td>false</td><td>Thời gian hẹn gửi của tin. <br>Không truyền khi tin muốn tin nhắn gửi đi liền.<br>Định dạng: yyyy-mm-dd hh:MM:ss.</td></tr><tr><td>Sandbox</td><td>string</td><td>false</td><td>1: Tin gửi ở môi trường test, dùng để kiểm tra kết nối và các thông số tích hợp, không về tin nhắn, không trừ tiền.<br>0: Tin gửi ở môi trường bình thường, có về tin nhắn.</td></tr><tr><td>RequestId</td><td>string</td><td>false</td><td>ID đối tác truyền sang để chặn trùng và đối soát khi cần.<br>Độ dài tối đa 50 ký tự.<br><strong>Mỗi RequestId truyền sang có hiệu lực chặn trong 24h.</strong></td></tr><tr><td>campaignid</td><td>string</td><td>false</td><td>Tên chiến dịch gửi tin, tối đa 254 ký tự.</td></tr><tr><td>CallbackUrl</td><td>string</td><td>false</td><td>URL nhận kết quả gửi tin. <br>Xem body mẫu <a href="https://samplefordevelopers.esms.vn/#b98ca55e-3001-4446-b5bb-a4ab86127b0b">ở đây</a>. <br>Xem chi tiết <a href="https://developers-v2.esms.vn/esms-api/callback-url">ở đây</a>.</td></tr><tr><td>SendingMode</td><td>string</td><td>false</td><td>Chế độ gửi:<br> <kbd><strong>1</strong></kbd> (Default): Gửi thường, tin ZNS được gửi theo cơ chế thông thường. <br><kbd><strong>3</strong></kbd>: Gửi vượt hạn mức, cho phép OA gửi tin ZNS tag 3 vượt hạn mức. <br><br><strong>Lưu ý</strong>: Chế độ Gửi vượt hạn mức (SendingMode = 3) chỉ áp dụng cho các OA được whitelist. Vui lòng liên hệ đội ngũ CSKH nếu có nhu cầu gửi ở chế độ Gửi vượt hạn mức.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d8e0f1f0702544b2acb456ca9ccfd111250"
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}

{% tab title="789" %}

```
{
    "CodeResult": "789",
    "CountRegenerate": 0,
    "ErrorMessage": "TemplateId is not config"
}
```

**Template chưa được cấu hình cho OA ID bạn đang sử dụng.**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

<table><thead><tr><th width="151.73333740234375">Thuộc tính</th><th width="143.7332763671875">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Request được gửi đến ESMS thành công.<br><br><strong>Lưu ý:</strong> Mã phản hồi <strong>100</strong> chỉ xác nhận rằng yêu cầu đã được gửi thành công đến hệ thống ESMS, <strong>không phản ánh việc tin nhắn đã được gửi đến số điện thoại người nhận hay chưa</strong>.<br>Để theo dõi trạng thái cuối cùng của tin nhắn, quý khách vui lòng truyền thêm tham số <strong>CallbackUrl</strong>; hệ thống ESMS sẽ tự động gửi phản hồi (callback) đến địa chỉ này khi có trạng thái cuối của tin.</td></tr><tr><td>SMSID</td><td>string</td><td>ID tin nhắn do esms trả về.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi).</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu của các ngôn ngữ ở link:**</mark>* [**Code mẫu**](https://samplefordevelopers.esms.vn/#2d996c73-a5c2-45ca-973e-d18aabb960c7) **.**


# Hàm gửi tin Zalo V5

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> [https://rest.esms.vn/MainService.svc/json/SendZaloMessage\_V5\_post/](http://rest.esms.vn/MainService.svc/json/SendZaloMessage_V5_post/)

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

{% code overflow="wrap" %}

```json
curl --location 'http://rest.esms.vn/MainService.svc/json/SendZaloMessage_V5_post/' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey": "{{ApiKey}}",
    "SecretKey": "{{SecretKey}}",
    "OAID": "{{OAID}}",
    "Phone": "{{Phone}}",
    "TempData": [
        {
            "key": "{{key1}}",
            "value": "{{value1}}"
        },
        {
            "key": "{{key2}}",
            "value": "{{value2}}"
        }
    ],
    "SendDate": "{{SendDate}}",
    "TempID": "{{TempID}}",
    "campaignid": "{{campaignid}}",
    "Sandbox": "{{Sandbox}}",
    "RequestId": "{{RequestId}}",
    "CallbackUrl": "{{CallbackUrl}}"
}'
```

{% endcode %}

* **Cấu trúc body của request:**

<table><thead><tr><th width="141.06671142578125">Tham số</th><th width="130.066650390625">Kiểu dữ liệu</th><th width="127.7332763671875" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Secretkey của tài khoản.</td></tr><tr><td>Phone</td><td>string</td><td>true</td><td>Số điện thoại nhận tin.</td></tr><tr><td>TempData</td><td>string</td><td>true</td><td>Bao gồm tên biến và giá trị biến trong Template:<br>key: Tên biến (bắt buộc phải giống trong Template đã đăng ký).<br>value: Giá trị biến.</td></tr><tr><td>TempID</td><td>string</td><td>true</td><td>Template của Zalo OA mà khách hàng đăng kí với eSMS.</td></tr><tr><td>OAID</td><td>string</td><td>true</td><td>Zalo OA ID, là ID của trang Zalo Offical Account của doanh nghiệp. Doanh nghiệp cần đăng nhập vào trang quản trị của Zalo OA để lấy phần Zalo OA ID này. <br><strong>Chú ý: sẽ phải đăng ký trước khi sử dụng.</strong></td></tr><tr><td>SendDate</td><td>string</td><td>false</td><td>Thời gian hẹn gửi của tin. <br>Không truyền khi tin muốn tin nhắn gửi đi liền.<br>Định dạng: yyyy-mm-dd hh:MM:ss.</td></tr><tr><td>Sandbox</td><td>string</td><td>false</td><td>1: Tin gửi ở môi trường test, dùng để kiểm tra kết nối và các thông số tích hợp, không về tin nhắn, không trừ tiền.<br>0: Tin gửi ở môi trường bình thường, có về tin nhắn.</td></tr><tr><td>RequestId</td><td>string</td><td>false</td><td>ID đối tác truyền sang để chặn trùng và đối soát khi cần.<br>Độ dài tối đa 50 ký tự.<br><strong>Mỗi RequestId truyền sang có hiệu lực chặn trong 24h.</strong></td></tr><tr><td>campaignid</td><td>string</td><td>false</td><td>Tên chiến dịch gửi tin, tối đa 254 ký tự.</td></tr><tr><td>CallbackUrl</td><td>string</td><td>false</td><td>URL nhận kết quả gửi tin. <br>Xem body mẫu <a href="https://samplefordevelopers.esms.vn/#b98ca55e-3001-4446-b5bb-a4ab86127b0b">ở đây</a>. <br>Xem chi tiết <a href="https://developers-v2.esms.vn/esms-api/callback-url">ở đây</a>.</td></tr><tr><td>SendingMode</td><td>string</td><td>false</td><td>Chế độ gửi:<br> <kbd><strong>1</strong></kbd> (Default): Gửi thường, tin ZNS được gửi theo cơ chế thông thường. <br><kbd><strong>3</strong></kbd>: Gửi vượt hạn mức, cho phép OA gửi tin ZNS tag 3 vượt hạn mức. <br><br><strong>Lưu ý</strong>: Chế độ Gửi vượt hạn mức (SendingMode = 3) chỉ áp dụng cho các OA được whitelist. Vui lòng liên hệ đội ngũ CSKH nếu có nhu cầu gửi ở chế độ Gửi vượt hạn mức.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d8e0f1f0702544b2acb456ca9ccfd111250"
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}

{% tab title="789" %}

```
{
    "CodeResult": "789",
    "CountRegenerate": 0,
    "ErrorMessage": "TemplateId is not config"
}
```

**Template chưa được cấu hình cho OA ID bạn đang sử dụng.**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

<table><thead><tr><th width="160.2666015625">Thuộc tính</th><th width="148">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Request được gửi đến ESMS thành công.<br><br><strong>Lưu ý:</strong> Mã phản hồi <strong>100</strong> chỉ xác nhận rằng yêu cầu đã được gửi thành công đến hệ thống ESMS, <strong>không phản ánh việc tin nhắn đã được gửi đến số điện thoại người nhận hay chưa</strong>.<br>Để theo dõi trạng thái cuối cùng của tin nhắn, quý khách vui lòng truyền thêm tham số <strong>CallbackUrl</strong>; hệ thống ESMS sẽ tự động gửi phản hồi (callback) đến địa chỉ này khi có trạng thái cuối của tin.</td></tr><tr><td>SMSID</td><td>string</td><td>ID tin nhắn do esms trả về.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi).</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu của các ngôn ngữ ở link:**</mark>* [**Code mẫu**](https://samplefordevelopers.esms.vn/#2d996c73-a5c2-45ca-973e-d18aabb960c7) **.**


# Tin Zalo mỗi khách hàng một nội dung

API eSMS gửi tin nhắn Zalo hàng loạt với nội dung tùy chỉnh cho từng khách hàng. Hỗ trợ mẫu tin, tham số động, hẹn giờ gửi và callback. Tích hợp dễ dàng qua HTTP POST JSON.

{% hint style="warning" %}
API này không hỗ trợ gửi tin từ ví zns miễn phí, các tin nhắn được miễn phí sẽ hậu kiểm và đối trừ sau.
{% endhint %}

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> [https://rest.esms.vn/MainService.svc/json/Send\_zns\_bulk\_v4\_post\_json/](http://rest.esms.vn/MainService.svc/json/Send_zns_bulk_v4_post_json/)

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```bash
curl --location 'https://rest.esms.vn/MainService.svc/json/Send_zns_bulk_v4_post_json/' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey": "{{ApiKey}}",
    "SecretKey": "{{SecretKey}}",
    "campaignid": "Chiến dịch 1",
    "OAID": "4097311281936189049",
    "TempID": "267247",
    "Sandbox": "0",
    "CallbackUrl": "https://esms.vn/webhook/",
    "Data": [
        {
            "Phone": "0901888484",
            "RequestId": "96accf59-0c41-4bc7-a5c1",
            "Params": [ "Chị A", "Gội đầu", "KH001", "19/03/2025" ]
        },
        {
            "Phone": "0918238965",
            "RequestId": "96accf59-0c41-4bc7-a5c2",
            "Params": [ "Chị B", "Uốn", "KH002", "19/03/2025" ]
        },
        {
            "Phone": "0765418062",
            "RequestId": "96accf59-0c41-4bc7-a5c3",
            "Params": [ "Chị C", "Nhuộm", "KH003", "19/03/2025" ]
        }
    ]
}'
```

* **Cấu trúc body của request:**

<table><thead><tr><th width="155">Tham số</th><th width="124">Kiểu dữ liệu</th><th width="141" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey </td><td>string</td><td>true</td><td>Chuỗi ký tự đại diện cho khóa API của tài khoản eSMS.</td></tr><tr><td>SecretKey </td><td>string</td><td>true</td><td>Chuỗi ký tự bí mật của tài khoản eSMS.</td></tr><tr><td>campaignid</td><td>string</td><td>false</td><td>Tên chiến dịch gửi tin, tối đa 254 ký tự.<br>Đây là mã chiến dịch mà bạn sẽ phân biệt được các chiến dịch gửi tin.</td></tr><tr><td>OAID</td><td>string</td><td>true</td><td>ID của Zalo Official Account (OA) của doanh nghiệp. Doanh nghiệp cần đăng nhập vào trang quản trị của Zalo OA để lấy OAID này. <br><strong>Chú ý: sẽ phải đăng ký trước khi sử dụng.</strong></td></tr><tr><td>TempID</td><td>string</td><td>true</td><td>ID của mẫu tin nhắn Zalo OA mà doanh nghiệp đã đăng ký với eSMS.</td></tr><tr><td>Sandbox</td><td>string</td><td>false</td><td>Chế độ Sandbox để kiểm tra API mà không gửi tin nhắn thực tế.<br><strong>Mặc định:</strong> <code>Sandbox = 0</code></td></tr><tr><td>SendDate</td><td>string</td><td>false</td><td>Thời gian hẹn gửi tin nhắn.<br>Nếu không truyền tham số này, tin nhắn sẽ được gửi ngay lập tức.<br><strong>Định dạng:</strong> <code>yyyy-mm-dd hh:MM:ss</code></td></tr><tr><td>CallbackUrl</td><td>string</td><td>false</td><td>URL mà hệ thống sẽ gọi lại để trả kết quả gửi tin nhắn.<br>Xem body mẫu <a href="https://samplefordevelopers.esms.vn/#eeaca8c5-ef65-4fed-ac2e-697d0360327b">ở đây</a>. <br>Xem chi tiết <a href="/pages/HxTrJlnDLexPUwac9BWb">ở đây</a>.</td></tr><tr><td>Data</td><td>Array</td><td>true</td><td>Mảng đối tượng chứa thông tin về từng tin nhắn bạn muốn gửi.<br><strong>Chú ý: Mảng có kích thước tối đa 500 phần tử.</strong></td></tr><tr><td>Data: Phone</td><td>string</td><td>true</td><td>Số điện thoại người nhận.</td></tr><tr><td>Data: RequestId</td><td>string</td><td>false</td><td>ID đối tác truyền sang để chặn trùng và đối soát khi cần.<br>Độ dài tối đa 50 ký tự.<br><strong>Mỗi RequestId truyền sang có hiệu lực chặn trong 24h.</strong></td></tr><tr><td>Data: Params </td><td>string</td><td>true</td><td><p></p><p>Danh sách các giá trị cần truyền cho các biến trong mẫu tin nhắn.<br> <strong>*Lưu ý:</strong></p><ol><li>Các tham số truyền vào phải đúng thứ tự như template bạn đăng ký.</li><li>Nếu tham số trùng nhau chỉ cần truyền vào một tham số.</li></ol></td></tr><tr><td>SendingMode</td><td>string</td><td>false</td><td>Chế độ gửi:<br> <kbd><strong>1</strong></kbd> (Default): Gửi thường, tin ZNS được gửi theo cơ chế thông thường. <br><kbd><strong>3</strong></kbd>: Gửi vượt hạn mức, cho phép OA gửi tin ZNS tag 3 vượt hạn mức. <br><br><strong>Lưu ý</strong>: Chế độ Gửi vượt hạn mức (SendingMode = 3) chỉ áp dụng cho các OA được whitelist. Vui lòng liên hệ đội ngũ CSKH nếu có nhu cầu gửi ở chế độ Gửi vượt hạn mức.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json

{
    "CodeResult": "100",
    "Message": "Sucess",
    "TotalFail": 1,
    "TotalSuccess": 2,
    "detail": [
        {
            "CodeResult": "100",
            "Phone": "{Phone}",
            "SMSID": "a037b928-cb7e-4bfc-bdf9-0286318163aa264"
        },
        {
            "CodeResult": "100",
            "Phone": "{Phone}",
            "SMSID": "b83ff06e-8989-4b0d-818e-795b96699e86261"
        },
        {
            "CodeResult": "108",
            "Phone": "{Phone}",
            "ErrorMessage": "The phone number 097469188 is not valid."
        }
    ]
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}

{% tab title="789" %}

```json
{
    "CodeResult": "789",
    "CountRegenerate": 0,
    "ErrorMessage": "TemplateId is not config"
}
```

**Template chưa được cấu hình cho OA ID bạn đang sử dụng.**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

<table><thead><tr><th width="177">Thuốc tính</th><th width="146">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Request được gửi đến ESMS thành công.<br><br><strong>Lưu ý:</strong> Mã phản hồi <strong>100</strong> chỉ xác nhận rằng yêu cầu đã được gửi thành công đến hệ thống ESMS, <strong>không phản ánh việc tin nhắn đã được gửi đến số điện thoại người nhận hay chưa</strong>.<br>Để theo dõi trạng thái cuối cùng của tin nhắn, quý khách vui lòng truyền thêm tham số <strong>CallbackUrl</strong>; hệ thống ESMS sẽ tự động gửi phản hồi (callback) đến địa chỉ này khi có trạng thái cuối của tin.</td></tr><tr><td>Message</td><td>string</td><td>Mô tả chi tiết về phản hồi.</td></tr><tr><td>TotalFail</td><td>string</td><td>Tổng số điện thoại request gửi tin thất bại.</td></tr><tr><td>TotalSuccess</td><td>string</td><td>Tổng số điện thoại request gửi tin thành công.</td></tr><tr><td>detail : CodeResult</td><td>string</td><td>Mã trả về.</td></tr><tr><td>detail : Phone</td><td>string</td><td>Số điện thoại tương ứng với ID tin nhắn do esms trả về.</td></tr><tr><td>detail : SMSID</td><td>string</td><td>ID tin nhắn do esms trả về.</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [**Link code mẫu**](https://samplefordevelopers.esms.vn/#1f75d02b-c622-4de4-aedc-dd9d4c2b16ea)**.**&#x20;


# Hàm gửi tin nhắn Zalo dạng X-Form

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> <https://rest.esms.vn/MainService.svc/json/SendMultipleMessage_V4_post/>

* **Content Type:** <mark style="color:orange;">application/x-www-form-urlencoded</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

{% code overflow="wrap" %}

```
curl --location 'http://rest.esms.vn/MainService.svc/json/SendMultipleMessage_V4_post/' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'Apikey={{Apikey}}' \
--data-urlencode 'SecretKey={{SecretKey}}' \
--data-urlencode 'Phone={{Phone}}' \
--data-urlencode 'Content={{Content}}' \
--data-urlencode 'Smstype={{Smstype}}' \
--data-urlencode 'OAID={{OAID}}'
```

{% endcode %}

* **Cấu trúc body của request:**

<table><thead><tr><th width="143">Tham số</th><th width="152">Kiểu dữ liệu</th><th width="130" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>Phone</td><td>string</td><td>true</td><td>Số điện thoại người nhận.</td></tr><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Secretkey của tài khoản.</td></tr><tr><td>OAID</td><td>string</td><td>true</td><td>Zalo OA ID, là ID của trang Zalo Offical Account của doanh nghiệp. Doanh nghiệp cần đăng nhập vào trang quản trị của Zalo OA để lấy phần Zalo OA ID này. <br><strong>Chú ý: sẽ phải đăng ký trước khi sử dụng.</strong></td></tr><tr><td>Content</td><td>string</td><td>true</td><td>Nội dung tin nhắn sẽ được gửi full content.<br>Lưu ý: Khi gửi dạng tin nhắn này khách hàng vui lòng liên hệ cho nhân viên kinh doanh để được hỗ trợ về content.</td></tr><tr><td>Smstype</td><td>string</td><td>true</td><td>Loại tin nhắn:<br>24: Zalo ưu tiên.<br>25: Zalo bình thường.</td></tr><tr><td>SendingMode</td><td></td><td>false</td><td>Không áp dụng gửi tin Vượt hạn mức cho API này.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d8e0f1f0702544b2acb456ca9ccfd111250"
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}

{% tab title="789" %}

```
{
    "CodeResult": "789",
    "CountRegenerate": 0,
    "ErrorMessage": "TemplateId is not config"
}
```

**Template chưa được cấu hình cho OA ID bạn đang sử dụng.**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

<table><thead><tr><th width="143.53338623046875">Thuộc tính</th><th width="140.933349609375">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Request được gửi đến ESMS thành công.<br><br><strong>Lưu ý:</strong> Mã phản hồi <strong>100</strong> chỉ xác nhận rằng yêu cầu đã được gửi thành công đến hệ thống ESMS, <strong>không phản ánh việc tin nhắn đã được gửi đến số điện thoại người nhận hay chưa</strong>.<br>Để theo dõi trạng thái cuối cùng của tin nhắn, quý khách vui lòng truyền thêm tham số <strong>CallbackUrl</strong>; hệ thống ESMS sẽ tự động gửi phản hồi (callback) đến địa chỉ này khi có trạng thái cuối của tin.</td></tr><tr><td>SMSID</td><td>string</td><td>ID tin nhắn do esms trả về.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi).</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu của các ngôn ngữ ở link:**</mark>* [**Code mẫu**](https://samplefordevelopers.esms.vn/#2d996c73-a5c2-45ca-973e-d18aabb960c7) **.**


# Hàm gửi tin nhắn Zalo dạng Json Full template

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> <https://rest.esms.vn/MainService.svc/json/SendMultipleMessage_V4_post_json/>

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

{% code overflow="wrap" %}

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/SendMultipleMessage_V4_post_json/' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey": "{{ApiKey}}",
    "SecretKey": "{{SecretKey}}",
    "SmsType": "{{SmsType}}",
    "OAID": "{{OAID}}",
    "Phone": "{{Phone}}",
    "Content": "{{Content}}",
    "RequestId": "{{RequestId}}",
    "IsUnicode": "1"
}'
```

{% endcode %}

* **Cấu trúc body của request:**

<table><thead><tr><th width="146">Tham số</th><th width="137">Giá trị biến</th><th width="168" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>Phone</td><td>string</td><td>true</td><td>Số điện thoại người nhận.</td></tr><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Secretkey của tài khoản.</td></tr><tr><td>OAID</td><td>string</td><td>true</td><td>Zalo OA ID, là ID của trang Zalo Offical Account của doanh nghiệp. Doanh nghiệp cần đăng nhập vào trang quản trị của Zalo OA để lấy phần Zalo OA ID này. <br><strong>Chú ý: sẽ phải đăng ký trước khi sử dụng.</strong></td></tr><tr><td>Content</td><td>string</td><td>true</td><td>Nội dung tin nhắn sẽ được gửi full content.<br>Lưu ý: Khi gửi dạng tin nhắn này khách hàng vui lòng liên hệ cho nhân viên kinh doanh để được hỗ trợ về content.</td></tr><tr><td>Smstype</td><td>string</td><td>true</td><td>Loại tin nhắn:<br>24: Zalo ưu tiên.<br>25: Zalo bình thường.</td></tr><tr><td>RequestId</td><td>string</td><td>false</td><td>ID đối tác truyền sang để chặn trùng và đối soát khi cần.<br>Độ dài tối đa 50 ký tự.<br><strong>Mỗi RequestId truyền sang có hiệu lực chặn trong 24h.</strong></td></tr><tr><td>IsUnicode</td><td></td><td>false</td><td>Gửi nội dung có dấu<br>1: Có dấu.<br>0: Không dấu.</td></tr><tr><td>SendingMode</td><td></td><td>false</td><td>Không áp dụng gửi tin Vượt hạn mức cho API này.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```
{
    "CodeResult": "789",
    "CountRegenerate": 0,
    "ErrorMessage": "TemplateId is not config"
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}

{% tab title="789" %}

```
{
    "CodeResult": "789",
    "CountRegenerate": 0,
    "ErrorMessage": "TemplateId is not config"
}
```

**Template chưa được cấu hình cho OA ID bạn đang sử dụng.**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

<table><thead><tr><th width="156.8665771484375">Thuộc tính</th><th width="133.800048828125">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Request được gửi đến ESMS thành công.<br><br><strong>Lưu ý:</strong> Mã phản hồi <strong>100</strong> chỉ xác nhận rằng yêu cầu đã được gửi thành công đến hệ thống ESMS, <strong>không phản ánh việc tin nhắn đã được gửi đến số điện thoại người nhận hay chưa</strong>.<br>Để theo dõi trạng thái cuối cùng của tin nhắn, quý khách vui lòng truyền thêm tham số <strong>CallbackUrl</strong>; hệ thống ESMS sẽ tự động gửi phản hồi (callback) đến địa chỉ này khi có trạng thái cuối của tin.</td></tr><tr><td>SMSID</td><td>string</td><td>ID tin nhắn do esms trả về.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi).</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu của các ngôn ngữ ở link:**</mark>* [**Code mẫu**](https://samplefordevelopers.esms.vn/#2d996c73-a5c2-45ca-973e-d18aabb960c7) **.**


# Hàm gửi tin nhắn Viber dạng GET

Cho phép bạn gửi tin nhắn đến số điện thoại đang sử sụng Viber

<figure><img src="/files/PnzjK4oRa8QU1lfODV0g" alt=""><figcaption><p>Hình mẫu tin nhắn Viber</p></figcaption></figure>

## HTTP request

\ <mark style="color:green;">**`GET`**</mark> <https://rest.esms.vn/MainService.svc/json/SendMultipleMessage_V4_get?SmsType=23&OTTUrl={{OTTUrl}}&OTTImgUrl={{OTTImgUrl}}&Phone={{Phone}}&Content={{Content}}&ApiKey={{ApiKey}}&SecretKey={{SecretKey}}&Brandname={{Brandname}}&OTTLabel={{OTTLabel}}&CallbackUrl={{CallbackUrl}}><mark style="color:blue;">\&Sandbox={{Sandbox}}</mark>

* **Response Type:** <mark style="color:orange;">application/json</mark>

{% code overflow="wrap" %}

```json
curl --location --globoff 'https://rest.esms.vn/MainService.svc/json/SendMultipleMessage_V4_get?SmsType=23&OTTUrl={{OTTUrl}}&OTTImgUrl={{OTTImgUrl}}&Phone={{Phone}}&Content={{Content}}&ApiKey={{ApiKey}}&SecretKey={{SecretKey}}&Brandname={{Brandname}}&OTTLabel={{OTTLabel}}&CallbackUrl={{CallbackUrl}}&Sandbox={{Sandbox}}'
```

{% endcode %}

* **Cấu trúc body của request:**

<table><thead><tr><th width="171">Tham số</th><th width="145">Kiểu dữ liệu</th><th width="153" data-type="checkbox">Tính bắt buộc</th><th>Định nghĩa</th></tr></thead><tbody><tr><td>SmsType</td><td>string</td><td>true</td><td>Loại tin nhắn<br>23: Tin nhắn OTT Viber.</td></tr><tr><td>OTTUrl</td><td>string</td><td>false</td><td>Đường dẫn tên nút.</td></tr><tr><td>OTTImgUrl</td><td>string</td><td>false</td><td>Đường dẫn hình ảnh.</td></tr><tr><td>Phone</td><td>string</td><td>true</td><td>Số điện thoại người nhận.</td></tr><tr><td>Content</td><td>string</td><td>true</td><td>Nội dung gửi đến người nhận.</td></tr><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Secretkey của tài khoản.</td></tr><tr><td>Brandname</td><td>string</td><td>true</td><td>Tên Brandname (tên công ty hay tổ chức khi gửi tin sẽ hiển thị trên tin nhắn đó). Chú ý: sẽ phải đăng ký trước khi sử dụng.</td></tr><tr><td>OTTLabel</td><td>string</td><td>false</td><td>Tên nút.</td></tr><tr><td>RequestId</td><td>string</td><td>false</td><td>ID đối tác truyền sang để chặn trùng và đối soát khi cần.<br>Độ dài tối đa 50 ký tự.<br><strong>Mỗi RequestId truyền sang có hiệu lực chặn trong 24h.</strong></td></tr><tr><td>CallbackUrl</td><td>string</td><td>false</td><td>URL nhận kết quả gửi tin. <br>Xem body mẫu <a href="https://samplefordevelopers.esms.vn/#6acfe1fc-8601-4bce-9549-65bf17f279b1">ở đây</a>. <br>Xem chi tiết <a href="https://developers-v2.esms.vn/esms-api/callback-url">ở đây</a>.</td></tr><tr><td>Sandbox</td><td></td><td>false</td><td>1: Tin gửi ở môi trường test, dùng để kiểm tra kết nối và các thông số tích hợp, không về tin nhắn, không trừ tiền. <br>0: Tin gửi ở môi trường bình thường, có về tin nhắn.</td></tr></tbody></table>

* <mark style="color:yellow;">**`Lưu ý:`**</mark> Tin nhắn Viber có bốn kiểu nội dung để lựa chọn như sau:\
  \- <mark style="color:green;">**Kiểu Văn bản - Ảnh- Nút**</mark> => Khi request truyền các tham số: Content, OttImgUrl, OttUrl, OTTLabel.\
  \- <mark style="color:green;">**Kiểu Văn bản - Nút**</mark> => Khi request truyền các tham số: Content, OttUrl, OTTLabel.\
  \- <mark style="color:green;">**Kiểu Ảnh**</mark> => Khi request truyền các tham số: OttImgUrl.\
  \- <mark style="color:green;">**Kiểu Văn bản**</mark> => Khi request truyền các tham số: Content.

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d8e0f1f0702544b2acb456ca9ccfd111250"
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="Second Tab" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}

{% tab title="Untitled" %}

```
{
    "CodeResult": "104",
    "CountRegenerate": 0,
    "ErrorMessage": "Brand name code is not exist"
}
```

**Brandname truyền chưa đúng hoặc chưa được active.**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

<table><thead><tr><th width="157.5333251953125">Thuộc tính</th><th width="130">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Request được gửi đến ESMS thành công.<br><br><strong>Lưu ý:</strong> Mã phản hồi <strong>100</strong> chỉ xác nhận rằng yêu cầu đã được gửi thành công đến hệ thống ESMS, <strong>không phản ánh việc tin nhắn đã được gửi đến số điện thoại người nhận hay chưa</strong>.<br>Để theo dõi trạng thái cuối cùng của tin nhắn, quý khách vui lòng truyền thêm tham số <strong>CallbackUrl</strong>; hệ thống ESMS sẽ tự động gửi phản hồi (callback) đến địa chỉ này khi có trạng thái cuối của tin.</td></tr><tr><td>SMSID</td><td>string</td><td>ID tin nhắn do esms trả về.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi).</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [**Link code mẫu**](https://samplefordevelopers.esms.vn/#9a4ce369-8f02-43cb-9693-f2e9ab827af3)**.**


# Hàm check code

Hàm cho phép bạn gọi API check code xem đã sử dụng, hết hạn.

## HTTP request

\ <mark style="color:green;">**`GET`**</mark>  <mark style="color:blue;"><https://rest.esms.vn/MainService.svc/json/CheckCodeGen\\_V4\\_get?ApiKey=\\{{ApiKey\\}}\\&SecretKey=\\{{SecretKey\\}}\\&Phone=\\{{{Phone\\}}\\&Code=\\{{Code\\}}></mark>

\
**Response Type:** <mark style="color:orange;">application/json</mark>

{% code overflow="wrap" %}

```json
curl --location --globoff 'https://rest.esms.vn/MainService.svc/json/CheckCodeGen_V4_get?ApiKey={{ApiKey}}&SecretKey={{SecretKey}}&Phone={{{Phone}}&Code={{Code}}'
```

{% endcode %}

* **Cấu trúc body của request:**

<table><thead><tr><th width="130">Tham số</th><th width="129">Kiểu dữ liệu</th><th width="139" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Secretkey của tài khoản.</td></tr><tr><td>Phone</td><td>string</td><td>true</td><td>Số điện thoại người nhận code.</td></tr><tr><td>Code</td><td>string</td><td>true</td><td>Mã code cần check.</td></tr></tbody></table>

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
 "CodeResult": "100",
 "CountRegenerate": 0,
 "ErrorMessage": "0901888484, Content: Success!"
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

<table><thead><tr><th width="234">Thuốc tính </th><th width="165">Kiểu dữ liệu </th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Mã trả về.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi).</td></tr><tr><td>Content</td><td>string</td><td>Trạng thái của code.</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [**Link code mẫu**](https://samplefordevelopers.esms.vn/#62b4ccfb-c812-44f3-9cf5-e8c5b99e7b06)**.**


# Kết nối mã SVoucher


# Kết nối đầu số ngắn

## ***1: Thông tin kết nối:***

### **Bước 1:** Khi khách hàng gửi tin nhắn lên đầu số ngắn, phía eSMS sẽ gọi 1 request như bên dưới sang đối tác

{% code title="HTTP GET" overflow="wrap" fullWidth="false" %}

```http
http://domain.abc/receive_mo?sender={{sender}}&content={{content}}&serviceNumber={{serviceNumber}}&keyword={{keyword}}&sign={{sign}}&cpid={{cpid}}&smsid={{smsid}}&receiverTime={{receiverTime}}
```

{% endcode %}

Trong đó:

* `http://domain.abc/receive_mo` : là link mà đối tác cung cấp cho eSMS để nhận các tin nhắn MO từ khách hàng

<table><thead><tr><th width="198">Tham số</th><th width="120">Kiểu</th><th>Mô tả</th></tr></thead><tbody><tr><td><pre><code>cpid
</code></pre></td><td>string</td><td>Là mã định danh CP do eSMS cung cấp.<br>Bao gồm CPID và PrivateKey</td></tr><tr><td><pre><code>sign
</code></pre></td><td>string</td><td>chữ ký số, tạo bởi chuỗi bí mật của ứng dụng tương ứng cpid</td></tr><tr><td><pre><code>smsid
</code></pre></td><td>string</td><td>là một chuỗi do eSMS.vn cung cấp. Đây là số duy nhất tương ứng với một tin nhắn. Số này dùng để kiểm tra các trường hợp trùng và đối chiếu đối soát về sau.</td></tr><tr><td><pre><code>sender
</code></pre></td><td>string</td><td>số điện thoại khách hàng, định dạng quốc tế (có 84)</td></tr><tr><td><pre><code>serviceNumber
</code></pre></td><td>string</td><td>đầu số dịch vụ (8041, 8079, 6088, ...)</td></tr><tr><td><pre><code>keyword
</code></pre></td><td>string</td><td>từ đầu tiên trong cú pháp MO</td></tr><tr><td><pre><code>content
</code></pre></td><td>string</td><td>nội dung mà khách hàng nhắn</td></tr><tr><td><pre><code>receiverTime
</code></pre></td><td>string</td><td>Thời gian nhận được MO, có format yyyyMMddhhmmss</td></tr></tbody></table>

### **Bước 2:** Đối tác xử lý request này và trả về thông tin có dạng sau:

```
<ClientResponse>
   <Message>Nội dung tin nhắn trả về</Message>
   <Smsid>ID của tin nhắn gửi lên</Smdid>
   <Receiver>Số điện thoại người nhận</Receiver>
</ClientResponse>
```

## ***2. Tạo khóa bí mật:***

Sign: được băm từ 5 tham số: `Cpid`, `smsid`, `content`, `receiveTime` và `PrivateKey` \
hashValue(value1, value2,…) = MD5(value1 + value2 + … + private\_key) \
\
Ví dụ: đối tác A sử dụng dịch vụ X có khóa bí mật là 17417a0d20114d36a902e49cad0e97f3 thì giá trị băm được tính như sau: \
hash("abcdef", "1234", "xyz") = MD5("abcdef1234xyz17417a0d20114d36a902e49cad0e97f3");\
\
Format thời gian: giá trị thời gian được truyền dưới định dạng sau: `yyyyMMddhhmmss`. Ví dụ ngày 28 tháng 2 năm 2013, lúc 13 giờ 01 phút 01 giây: 20130228130101

### **Mã lệnh mẫu**

Trong việc giao tiếp giữa client và server, có một giá trị băm gửi gửi kèm để đảm bảo toàn bộ các thông tin là chính xác. Đoạn lệnh mẫu tính giá trị băm xin tham khảo dưới đây.

* **.NET**

```csharp
string GetHash(string s)
{
  UTF8Encoding ue = new UTF8Encoding();
  byte[] v = ue.GetBytes(s);
  byte[] hashValue = new MD5CryptoServiceProvider().ComputeHash(v);
  return Convert.ToBase64String(hashValue);
}
```

* **Java**

```java
String getHash(String sSrc) throws Exception {
  Charset utf8Charset = Charset.forName("UTF-8");
  byte[] textBytes = sSrc.getBytes(utf8Charset);
  MessageDigest m = MessageDigest.getInstance("MD5");
  byte[] digest = m.digest(textBytes);
  String sEncodedText = B64.b64encode(digest);
  return sEncodedText;
} 
```

* **PHP**

```php
<?php
    $str = 'qwertyuiop';
    $hash = base64_encode(md5($str, true));
?>
```


# Hàm gọi Voice


# Hàm tạo cuộc gọi voice OTP

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> [https://rest.esms.vn/MainService.svc/json/SendMultipleMessage\_V4\_post\_json/](http://rest.esms.vn/MainService.svc/json/SendMultipleMessage_V4_post_json/)<br>

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```
curl --location 'https://rest.esms.vn/MainService.svc/json/SendMultipleMessage_V4_post_json/' \
--header 'Content-Type: application/json' \
--data '{
   "ApiKey": "{{ApiKey}}",
   "Content": "{{Content}}",
   "Phone": "{{Phone}}",
   "SecretKey": "{{SecretKey}}",
   "SmsType": "8",
   "IsUnicode": {{IsUnicode}},
   "Sandbox": {{Sandbox}},
   "campaignid": "{{campaignid}}",
   "RequestId": "{{RequestId}}",
   "CallbackUrl": "{{CallbackUrl}}",
   "SendDate":{{SendDate}}
}'
```

* **Cấu trúc body của request:**

<table><thead><tr><th width="145">Tham số</th><th width="121">Kiểu dữ liệu</th><th width="147" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey eSMS cung cấp.</td></tr><tr><td>Content</td><td>string</td><td>true</td><td>Nội dung tin nhắn.</td></tr><tr><td>Phone</td><td>string</td><td>true</td><td>Số điện thoại nhận tin nhắn.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>SecretKey eSMS cung cấp.</td></tr><tr><td>SmsType</td><td>number</td><td>true</td><td>Loại tin nhắn<br>8: Tin Cố định giá rẻ</td></tr><tr><td>Unicode</td><td>number</td><td>false</td><td><p>Gửi nội dung có dấu<br>1: Có dấu.</p><p>0: Không dấu.</p></td></tr><tr><td>Sandbox</td><td>number</td><td>false</td><td>1: Tin gửi ở môi trường test, dùng để kiểm tra kết nối và các thông số tích hợp, không về tin nhắn <br>0: Tin gửi ở môi trường bình thường, có về tin nhắn.</td></tr><tr><td>campaignid</td><td>string</td><td>false</td><td>Tên chiến dịch.</td></tr><tr><td>RequestId</td><td>string</td><td>false</td><td>ID đối tác truyền sang để chặn trùng và đối soát khi cần.<br>Độ dài tối đa 50 ký tự.<br><strong>Mỗi RequestId truyền sang có hiệu lực chặn trong 24h.</strong></td></tr><tr><td>CallbackUrl</td><td>string</td><td>false</td><td>URL nhận kết quả gửi tin.</td></tr><tr><td>SendDate</td><td>string</td><td>false</td><td>Thời gian hẹn gửi của tin. <br>Không truyền khi tin muốn tin nhắn gửi đi liền.<br>Định dạng: yyyy-mm-dd hh:MM:ss</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

<table><thead><tr><th width="176">Thuộc tính</th><th width="178">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>string</td><td>Mã trả về.</td></tr><tr><td>SMSID</td><td>string</td><td>ID của tin nhắn mới được tạo ra trên hệ thống eSMS. Dùng ID này để query lấy trạng thái tin nhắn.</td></tr><tr><td>ErrorMessage</td><td>string</td><td>Thông tin lỗi trả về (nếu có lỗi).</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu của các ngôn ngữ ở link**</mark>**:*** [**Code mẫu**](https://samplefordevelopers.esms.vn/#562c21f1-e073-4352-8a24-eac62657953b) **.**


# Hàm tạo cuộc gọi tự động theo Template

Hàm cho phép bạn gửi tin nhắn thoại đến 1 số điện thoại bởi mẫu cuộc gọi đã được tạo sẵn trên hệ thống.

## HTTP request

\ <mark style="color:green;">**`GET`**</mark> [https://voiceapi.esms.vn/MainService.svc/json/MakeCallTemplate\_V2?ApiKey={{ApiKey}}\&SecretKey={{SecretKey}}\&TemplateId={{TemplateId}}\&Phone={{Phone}}\&VariableListStr={{VariableListStr}}\&SendDate={{SendDate}}\&Voice={{Voice}}\&Speed={{Speed}}\&CallbackUrl={{CallbackUrl}}\&RequestId={{RequestId}}](http://voiceapi.esms.vn/MainService.svc/json/MakeCallTemplate_V2?ApiKey={{ApiKey}}\&SecretKey={{SecretKey}}\&TemplateId={{TemplateId}}\&Phone={{Phone}}\&VariableListStr={{VariableListStr}}\&SendDate={{SendDate}}\&Voice={{Voice}}\&Speed={{Speed}}\&CallbackUrl={{CallbackUrl}}\&RequestId={{RequestId}})

* **Response Type:** <mark style="color:orange;">application/json</mark>

{% code overflow="wrap" %}

```
curl --location --globoff 'https://voiceapi.esms.vn/MainService.svc/json/MakeCallTemplate_V2?ApiKey={{ApiKey}}&SecretKey={{SecretKey}}&TemplateId={{TemplateId}}&Phone={{Phone}}&VariableListStr={{VariableListStr}}&SendDate={{SendDate}}&Voice={{Voice}}&Speed={{Speed}}&CallbackUrl={{CallbackUrl}}&RequestId={{RequestId}}'
```

{% endcode %}

* **Cấu trúc body của request::**

<table><thead><tr><th width="169">Tham số</th><th width="143">Kiểu dữ liệu</th><th width="134" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Secretkey của tài khoản</td></tr><tr><td>TemplateId</td><td>string</td><td>true</td><td>Id kịch bản cuộc gọi đăng ký trên trang account.esms.vn</td></tr><tr><td>Phone</td><td>string</td><td>true</td><td>Số điện thoại nhận tin</td></tr><tr><td>VariableListStr</td><td>string</td><td>false</td><td>Chuỗi biến chứa danh sách giá trị các biến của mẫu cuộc gọi, cách nhau bởi dấu “||”, thứ tự các biến từ trái sang phải. Ví dụ: Trung||20000 (Giá trị biến 1: Trung, Giá trị biến 2: 20000)</td></tr><tr><td>SendDate</td><td>string</td><td>false</td><td>Đặt lịch gửi tin (định dạng: yyyy/MM/dd hh:mm:ss) Ví dụ: 2017/12/12 14:00:00</td></tr><tr><td>Voice</td><td>string</td><td>false</td><td><p></p><p>Giọng đọc biến, có các giá trị sau đây:</p><ul><li>male: giọng nam miền Bắc</li><li>female: giọng nữ miền Bắc</li><li>hatieumai: giọng nữ miền Nam</li><li>ngoclam: giọng nữ Huế</li></ul></td></tr><tr><td>Speed</td><td>string</td><td>false</td><td><p></p><p>Tốc độ đọc biến, có các giá trị sau đây:</p><ul><li>-3: rất chậm</li><li>-2: khá chậm</li><li>-1: chậm</li><li>0: bình thường</li><li>1: nhanh</li><li>2: khá nhanh</li><li>3: rất nhanh</li></ul></td></tr><tr><td>RequestId</td><td>string</td><td>false</td><td>ID đối tác truyền sang để chặn trùng và đối soát khi cần.<br>Độ dài tối đa 50 ký tự.<br><strong>Mỗi RequestId truyền sang có hiệu lực chặn trong 24h.</strong></td></tr><tr><td>CallbackUrl</td><td>string (<em>URL Encode</em>)</td><td>false</td><td><p></p><p>Url nhận callback kết quả cuộc gọi (mẫu: <code>https://{{Your_API_Domain}}/Esms/ReceiveVocieCallback?ReferenceId=&#x26;CallDuration=&#x26;CallStatus=&#x26;Ivr=&#x26;Price=&#x26;SentResult=&#x26;CID=&#x26;SendStatus=</code>)</p><ul><li><strong>CallDuration</strong>: độ dài cuộc gọi</li><li><strong>CallStatus</strong>: kết quả cuộc gọi (ANSWERED, NO ANSWER)</li><li><strong>Ivr</strong>: phím bấm của khách hàng</li><li><strong>Price</strong>: giá cuộc gọi</li><li><strong>SentResult</strong>: Kết quả gửi tin qua nhà mạng (0: thất bại, 1: thành công)</li><li><strong>CID</strong>: đầu số gửi tin</li><li><strong>SendStatus</strong>: Trạng thái cuộc gọi: </li></ul><p>            2: Chờ gửi.</p><p>            5: Đã gửi xong.</p><p>            7: Đã gửi chờ báo cáo.</p><p></p><p><strong>Yêu cầu phản hồi</strong>:</p><p>Khi đối tác nhận được dữ liệu, vui lòng trả về trạng thái <strong><code>HTTP_STATUS_CODE=200</code></strong> để xác nhận với ESMS là thành công.</p><p>Nếu không nhận được HTTP_STATUS_CODE 200, ESMS sẽ tiến hành gửi lại tối đa 5 lần.<br><br><em>Ví dụ</em>:<br><code>curl --location --globoff --request GET 'https://{{Your_API_Domain}}/Esms/ReceiveVocieCallback?ReferenceId=066107ee-6ec4-4283-b595-aa74977c65c5&#x26;CallDuration=0&#x26;CallStatus=&#x26;Ivr=&#x26;Price=0.0000&#x26;SentResult=0&#x26;CID=02871002454&#x26;SendStatus=5'</code><br></p></td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
 "CodeResult": "100",
 "SMSID": "8eb2af6d-fb4c4814-b9cc-4c0e3ed32edf "
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

<pre class="language-json"><code class="lang-json"><strong>{
</strong>    "CodeResult": "101",
    "ErrorMessage": "Authorize Failed"
}
</code></pre>

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}

{% tab title="104" %}

```json
{
    "CodeResult": "104",
    "ErrorMessage": "Template not found"
}
```

TemplateId không tổng
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

| Thuộc tính | Kiểu dữ liệu | Mô tả                                                                                             |
| ---------- | ------------ | ------------------------------------------------------------------------------------------------- |
| CodeResult | string       | Mã trả về.                                                                                        |
| SMSID      | string       | ID của cuộcgoji mới được tạo ra trên hệ thống eSMS. Dùng ID này để query lấy trạng thái cuộc gọi. |

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [**Link code mẫu**](https://samplefordevelopers.esms.vn/#9b15367f-ff51-4cf4-9769-455cbdcec284)**.**


# Hàm tạo cuộc gọi tự động từ file ghi âm

Hàm cho phép bạn gửi tin nhắn thoại đến 1 số điện thoại bởi file ghi âm đã tạo.

## HTTP request

\ <mark style="color:green;">**`GET`**</mark> [https://voiceapi.esms.vn/MainService.svc/json/MakeCallRecord\_V2?ApiKey={{ApiKey}}\&SecretKey={{SecretKey}}\&TemplateId={{RecordId}}\&Phone={{Phone}}\&SendDate={{SendDate}}\&NumberForward={{NumberForward}}\&MaxRepeat={{MaxRepeat}}\&MaxRetry={{MaxRetry}}\&Ivr={{Ivr}}\&TimeWaitToIvr={{TimeWaitToIvr}}\&WaitRetry={{WaitRetry}}\&CallbackUrl={{CallbackUrl}}\&RequestID={{RequestId}}](http://voiceapi.esms.vn/MainService.svc/json/MakeCallRecord_V2?ApiKey={{ApiKey}}\&SecretKey={{SecretKey}}\&TemplateId={{RecordId}}\&Phone={{Phone}}\&SendDate={{SendDate}}\&NumberForward={{NumberForward}}\&MaxRepeat={{MaxRepeat}}\&MaxRetry={{MaxRetry}}\&Ivr={{Ivr}}\&TimeWaitToIvr={{TimeWaitToIvr}}\&WaitRetry={{WaitRetry}}\&CallbackUrl={{CallbackUrl}}\&RequestID={{RequestId}})[](<http://voiceapi.esms.vn/MainService.svc/json&#xD;&#xA;/MakeCallTemplate_V2?ApiKey={ApiKey}\&SecretKey={SecretKey}\&TemplateId={TemplateI&#xD;&#xA;d}\&Phone={Phone}\&VariableListStr={VariableListStr}\&SendDate={SendDate}&#xD;&#xA;\&Voice={Voice}\&Speed={Speed}\&CallbackUrl={CallbackUrl}\&RequestId={RequestId}&#xD;>)<br>

* **Response Type:** <mark style="color:orange;">application/json</mark>

{% code overflow="wrap" %}

```
curl --location --globoff 'https://voiceapi.esms.vn/MainService.svc/json/MakeCallRecord_V2?ApiKey={{ApiKey}}&SecretKey={{SecretKey}}&TemplateId={{RecordId}}&Phone={{Phone}}&SendDate={{SendDate}}&NumberForward={{NumberForward}}&MaxRepeat={{MaxRepeat}}&MaxRetry={{MaxRetry}}&Ivr={{Ivr}}&TimeWaitToIvr={{TimeWaitToIvr}}&WaitRetry={{WaitRetry}}&CallbackUrl={{CallbackUrl}}&RequestID={{RequestId}}'
```

{% endcode %}

* **Cấu trúc body của request:**

<table><thead><tr><th width="202">Tham số</th><th width="137">Kiểu dữ liệu</th><th width="137" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Secretkey của tài khoản</td></tr><tr><td>TemplateId</td><td>string</td><td>true</td><td>Id file ghi âm tạo trên trang account.esms.vn</td></tr><tr><td>Phone</td><td>string</td><td>true</td><td>Số điện thoại nhận tin</td></tr><tr><td>NumberForward</td><td>string</td><td>false</td><td>Số điện thoại được chuyển đến khi nhập đúng Ivr</td></tr><tr><td>SendDate</td><td>string</td><td>false</td><td>Đặt lịch gửi tin (định dạng: yyyy/MM/dd hh:mm:ss) Ví dụ: 2017/12/12 14:00:00</td></tr><tr><td>MaxRepeat</td><td>string</td><td>false</td><td>Số lần lặp lại file ghi âm khi nghe</td></tr><tr><td>MaxRetry</td><td>string</td><td>false</td><td>Số lần gọi lại khi người nhận không bắt máy</td></tr><tr><td>Ivr</td><td>string</td><td>false</td><td>Phím quy định khi người nhận bấm để chuyển số (phím từ: 0-9)</td></tr><tr><td>TimeWaitToIvr</td><td>string</td><td>false</td><td>Thời gian chờ tối đa để người gọi nhấn phím</td></tr><tr><td>WaitRetry</td><td>string</td><td>false</td><td>Khoảng cách giữa các lần gọi lại khi người nhận không bắt máy (đơn vị: giây)</td></tr><tr><td>CallbackUrl</td><td>string (<em>URL Encode</em>)</td><td>false</td><td><p></p><p>Url nhận callback kết quả cuộc gọi (mẫu: <code>https://{{Your_API_Domain}}/Esms/ReceiveVocieCallback?ReferenceId=&#x26;CallDuration=&#x26;CallStatus=&#x26;Ivr=&#x26;Price=&#x26;SentResult=&#x26;CID=&#x26;SendStatus=</code>)</p><ul><li><strong>CallDuration</strong>: độ dài cuộc gọi</li><li><strong>CallStatus</strong>: kết quả cuộc gọi (ANSWERED, NO ANSWER)</li><li><strong>Ivr</strong>: phím bấm của khách hàng</li><li><strong>Price</strong>: giá cuộc gọi</li><li><strong>SentResult</strong>: Kết quả gửi tin qua nhà mạng (0: thất bại, 1: thành công)</li><li><strong>CID</strong>: đầu số gửi tin</li><li><strong>SendStatus</strong>: Trạng thái cuộc gọi: </li></ul><p>            2: Chờ gửi.</p><p>            5: Đã gửi xong.</p><p>            7: Đã gửi chờ báo cáo.</p><p></p><p><strong>Yêu cầu phản hồi</strong>:</p><p>Khi đối tác nhận được dữ liệu, vui lòng trả về trạng thái <strong><code>HTTP_STATUS_CODE=200</code></strong> để xác nhận với ESMS là thành công.</p><p>Nếu không nhận được HTTP_STATUS_CODE 200, ESMS sẽ tiến hành gửi lại tối đa 5 lần.<br><br><em>Ví dụ</em>:<br><code>curl --location --globoff --request GET 'https://{{Your_API_Domain}}/Esms/ReceiveVocieCallback?ReferenceId=066107ee-6ec4-4283-b595-aa74977c65c5&#x26;CallDuration=0&#x26;CallStatus=&#x26;Ivr=&#x26;Price=0.0000&#x26;SentResult=0&#x26;CID=02871002454&#x26;SendStatus=5'</code><br></p></td></tr><tr><td>RequestId</td><td>string</td><td>false</td><td>ID đối tác truyền sang để chặn trùng và đối soát khi cần.<br>Độ dài tối đa 50 ký tự.<br><strong>Mỗi RequestId truyền sang có hiệu lực chặn trong 24h.</strong></td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
 "CodeResult": "100",
 "SMSID": "8eb2af6d-fb4c4814-b9cc-4c0e3ed32edf "
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

<table><thead><tr><th width="213">Thuộc tính</th><th width="168">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CodeResult</td><td>String</td><td>Mã trả về.</td></tr><tr><td>SMSID</td><td>String</td><td>ID tin nhắn do esms trả về.</td></tr><tr><td>ErrorMessage</td><td>String</td><td>Thông tin lỗi trả về (nếu có lỗi).</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [**Link code mẫu**](https://samplefordevelopers.esms.vn/#bd90912f-439a-4c8e-a741-914b7fc36cde)**.**


# Hàm lấy trạng thái cuộc gọi

Hàm cho phép bạn gửi tin nhắn thoại đến 1 số điện thoại bởi file ghi âm đã tạo.

## HTTP request

\ <mark style="color:green;">**`GET`**</mark> <https://voiceapi.esms.vn/MainService.svc/json/GetSendStatus?ApiKey={{ApiKey}}&SecretKey={{SecretKey}}&ReferenceId={{SMSID}}>

* **Response Type:** <mark style="color:orange;">application/json</mark>

{% code overflow="wrap" %}

```
curl --location -g 'https://voiceapi.esms.vn/MainService.svc/json/MakeCallRecord_V2?ApiKey={{ApiKey}}&SecretKey={{SecretKey}}&TemplateId={{RecordId}}&Phone={{Phone}}&SendDate={{SendDate}}&NumberForward={{NumberForward}}&MaxRepeat={{MaxRepeat}}&MaxRetry={{MaxRetry}}&Ivr={{Ivr}}&TimeWaitToIvr={{TimeWaitToIvr}}&WaitRetry={{WaitRetry}}&CallbackUrl={{CallbackUrl}}&RequestID={{RequestId}}'
```

{% endcode %}

* **Cấu trúc body của request:**

<table><thead><tr><th width="157">Tham số</th><th width="141">Kiểu dữ liệu</th><th width="129" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>ApiKey của tài khoản.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Secretkey của tài khoản.</td></tr><tr><td>ReferenceId</td><td>string</td><td>true</td><td>SMSID khi gọi trả về.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CallDuration": 13,
    "CallStatus": "ANSWERED",
    "CodeResponse": "100",
    "Ivr": "",
    "ReferenceId": "505139D7-54F8-48A9-88FA-9460A78731DD",
    "SendStatus": 5,
    "SentResult": 1
}
```

**Request hợp lệ.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Sai thông tin ApiKey/SecretKey.**
{% endtab %}
{% endtabs %}

* **Cấu trúc body của response:**

<table><thead><tr><th width="193">Thuộc tính</th><th width="203">Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>CallDuration</td><td>string</td><td>ID của cuộcgoji mới được tạo ra trên hệ thống eSMS. Dùng ID này để query lấy trạng thái cuộc gọi.</td></tr><tr><td>CallStatus</td><td>string</td><td>Kết quả của cuộc gọi (ANSWERED: cuộc gọi được trả lời, NOANSWERED: cuộc gọi thất bại hoặc không ai bắt máy).</td></tr><tr><td>Ivr</td><td>string</td><td>Phím phản hồi của người nghe.</td></tr><tr><td>ReferenceId</td><td>string</td><td>SMSID tin nhắn check trạng thái.</td></tr><tr><td>SendStatus</td><td>string</td><td>Trạng thái tin nhắn<br>5: Đã gửi xong.</td></tr><tr><td>SentResult</td><td>string</td><td>Kết quả tin nhắn<br>0: Thất bại.<br>1: Thành công.</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/esms-api/bang-ma-loi) **.**
* *<mark style="color:yellow;">**Lấy code mẫu các ngôn ngữ trên Postman:**</mark>* [**Link code mẫu**](https://samplefordevelopers.esms.vn/#92d7042b-06f1-41c4-85f8-91a1d976944d)**.**


# Bảng mã lỗi

<table><thead><tr><th width="103.4444580078125">Mã lỗi</th><th width="344">Thông tin lỗi</th><th>Loại tin áp dụng</th></tr></thead><tbody><tr><td>99</td><td>Số điện thoại bị chặn trên hệ thống.</td><td>Tất cả loại tin</td></tr><tr><td>100</td><td>Request được gửi đến ViHAT thành công.<br><br><strong>Lưu ý:</strong> Mã phản hồi <strong>100</strong> chỉ xác nhận rằng yêu cầu đã được gửi thành công đến hệ thống ESMS, <strong>không phản ánh việc tin nhắn đã được gửi đến số điện thoại người nhận hay chưa</strong>.<br>Để theo dõi trạng thái cuối cùng của tin nhắn, quý khách vui lòng truyền thêm tham số <strong>CallbackUrl</strong>; hệ thống ESMS sẽ tự động gửi phản hồi (callback) đến địa chỉ này khi có trạng thái cuối của tin.</td><td>Tất cả loại tin</td></tr><tr><td>101</td><td>Sai thông tin ApiKey hoặc SecretKey.</td><td>Tất cả loại tin</td></tr><tr><td>102</td><td>Không có bảng giá.</td><td>Tất cả loại tin</td></tr><tr><td>103</td><td>Không đủ số dư để gửi tin.</td><td>Tất cả loại tin</td></tr><tr><td>104</td><td>Brandname/ Mã cuộc gọi không tồn tại.</td><td><p>Tin chăm sóc khách hàng</p><p>Tin quảng cáo<br>Gọi voice theo kịch bản<br>Gọi voice theo template</p></td></tr><tr><td>105</td><td>Không tìm thấy mã tin nhắn/ Mã cuộc gọi trên hệ thống. Kiểm tra lại SMSID hoặc thử lại sau (mới gửi tin sẽ không call api lấy trạng thái ngay được)<br></td><td>Hàm kiểm tra trạng thái tin nhắn theo khoảng thời gian<br>Hàm kiểm tra tin nhắn theo SMSID<br>Hàm kiểm tra chi tiết từng số trong tin nhắn.</td></tr><tr><td>106</td><td>File ghi âm không tồn tại.</td><td>Gọi voice theo kịch bản<br>Gọi voice theo template</td></tr><tr><td>107</td><td>Mỗi request phải có ít nhất 30 số điện thoại (không trùng nhau).</td><td>Tin quảng cáo</td></tr><tr><td>108</td><td>Số điện thoại không đúng định dạng.</td><td>Tất cả loại tin</td></tr><tr><td>110</td><td>Dữ liệu yêu cầu không đúng.</td><td>Tin Zalo mỗi khách hàng một nội dung</td></tr><tr><td>115</td><td>Dữ liệu hashphone không đúng.</td><td>Tin nhắn Zalo sử dụng hashphone</td></tr><tr><td>118</td><td>Loại tin nhắn không hỗ trợ.</td><td>Tất cả loại tin</td></tr><tr><td>120</td><td>Danh sách số điện thoại gửi tin vượt quá giới hạn.</td><td>Tin Quảng cáo</td></tr><tr><td>124</td><td>Trùng RequestId khi gửi tin.</td><td>Tất cả loại tin</td></tr><tr><td>140</td><td>IP chưa được whitelist để gửi tin. Vui lòng cung cấp IP cho Sale/CSKH để được whitelist.</td><td>Tất cả loại tin</td></tr><tr><td>143</td><td>Tài khoản của bạn chưa kích hoạt hoặc bị khóa.</td><td>Tất cả loại tin</td></tr><tr><td>146</td><td>Sai template chăm sóc khách hàng. Liên hệ Sale/CSKH để được hỗ trợ.</td><td>Tin chăm sóc khách hàng.</td></tr><tr><td>160</td><td>Vượt giới hạn TPS</td><td>Hàm lấy thông tin trạng thái ZNS</td></tr><tr><td>163</td><td>Danh sách số điện thoại gửi tin vượt quá giới hạn ( 1 SĐT/request)</td><td>Tin Cố định giá rẻ</td></tr><tr><td>171</td><td>Mã đã được sử dụng, mã hết hạn hoặc mã không áp dụng cho số điện thoại cần check.</td><td>Hàm check code</td></tr><tr><td>177</td><td>Nhà mạng chưa được đăng ký.</td><td>Tin chăm sóc khách hàng</td></tr><tr><td>199</td><td>Yêu cầu này đã tồn tại, đang xử lý</td><td>Hàm đăng ký mua gói OA<br>Hàm đăng ký template SMS<br>Hàm đăng ký template Zalo</td></tr><tr><td>201</td><td>Nội dung có chứa từ khóa chặn.</td><td>Tin chăm sóc khách hàng</td></tr><tr><td>204</td><td>OAID không tồn tại trên hệ thống.</td><td><p>Tin Zalo</p><p>Tin Zalo tư vấn<br>Tin Zalo giao dịch</p></td></tr><tr><td>210</td><td>Không đúng payload theo quy định.</td><td>Tin Zalo tư vấn<br>Tin Zalo giao dịch</td></tr><tr><td>300</td><td>Thiếu loại tin nhắn.</td><td>Tin Chăm sóc khách hàng<br>Tin Quảng cáo<br>Tin Viber</td></tr><tr><td>301</td><td>Mã của loại dịch vụ chưa hỗ trợ.</td><td>Hàm đăng ký template SMS</td></tr><tr><td>687</td><td>Danh sách yêu cầu vượt quá 500 số điện thoại.</td><td>Tin Zalo mỗi khách hàng một nội dung</td></tr><tr><td>789</td><td>Template chưa được cấu hình cho OA ID bạn đang sử dụng.</td><td>Tin Zalo<br>Tin Zalo tư vấn<br>Tin Zalo giao dịch</td></tr><tr><td>790</td><td>Sai template ZNS.</td><td>Tin Zalo</td></tr><tr><td>791</td><td>Thiếu OA ID hoặc Template ID.</td><td>Tin Zalo</td></tr><tr><td>799</td><td>OAID không active - OAID Sai - OAID chưa được add vào tài khoản.</td><td>Tin Zalo</td></tr><tr><td>801</td><td>Gửi tin chế độ Gửi vượt hạn mức không cho phép gửi tin hẹn giờ.</td><td>Tin Zalo</td></tr><tr><td>802</td><td>OA chưa được phép gửi tin chế độ Gửi vượt hạn mức.</td><td>Tin Zalo</td></tr><tr><td>851</td><td>Thiếu MessageId hoặc SMSID</td><td>Hàm lấy thông tin trạng thái ZNS<br>Hàm kiểm tra trạng thái tin nhắn Zalo</td></tr><tr><td>854</td><td>Không tìm thấy dữ liệu</td><td>Hàm kiểm tra trạng thái tin nhắn Zalo</td></tr></tbody></table>


# Môi trường test ( Sandbox)

* Để gửi tin ở môi trường thử nghiệm, eSMS đã cung cấp cho khách hàng môi trường test tin. Khách hàng truyền thêm trường Sandbox vào body gửi. Tin nhắn sẽ **không được lưu ở hệ thống eSMS, không tính phí và không về máy khách hàng.**
* Truyền Sandbox = 1 cho các api có hỗ trợ môi trường Sandbox.

## **Body mẫu cho gửi thử nghiệm tin nhắn Chăm sóc khách hàng:**

{% code overflow="wrap" %}

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/SendMultipleMessage_V4_post_json/' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey": "{{ApiKey}}",
    "Content": "Cam on quy khach da su dung dich vu cua chung toi. Chuc quy khach mot ngay tot lanh!",
    "Phone": "{{Phone}}",
    "SecretKey": "{{SecretKey}}",
    "Brandname": "Baotrixemay",
    "SmsType": "2",
    "Sandbox": "1"
}'
```

{% endcode %}

## **Body mẫu cho gửi thử nghiệm tin nhắn Zalo:**

{% code overflow="wrap" %}

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/SendZaloMessage_V5_post/' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey": "{{ApiKey}}",
    "SecretKey": "{{SecretKey}}",
    "OAID": "4097311281936189049",
    "Phone": "{{Phone}}",
    "TempData": [
        {
            "key": "otp",
            "value": "686868"
        }
    ],
    "TempID": "205644",
    "Sandbox": "1"
}'
```

{% endcode %}

## Body mẫu cho gửi thử nghiệm tin nhắn Viber:

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/Send_Multiple_Sms_OTT/' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey": "{{ApiKey}}",
    "SecretKey": "{{SecretKey}}",
    "Brandname": "BAT DONG SAN GIA TOT",
    "SmsType": "23",
    "Content": "Chúng tôi vừa mở bán căn hộ ĐẸP NHẤT thuộc siêu dự án- Đất nền sổ đỏ sở hữu lâu dài.",
    "OttImgUrl": "https://freesms.vn/wp-content/uploads/2021/07/esms-la-gi.png",
    "OttLabel": "eSMS.vn",
    "OttUrl": "https://esms.vn",
    "Phones": [
        "{{Phones}}"
    ],
    "IsSandBox": "1"
}'
```

## Body mẫu cho gửi thử nghiệm tin nhắn Quảng cáo:

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/SendMultipleSMSBrandname_json/' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey":"{{ApiKey}}",
    "SecretKey":"{{SecretKey}}",
    "Content":"TEST SANDBO",
    "SmsType":"1",
    "Brandname":"Svoucher",
    "Phones":["{{Phones1}}","{{Phones2}}","{{Phones3}}"],
    "Sandbox":"1"
}'
```


# Callback Url

* Khi có trạng thái thực tế của tin nhắn, eSMS sẽ gửi callback trạng thái về endpoint (webhook) của khách hàng thông qua phương thức **HTTPS&#x20;**<mark style="color:green;">**GET**</mark>.
* Callback sẽ được retry 5 lần nếu như url của khách hàng trả timeout. Hết 5 lần mà url của khách hàng vẫn timeout thì sẽ ngừng callback.
* Danh sách IP của eSMS dùng để thực hiện callback: \
  &#x20;\+ 103.29.26.39\
  &#x20;\+ 103.29.26.80\
  &#x20;\+ 103.29.27.39<br>

## Callback mẫu

### Callback mẫu cho loại tin CSKH:

{% code overflow="wrap" %}

```json
curl --location -g 'https://{{yourportalreceivecallback}}?SMSID=dc712784-9c5f-4c69-b9a8-ea69d56adc9a87&SendFailed=2&SendStatus=5&SendSuccess=0&TotalPrice=0.0000&TotalReceiver=2&TotalSent=2&RequestId=&TypeId=2&telcoid=1&phonenumber=0901888484&switchsmsid='
```

{% endcode %}

### Callback mẫu cho loại tin Quảng cáo:

{% code overflow="wrap" %}

```
curl --location -g 'https://{{yourportalreceivecallback}}?SMSID=82b0bb8aed914a0aab8deba567c9b8c2&SendFailed=0&SendStatus=5&SendSuccess=0&TotalPrice=696987.0000&TotalReceiver=169&TotalSent=169&RequestId=&TypeId=1'
```

{% endcode %}

### Callback mẫu cho loại tin Zalo:

{% code overflow="wrap" %}

```json
curl --location -g 'https://{{yourportalreceivecallback}}?SMSID=f66545d2-c7e2-4603-984e-d2238c363c8292&SendFailed=1&SendStatus=5&SendSuccess=0&TotalPrice=0.0000&TotalReceiver=1&TotalSent=0&RequestId=&TypeId=25&telcoid=2&phonenumber=0901888484&partnerids=&error_info=%22{%5C%22error%5C%22%3A-114%2C%5C%22message%5C%22%3A%5C%22User%20is%20inactive%2C%20or%20reject%20the%20message%2C%20or%20using%20an%20outdated%20Zalo%20version%2C%20or%20other%20internal%20errors%5C%22}%22&oaid=1397492183140006179&tempid=2056446'
```

{% endcode %}

### Callback mẫu cho loại tin Viber:

{% code overflow="wrap" %}

```json
curl --location -g 'https://{{yourportalreceivecallback}}?SMSID=849fe08c19294b02857cf91687021a50250&SendFailed=0&SendStatus=5&SendSuccess=1&TotalPrice=470.0000&TotalReceiver=1&TotalSent=1&RequestId=&TypeId=23&telcoid=2&phonenumber=0901888484'
```

{% endcode %}

### Callback mẫu cho loại tin Zalo tư vấn:

{% code overflow="wrap" %}

```json
curl --location -g 'https://{{yourportalreceivecallback}}?SMSID=7d11c87a22934df390f73ec59d8defd6205&SendFailed=0&SendStatus=5&SendSuccess=1&TotalPrice=60.0000&TotalReceiver=1&TotalSent=1&RequestId=&TypeId=26&phonenumber=312158068343230&error_info=%257B%2522data%2522%3A%257B%2522message_id%2522%3A%2522e1a60e8890be9de4c4ab%2522%2C%2522user_id%2522%3A%252231215806834323092%2522%257D%2C%2522error%2522%3A0%2C%2522message%2522%3A%2522Success%2522%257D____24%2F04%2F2024%252016%3A58%3A01&oaid=4097311281936189049&partnerids=e1a60e8890be9de4c4ab'
```

{% endcode %}

### Callback mẫu cho loại tin Zalo giao dịch:

{% code overflow="wrap" %}

```json
curl --location -g 'https://{{yourportalreceivecallback}}?SMSID=53dbbc6e816f4159a9035a14a787e08f172&SendFailed=0&SendStatus=5&SendSuccess=1&TotalPrice=60.0000&TotalReceiver=1&TotalSent=1&RequestId=&TypeId=26&phonenumber=312158068343230&error_info=%257B%2522data%2522%3A%257B%2522message_id%2522%3A%2522f405841b5f2352790b36%2522%2C%2522user_id%2522%3A%252231215806834323092%2522%257D%2C%2522error%2522%3A0%2C%2522message%2522%3A%2522Success%2522%257D____24%2F04%2F2024%252017%3A07%3A01&oaid=4097311281936189049&partnerids=f405841b5f2352790b36'
```

{% endcode %}

### Callback mẫu cho loại tin Zalo dạng yêu cầu mẫu thông tin người dùng:

{% code overflow="wrap" %}

```json
curl --location -g 'https://{{yourportalreceivecallback}}?SMSID=53dbbc6e816f4159a9035a14a787e08f172&SendFailed=0&SendStatus=5&SendSuccess=1&TotalPrice=60.0000&TotalReceiver=1&TotalSent=1&RequestId=&TypeId=26&phonenumber=312158068343230&error_info=%257B%2522data%2522%3A%257B%2522message_id%2522%3A%2522f405841b5f2352790b36%2522%2C%2522user_id%2522%3A%252231215806834323092%2522%257D%2C%2522error%2522%3A0%2C%2522message%2522%3A%2522Success%2522%257D____24%2F04%2F2024%252017%3A07%3A01&oaid=4097311281936189049&partnerids=f405841b5f2352790b36'
```

{% endcode %}

### Callback mẫu cho loại tin Zalo hành trình

{% code overflow="wrap" %}

```json
curl --location -g 'https://{{yourportalreceivecallback}}?SMSID=7d11c87a22934df390f73ec59d8defd6205&SendFailed=0&SendStatus=5&SendSuccess=1&TotalPrice=220.0000&TotalReceiver=1&TotalSent=1&RequestId=&TypeId=27&phonenumber=312158068343230&error_info=%257B%2522data%2522%3A%257B%2522message_id%2522%3A%2522e1a60e8890be9de4c4ab%2522%2C%2522user_id%2522%3A%252231215806834323092%2522%257D%2C%2522error%2522%3A0%2C%2522message%2522%3A%2522Success%2522%257D____24%2F04%2F2024%252016%3A58%3A01&oaid=4097311281936189049&partnerids=e1a60e8890be9derir3gfbff'
```

{% endcode %}

### **Callback mẫu cho loại tin Zalo gửi bằng UID**

{% code overflow="wrap" %}

```
curl --location --globoff 'https://{{yourportalreceivecallback}}?SMSID=5450d5579bfa466a9f2a5911c82f4037&SendFailed=0&SendStatus=5&SendSuccess=1&TotalPrice=2104.0000&TotalReceiver=1&TotalSent=1&RequestId=&TypeId=25&telcoid=9&phonenumber=5308693166941955879&error_info={%22error%22%3A0%2C%22message%22%3A%22Success%22%2C%22data%22%3A{%22delivery_time%22%3Anull%2C%22message%22%3A%22The%20message%20was%20delivered%20to%20the%20user%27s%20phone%22%2C%22status%22%3A1}}&oaid=3639635426588416370&tempid=523194&partnerids=416f53d0cf0ec7569e19'
```

{% endcode %}

## Thông tin kết quả trả về của callback:

<table><thead><tr><th width="138.5999755859375">Thuộc tính</th><th width="112.199951171875">Kiểu dữ liệu</th><th>Định nghĩa</th></tr></thead><tbody><tr><td>SMSID</td><td>string</td><td>Mã tin nhắn.</td></tr><tr><td>SendFailed</td><td>string</td><td>Số lượng tin nhắn thất bại.</td></tr><tr><td>SendStatus</td><td>string</td><td>Trạng thái tin nhắn<br>1: Chờ duyệt.<br>2: Chờ gửi.<br>4: Từ chối.<br>5: Đã gửi xong (<strong>Kiểm tra thêm SendSuccess/SendFailed để biết tin gửi thành công hay thất bại</strong>).<br>7: Đã gửi chờ báo cáo.</td></tr><tr><td>SendSuccess</td><td>string</td><td>Số lượng tin thành công.</td></tr><tr><td>Totalprice</td><td>string</td><td>Tổng tiền đơn.</td></tr><tr><td>TotalReceiver</td><td>string</td><td>Tổng số người nhận.</td></tr><tr><td>TotalSent</td><td>string</td><td>Tổng số lượng tin được gửi.</td></tr><tr><td>RequestId</td><td>string</td><td>Mã request của khách hàng.</td></tr><tr><td>TypeId</td><td>string</td><td>Loại tin nhắn<br>1: tin quảng cáo.<br>2: tin chăm sóc khách hàng.<br>23: tin viber.<br>24: tin zalo ưu tiên.<br>25: tin zalo bình thường.</td></tr><tr><td>telcoid</td><td>string</td><td>Nhà mạng<br>1: Viettel, 2: Mobi, 3: Vina, 4: Vietnammobile, 5: Gtel, 6: Itel, 7: Reddi.</td></tr><tr><td>phonenumber</td><td>string</td><td>Số điện thoại người nhận.<br><br>Riêng đối với <a href="https://developers.esms.vn/esms-api/ham-gui-tin/tin-nhan-zalo-1">API gửi tin Zalo bằng UID</a> thì trường này là zalo userid của người nhận.</td></tr><tr><td>partnerids</td><td>string</td><td>Mã giao dịch của Zalo <strong>(chỉ có đối với tin zalo).</strong></td></tr><tr><td>error_info</td><td>string</td><td>Mã lỗi của tin nhắn <strong>(chỉ có đối với tin zalo).</strong></td></tr><tr><td>oaid</td><td>string</td><td>ID của Oa gửi tin <strong>(chỉ có đối với tin zalo).</strong></td></tr><tr><td>tempid</td><td>string</td><td>Tempid gửi tin <strong>(chỉ có đối với tin zalo).</strong></td></tr></tbody></table>


# Overview

Website: <https://esms.vn/>

![](/files/J3w3AfewZVVjq5R4BRAz)

Detail service

<div><figure><img src="/files/cWUihdrPALuCXztWXKI0" alt=""><figcaption></figcaption></figure> <figure><img src="/files/RjYCY70U2mhBMG5aQxhL" alt=""><figcaption></figcaption></figure> <figure><img src="/files/B7reH9gBYl5KdUHvdytM" alt=""><figcaption></figcaption></figure></div>


# Getting started

* If your website or system requires the capability to send messages via SMS/Zalo/Viber for scenarios like confirming registration codes on the website or notifying staff of meetings and birthdays, then we can help you get started.
* The eSMS API system is designed to meet your needs, ensuring fast, simple, and seamless integration with any system while providing a reliable and trusted solution relevant to many languages such as C#, Java, and PHP.


# Mechanism

Messages can be sent over the HTTP protocol using both POST and GET methods.

Every request will be authenticated using a pair of keys known as APIKEY and SECRETKEY, which will be provided after you register an account at eSMS.vn.


# Access to the API information

Before you get started, please create an account at eSMS.vn at access to the API information page to get the keys. After successfully, you will have 5000 VND for trial.

![Access to API mangement.](/files/Cr68WnS3DCqYjrYZ9nFZ)

![Use the pair of keys shown on the page or you can re-create the new keys.](/files/6m3K7RpJfCWadB2cOhRl)


# Send SMS API


# Send OTP/Customer care message

Sending a POST request on this endpoint allows to send SMS individually (1 request per SMS).&#x20;

It is ideal to send single personalized messages for use-cases like notifications or alerts.

## HTTP request

<mark style="color:yellow;">**`POST`**</mark> **<https://rest.esms.vn/MainService.svc/json/SendMultipleMessage\\_V4\\_post\\_json/>**

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location --request POST 'https://rest.esms.vn/MainService.svc/json/SendMultipleMessage_V4_post_json/' \
--header 'Content-Type: application/json' \
--data-raw '{
   "ApiKey": "{{ApiKey}}",
   "Content": "{{Content}}",
   "Phone": "{{Phone}}",
   "SecretKey": "{{SecretKey}}",
   "Brandname": "{{Brandname}}",
   "SmsType": "2",
   "IsUnicode": "{{IsUnicode}}",
   "Sandbox": "{{Sandbox}}",
   "campaignid": "{{campaignid}}",
   "RequestId": "{{RequestId}}",
   "CallbackUrl": "{{CallbackUrl}}"
}'
```

* **Body request:**&#x20;

<table><thead><tr><th width="148">Parameter</th><th width="136">Type</th><th width="134" data-type="checkbox">Required</th><th>Description</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>Your API Key.</td></tr><tr><td>Content</td><td>string</td><td>true</td><td>The content of message.</td></tr><tr><td>Phone</td><td>string</td><td>true</td><td>The phone number of receiver.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Your Secret Key.</td></tr><tr><td>Brandname</td><td>string</td><td>true</td><td>The name of the sender is shown in the header of the customer's message. Pre-registration is required.</td></tr><tr><td>SmsType</td><td>string</td><td>true</td><td>Message type:<br>2: Customer care message.</td></tr><tr><td>IsUnicode</td><td>string</td><td>false</td><td><p>Message charset value (<strong>default is 0</strong>):<br>1: Unicode.</p><p>0: Non-Unicode.</p></td></tr><tr><td>Sandbox</td><td>string</td><td>false</td><td>Sandbox option value (<strong>default is 0</strong>):<br>1: For testing purpose to verify the validation of the request. Message is not charged and sent to the receiver.<br>0: Message will be processed to the receiver properly.</td></tr><tr><td>RequestId</td><td>string</td><td>false</td><td>Partner ID passed to block duplicates and check if needed.<br>Maximum length 50 characters.<br>Each RequestId passed is valid for blocking for 24 hours.</td></tr><tr><td>SendDate</td><td>string</td><td>false</td><td>Scheduler the message to the receiver.<br>If it's empty, the message will be instantly sent to the receiver.<br>Format: <strong>yyyy-mm-dd hh:MM:ss</strong></td></tr><tr><td>campaignid</td><td>string</td><td>false</td><td>The campaign name of the request.</td></tr><tr><td>CallbackUrl</td><td>string</td><td>false</td><td>The webhook URL that will receive the status of message after it processed to the operator. It is used for determine whether the SMS is succcessfully delivered to the receiver or failed.<br>See the sample request at <a href="https://samplefordevelopers.esms.vn/#20f85e1f-3d9e-4ff4-bc4f-8d9c9edbc88a">here</a>.<br>More detail at <a href="/pages/HxTrJlnDLexPUwac9BWb">here</a>.</td></tr></tbody></table>

***

* **Response**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d533459ee42b2b9525ba9eabf6a8156"
}
```

**Valid request.**
{% endtab %}

{% tab title="104" %}

```json
{
    "CodeResult": "104",
    "CountRegenerate": 0,
    "ErrorMessage": "Brand name code is not exist"
}
```

**Invalid brandname.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Invalid credential.**
{% endtab %}

{% tab title="124" %}

```json
{
    "CodeResult": "124",
    "CountRegenerate": 0,
    "ErrorMessage": "Request exist 1",
    "SendStatus": "5"
}
```

**Duplicate request.**
{% endtab %}

{% tab title="146" %}
{% code overflow="wrap" %}

```json
{
  "CodeResult": "146",
  "CountRegenerate": 0,
  "ErrorMessage": "Sai template Brandname CSKH",
  "SMSID": "3f5ec8c71c4a4ccea311f731dfeaa133156"
}
```

{% endcode %}

**The customer care template is not registered.**
{% endtab %}

{% tab title="99" %}

```json
{
  "error": "Invalid request"
}
```

Connection is error. Contact the admin for reference.
{% endtab %}
{% endtabs %}

* **Response body**

| Parameter    | Type   | Description                                  |
| ------------ | ------ | -------------------------------------------- |
| CodeResult   | string | Response code.                               |
| SMSID        | string | The message id eSMS system.                  |
| ErrorMessage | string | The error message if the request is invalid. |

* *<mark style="color:yellow;">**The detail of error code can refer at**</mark>* [**Table of error codes**](/en/esms-api/table-of-error-codes) **.**
* *<mark style="color:yellow;">**Get the  sample of code for programing languagues to use in Postman refer at**</mark>* [**Link  of code samples**](https://samplefordevelopers.esms.vn/#850974b9-12cf-46f5-946c-e8e15aa3585b)**.**


# Send adveritising message

API dùng để gửi tin Quảng cáo đến khách hàng. Mỗi request tối thiểu 30 số để được duyệt tin và tối đa 5000 số.

Sending a POST request on this endpoint allows to send bulk advertising SMS (maximum 5000 receivers per request).&#x20;

Personalized content is ideal for sending marketing campaigns or any mass personalized announcement.

## **HTTP request**&#x20;

\ <mark style="color:yellow;">**`POST`**</mark> [https://rest.esms.vn/MainService.svc/json/SendMultipleSMSBrandname\_json/](http://rest.esms.vn/MainService.svc/json/SendMultipleSMSBrandname_json/)<br>

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/SendMultipleSMSBrandname_json/' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey": "{{SecretKey}}",
    "SecretKey": "{{SecretKey}}",
    "Brandname": "{{Brandname}}",
    "Content": "{{Content}}",
    "Phones": [
        "{{Phones}}",
        "{{Phones}}",
        "{{Phones}}"
    ],
    "SmsType": "1",
    "SendDate": "{{SendDate}}",
    "CallbackUrl": "{{CallbackUrl}}",
    "Sandbox":"{{Sandbox}}",
    "RequestId": "{{RequestId}}"
}'
```

* **Cấu trúc body của request:**

<table><thead><tr><th width="170">Paramter</th><th width="116">Type</th><th width="109" data-type="checkbox">Required</th><th>Description</th></tr></thead><tbody><tr><td>ApiKey </td><td>string</td><td>true</td><td>Your API Key.</td></tr><tr><td>SecretKey </td><td>string</td><td>true</td><td>Your Secret Key.</td></tr><tr><td>Content </td><td>string</td><td>true</td><td>The personized or marketing content.</td></tr><tr><td>SmsType </td><td>string</td><td>true</td><td>Message type:<br>1: Advertising/marking message.</td></tr><tr><td>Brandname </td><td>string</td><td>true</td><td>The name of the sender is shown in the header of the customer's message. <br><strong>Pre-registration is required.</strong></td></tr><tr><td>Phones </td><td>array</td><td>true</td><td>The phone number of receivers.</td></tr><tr><td>SendDate</td><td>string</td><td>false</td><td>Schedule the time when the message to the receiver.<br>If it's empty, the message will be instantly sent to the receiver.<br>Format: <strong>yyyy-mm-dd hh:MM:ss</strong></td></tr><tr><td>RequestId</td><td>string</td><td>false</td><td>Partner ID passed to block duplicates and check if needed.<br>Maximum length 50 characters.<br>Each RequestId passed is valid for blocking for 24 hours.</td></tr><tr><td>CallbackUrl</td><td>string</td><td>false</td><td>The webhook URL that will receive the status of message after it processed to the operator. It is used for determine whether the SMS is succcessfully delivered to the receiver or failed.<br>See the sample request at <a href="https://samplefordevelopers.esms.vn/#20f85e1f-3d9e-4ff4-bc4f-8d9c9edbc88a">here</a>.<br>More detail at <a href="/pages/HxTrJlnDLexPUwac9BWb">here</a>.</td></tr><tr><td>Sandbox</td><td>string</td><td>false</td><td>Sandbox option value (<strong>default is 0</strong>):<br>1: For testing purpose to verify the validation of the request. Message is not charged and sent to the receiver.<br>0: Message will be processed to the receiver properly.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d533459ee42b2b9525ba9eabf6a8156"
}
```

**Valid request.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Invalid credential.**
{% endtab %}

{% tab title="104" %}

```json
{
    "CodeResult": "104",
    "CountRegenerate": 0,
    "ErrorMessage": "Brand name code is not exist"
}
```

**Invalid brandname.**
{% endtab %}

{% tab title="107" %}

```json
{
    "CodeResult": "107",
    "CountRegenerate": 0,
    "ErrorMessage": "Each request has at least 30 numbers to be approved"
}
```

**At least 30 receivers per request.**
{% endtab %}

{% tab title="124" %}

```json
{
    "CodeResult": "124",
    "CountRegenerate": 0,
    "ErrorMessage": "Request exist 1"
}
```

**Duplicate request id.**
{% endtab %}
{% endtabs %}

* **Response body**

| Parameter    | Type   | Description                                  |
| ------------ | ------ | -------------------------------------------- |
| CodeResult   | string | Response code.                               |
| SMSID        | string | The message id eSMS system.                  |
| ErrorMessage | string | The error message if the request is invalid. |

* *<mark style="color:yellow;">**The detail of error code can refer at**</mark>* [**Table of error codes**](/en/esms-api/table-of-error-codes) **.**
* *<mark style="color:yellow;">**Get the  sample of code for programing languagues to use in Postman refer at**</mark>* [**Link  of code samples**](https://samplefordevelopers.esms.vn/#850974b9-12cf-46f5-946c-e8e15aa3585b)**.**


# Send message via Zalo

This endpoint is used to send Zalo messages individually (1 request per message).&#x20;

It is ideal to send single personalized messages for use-cases like notifications, alerting or marketing for example.

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> [https://rest.esms.vn/MainService.svc/json/SendZaloMessage\_V5\_post/](http://rest.esms.vn/MainService.svc/json/SendZaloMessage_V5_post/)

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

{% code overflow="wrap" %}

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/SendZaloMessage_V5_post/' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey": "{{ApiKey}}",
    "SecretKey": "{{SecretKey}}",
    "OAID": "{{OAID}}",
    "Phone": "{{Phone}}",
    "TempData": [
        {
            "key": "{{key1}}",
            "value": "{{value1}}"
        },
        {
            "key": "{{key2}}",
            "value": "{{value2}}"
        }
    ],
    "SendDate": "{{SendDate}}",
    "TempID": "{{TempID}}",
    "campaignid": "{{Campaignid}}",
    "Sandbox": "{{Sandbox}}",
    "CallbackUrl": "{{CallbackUrl}}",
    "RequestId": "{{RequestId}}",
    "SendingMode":"1"
}'
```

{% endcode %}

* **Request body**

<table><thead><tr><th width="152">Parameter</th><th width="128">Type</th><th width="105" data-type="checkbox">Required</th><th>Description</th></tr></thead><tbody><tr><td>Phone</td><td>string</td><td>true</td><td>The phone number of receivers.</td></tr><tr><td>ApiKey</td><td>string</td><td>true</td><td>Your API Key.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Your Secret Key.</td></tr><tr><td>OAID</td><td>string</td><td>true</td><td><p>Zalo OA Id is the Zalo Official Account Id of the organization. It can be obtained by accessing to the Zalo administrator page.</p><p><strong>Note: Pre-registration is required.</strong></p></td></tr><tr><td>TempData</td><td>Json object</td><td>true</td><td>The dynamic json object of the template that is registered at Zalo. <br>The template data structure is specified separatedly for each teamplate.</td></tr><tr><td>SendDate</td><td>string</td><td>false</td><td>Schedule the time when the message to the receiver.<br>If it's empty, the message will be instantly sent to the receiver.<br>Format: <strong>yyyy-mm-dd hh:MM:ss</strong></td></tr><tr><td>TempID </td><td>string</td><td>true</td><td>The ID of template for the OA that is registered and provided by eSMS at Zalo to partner.<br>Each template will have a specified structure of body.</td></tr><tr><td>campaignid</td><td>string</td><td>false</td><td>The campaign name of request</td></tr><tr><td>RequestId</td><td>string</td><td>false</td><td>Partner ID passed to block duplicates and check if needed.<br>Maximum length 50 characters.<br>Each RequestId passed is valid for blocking for 24 hours.</td></tr><tr><td>Sandbox</td><td>string</td><td>false</td><td>Sandbox option value (<strong>default is 0</strong>):<br>1: For testing purpose to verify the validation of the request. Message is not charged and sent to the receiver.<br>0: Message will be processed to the receiver properly.</td></tr><tr><td>CallbackUrl</td><td>string</td><td>false</td><td>The webhook URL that will receive the status of message after it processed to the operator. It is used for determine whether the SMS is succcessfully delivered to the receiver or failed.<br>See the sample request at <a href="https://samplefordevelopers.esms.vn/#20f85e1f-3d9e-4ff4-bc4f-8d9c9edbc88a">here</a>.<br>More details at <a href="/pages/HxTrJlnDLexPUwac9BWb">here</a>.</td></tr><tr><td>SendingMode</td><td>string</td><td>false</td><td><p>Sending Modes:<br>  <kbd><strong>1</strong></kbd> Default (Normal Sending):<br>Messages are sent using the standard ZNS delivery mechanism.<br>  <kbd><strong>3</strong></kbd> Exceed Quota Sending:<br>Allows OA to send ZNS tagged messages exceeding the quota limits.<br></p><p><strong>Note:</strong><br>Exceed Quota Sending (SendingMode = 3) is only available for whitelisted OAs. Contact the Customer Support team for access.</p></td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d8e0f1f0702544b2acb456ca9ccfd111250"
}
```

**Valid request.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Invalid credential.**
{% endtab %}

{% tab title="789" %}

```json
{
    "CodeResult": "789",
    "CountRegenerate": 0,
    "ErrorMessage": "TemplateId is not config"
}
```

**The template is not configured on your account.**
{% endtab %}
{% endtabs %}

* Response body

| Parameter    | Type   | Description                                  |
| ------------ | ------ | -------------------------------------------- |
| CodeResult   | string | Response code.                               |
| SMSID        | string | The message id eSMS system.                  |
| ErrorMessage | string | The error message if the request is invalid. |

* *<mark style="color:yellow;">**The detail of error code can refer at**</mark>* [**Table of error codes**](/en/esms-api/table-of-error-codes) **.**
* *<mark style="color:yellow;">**Get the  sample of code for programing languagues to use in Postman refer at**</mark>* [**Link  of code samples**](https://samplefordevelopers.esms.vn/#850974b9-12cf-46f5-946c-e8e15aa3585b)**.**


# Send message via Zalo by UID

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> <https://rest.esms.vn//MainService.svc/json/SendZaloMessage_V6/zalo_uid/>

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

{% code overflow="wrap" %}

```json
curl --location 'https://rest.esms.vn//MainService.svc/json/SendZaloMessage_V6/zalo_uid/' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey": "APIKEYCUABAN",
    "SecretKey": "SECRETKEYCUABAN",
    "OAID": "4097311281936189049",
    "ZaloUid": "0901888484",
    "TempData": {
        "customer_name": "Đinh Thái Hà",
        "order_code": "HD00001",
        "address": "140-142 Đường Số 1, KDC Vạn Phúc, Hiệp Bình Phước, Thủ Đức",
        "phone": "0901888484",
        "email": "dinhthaiha@vihatgroup.com",
        "product_name": "Gói duy trì OA Zalo Premium 1 năm",
        "quantity": "1",
        "payment_amount": "4308000",
        "delivery_date": "01/08/2024"
    },
    "TempID":  "200607",
    "campaignid":  "Xác nhận mua hàng",
    "RequestId": "96accf59-0c41-4bc7-a5c4-4a466c2e41c2",
    "CallbackUrl": "https://esms.vn/webhook/"
}'
```

{% endcode %}

* **Request body**

<table><thead><tr><th width="152">Parameter</th><th width="128">Type</th><th width="105" data-type="checkbox">Required</th><th>Description</th></tr></thead><tbody><tr><td>ZaloUid</td><td>string</td><td>true</td><td>The Zalo Userid of receivers.</td></tr><tr><td>ApiKey</td><td>string</td><td>true</td><td>Your API Key.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Your Secret Key.</td></tr><tr><td>OAID</td><td>string</td><td>true</td><td><p>Zalo OA Id is the Zalo Official Account Id of the organization. It can be obtained by accessing to the Zalo administrator page.</p><p><strong>Note: Pre-registration is required.</strong></p></td></tr><tr><td>TempData</td><td>Json object</td><td>true</td><td>The dynamic json object of the template that is registered at Zalo. <br>The template data structure is specified separatedly for each teamplate.</td></tr><tr><td>SendDate</td><td>string</td><td>false</td><td>Schedule the time when the message to the receiver.<br>If it's empty, the message will be instantly sent to the receiver.<br>Format: <strong>yyyy-mm-dd hh:MM:ss</strong></td></tr><tr><td>TempID </td><td>string</td><td>true</td><td>The ID of template for the OA that is registered and provided by eSMS at Zalo to partner.<br>Each template will have a specified structure of body.</td></tr><tr><td>campaignid</td><td>string</td><td>false</td><td>The campaign name of request</td></tr><tr><td>RequestId</td><td>string</td><td>false</td><td>Partner ID passed to block duplicates and check if needed.<br>Maximum length 50 characters.<br>Each RequestId passed is valid for blocking for 24 hours.</td></tr><tr><td>Sandbox</td><td>string</td><td>false</td><td>Sandbox option value (<strong>default is 0</strong>):<br>1: For testing purpose to verify the validation of the request. Message is not charged and sent to the receiver.<br>0: Message will be processed to the receiver properly.</td></tr><tr><td>CallbackUrl</td><td>string</td><td>false</td><td>The webhook URL that will receive the status of message after it processed to the operator. It is used for determine whether the SMS is succcessfully delivered to the receiver or failed.<br>See the sample request at <a href="https://samplefordevelopers.esms.vn/#20f85e1f-3d9e-4ff4-bc4f-8d9c9edbc88a">here</a>.<br>More details at <a href="/pages/HxTrJlnDLexPUwac9BWb">here</a>.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d8e0f1f0702544b2acb456ca9ccfd111250"
}
```

**Valid request.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Invalid credential.**
{% endtab %}

{% tab title="789" %}

```json
{
    "CodeResult": "789",
    "CountRegenerate": 0,
    "ErrorMessage": "TemplateId is not config"
}
```

**The template is not configured on your account.**
{% endtab %}
{% endtabs %}

* Response body

| Parameter    | Type   | Description                                  |
| ------------ | ------ | -------------------------------------------- |
| CodeResult   | string | Response code.                               |
| SMSID        | string | The message id eSMS system.                  |
| ErrorMessage | string | The error message if the request is invalid. |

* *<mark style="color:yellow;">**The detail of error code can refer at**</mark>* [**Table of error codes**](/en/esms-api/table-of-error-codes) **.**
* *<mark style="color:yellow;">**Get the  sample of code for programing languagues to use in Postman refer at**</mark>* [**Link  of code samples**](https://samplefordevelopers.esms.vn/#850974b9-12cf-46f5-946c-e8e15aa3585b)**.**


# Send message via Viber

This endpoint is used to send Viber messages by individually or with bulk requests.

It is ideal to send the personalized messages for use-cases like notifications, alerting or marketing for example.

<figure><img src="/files/PnzjK4oRa8QU1lfODV0g" alt=""><figcaption><p>Hình mẫu tin nhắn Viber</p></figcaption></figure>

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> [https://rest.esms.vn/MainService.svc/json/Send\_Multiple\_Sms\_OTT/](http://rest.esms.vn/MainService.svc/json/Send_Multiple_Sms_OTT/)

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

{% code overflow="wrap" %}

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/Send_Multiple_Sms_OTT/' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey": "{{ApiKey}}",
    "SecretKey": "{{SecretKey}}",
    "Brandname": "{{Brandname}}",
    "SmsType": "23",
    "Content": "{{Content}}",
    "OttImgUrl": "{{OttImgUrl}}",
    "OttLabel": "{{OttLabel}}",
    "OttUrl": "{{OttUrl}}",
    "Phones": [
        "{{Phone1}}","{{Phone2}}","{{Phone3}}"
    ],
    "IsSandBox": "{{IsSandBox}}",
    "RequestId": "{{RequestId}}",
    "CallbackUrl": "{{CallbackUrl}}"
}'
```

{% endcode %}

* **Request body**

<table><thead><tr><th width="175">Parameter</th><th width="148">Type</th><th width="143" data-type="checkbox">Required</th><th>Description</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>Your API Key.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Your Secret Key.</td></tr><tr><td>Brandname</td><td>string</td><td>true</td><td>The name of the sender is shown in the header of the customer's message. <br><strong>Pre-registration is required.</strong></td></tr><tr><td>SmsType</td><td>number</td><td>true</td><td>Message type:<br>23: OTT message via Viber.</td></tr><tr><td>Content</td><td>string</td><td>true</td><td>The personized or marketing content.</td></tr><tr><td>OttImgUrl</td><td>string</td><td>false</td><td>The URL of image. The schema has to be <strong>https</strong>.</td></tr><tr><td>OTTLabel</td><td>string</td><td>false</td><td>The label of button.</td></tr><tr><td>OttUrl</td><td>string</td><td>false</td><td>The redirect URL when clicking to the button.</td></tr><tr><td>Phones</td><td>Array</td><td>true</td><td>The list phone number of receivers.</td></tr><tr><td>IsSandBox</td><td>number</td><td>false</td><td>Sandbox option value (<strong>default is 0</strong>):<br>1: For testing purpose to verify the validation of the request. Message is not charged and sent to the receiver.<br>0: Message will be processed to the receiver properly.</td></tr><tr><td>RequestId</td><td>string</td><td>false</td><td>Partner ID passed to block duplicates and check if needed.<br>Maximum length 50 characters.<br>Each RequestId passed is valid for blocking for 24 hours.</td></tr><tr><td>CallbackUrl</td><td>string</td><td>false</td><td>The webhook URL that will receive the status of message after it processed to the operator. It is used for determine whether the SMS is succcessfully delivered to the receiver or failed.<br>See the sample request at <a href="https://samplefordevelopers.esms.vn/#20f85e1f-3d9e-4ff4-bc4f-8d9c9edbc88a">here</a>.<br>More details at <a href="/pages/HxTrJlnDLexPUwac9BWb">here</a>.</td></tr></tbody></table>

* <mark style="color:yellow;">**`Note:`**</mark> Sending the message via Viber, there are 4 sending options can be used:

| Content Type          | Params required                                   |
| --------------------- | ------------------------------------------------- |
| Text - Image - Button | <p>Content<br>OttImgUrl<br>OttUrl<br>OTTLabel</p> |
| Text - Button         | <p>Content<br>OttUrl<br>OTTLabel</p>              |
| Image                 | OttImgUrl                                         |
| Text                  | Content                                           |

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d8e0f1f0702544b2acb456ca9ccfd111250"
}
```

**Valid request.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Invalid credentials.**
{% endtab %}

{% tab title="104" %}

```json
{
    "CodeResult": "104",
    "CountRegenerate": 0,
    "ErrorMessage": "Brand name code is not exist"
}
```

**Invalid brandname.**
{% endtab %}
{% endtabs %}

* **Response body**

| Parameter    | Type   | Description                                  |
| ------------ | ------ | -------------------------------------------- |
| CodeResult   | string | Response code.                               |
| SMSID        | string | The message id eSMS system.                  |
| ErrorMessage | string | The error message if the request is invalid. |

* *<mark style="color:yellow;">**The detail of error code can refer at**</mark>* [**Table of error codes**](/en/esms-api/table-of-error-codes) **.**
* *<mark style="color:yellow;">**Get the  sample of code for programing languagues to use in Postman refer at**</mark>* [**Link  of code samples**](https://samplefordevelopers.esms.vn/#850974b9-12cf-46f5-946c-e8e15aa3585b)**.**


# Send fixed number with cheap price

This endpoint is used to send the individually message to the recipient using the fixed number.

It is ideal to send the OTP (One-Time-Password) for use-case like verficiation for example.

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> [https://rest.esms.vn/MainService.svc/json/SendMultipleMessage\_V4\_post\_json/](http://rest.esms.vn/MainService.svc/json/SendMultipleMessage_V4_post_json/)<br>

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/SendMultipleMessage_V4_post_json/' \
--header 'Content-Type: application/json' \
--data '{
   "ApiKey": "{{ApiKey}}",
   "Content": "{{Content}}",
   "Phone": "{{Phone}}",
   "SecretKey": "{{SecretKey}}",
   "SmsType": "8",
   "IsUnicode": "{{IsUnicode}}",
   "Sandbox": "{{Sandbox}}",
   "campaignid": "{{campaignid}}",
   "RequestId": "{{RequestId}}",
   "CallbackUrl": "{{CallbackUrl}}",
   "SendDate":"{{SendDate}}"
}'
```

* **Request body**

<table><thead><tr><th width="145">Paramter</th><th width="121">Type</th><th width="147" data-type="checkbox">Required</th><th>Description</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>Your API Key.</td></tr><tr><td>Content</td><td>string</td><td>true</td><td>The message content.</td></tr><tr><td>Phone</td><td>string</td><td>true</td><td>The phone number of receivers.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Your Secret Key.</td></tr><tr><td>SmsType</td><td>string</td><td>true</td><td>Message type<br>8: Fixed number</td></tr><tr><td>Unicode</td><td>string</td><td>false</td><td><p>Message charset value (<strong>default is 0</strong>):<br>1: Unicode.</p><p>0: Non-Unicode.</p></td></tr><tr><td>Sandbox</td><td>string</td><td>false</td><td>Sandbox option value (<strong>default is 0</strong>):<br>1: For testing purpose to verify the validation of the request. Message is not charged and sent to the receiver.<br>0: Message will be processed to the receiver properly.</td></tr><tr><td>campaignid</td><td>string</td><td>false</td><td>The campaign name of the request.</td></tr><tr><td>RequestId</td><td>string</td><td>false</td><td>Partner ID passed to block duplicates and check if needed.<br>Maximum length 50 characters.<br>Each RequestId passed is valid for blocking for 24 hours.</td></tr><tr><td>CallbackUrl</td><td>string</td><td>false</td><td>The webhook URL that will receive the status of message after it processed to the operator. It is used for determine whether the SMS is succcessfully delivered to the receiver or failed.<br>See the sample request at <a href="https://samplefordevelopers.esms.vn/#20f85e1f-3d9e-4ff4-bc4f-8d9c9edbc88a">here</a>.<br>More detail at <a href="/pages/HxTrJlnDLexPUwac9BWb">here</a>.</td></tr><tr><td>SendDate</td><td>string</td><td>false</td><td>Scheduler the message to the receiver.<br>If it's empty, the message will be instantly sent to the receiver.<br>Format: <strong>yyyy-mm-dd hh:MM:ss</strong></td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d8e0f1f0702544b2acb456ca9ccfd111250"
}
```

**Valid request.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Invalid credential.**
{% endtab %}

{% tab title="99" %}

```
{
  "error": "Invalid request"
}
```

Connection is error. Contact the admin for reference.
{% endtab %}
{% endtabs %}

* **Response body**

| Parameter    | Type   | Description                                  |
| ------------ | ------ | -------------------------------------------- |
| CodeResult   | string | Response code.                               |
| SMSID        | string | The message id eSMS system.                  |
| ErrorMessage | string | The error message if the request is invalid. |

* *<mark style="color:yellow;">**The detail of error code can refer at**</mark>* [**Table of error codes**](/en/esms-api/table-of-error-codes) **.**
* *<mark style="color:yellow;">**Get the  sample of code for programing languagues to use in Postman refer at**</mark>* [**Link  of code samples**](https://samplefordevelopers.esms.vn/#850974b9-12cf-46f5-946c-e8e15aa3585b)**.**


# Send multi-channel message via Zalo and SMS

This endpoint is used for sending multi-channel SMS via Zalo and SMS by orderding.

It is ideal to send the personalized messages for use-cases like notifications, alerting or marketing for example with high delivery rate.

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> <https://rest.esms.vn/MainService.svc/json/MultiChannelMessage/><br>

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

{% code overflow="wrap" %}

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/MultiChannelMessage/' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey": "{{ApiKey}}",
    "SecretKey": "{{SecretKey}}",
    "Phone": "{{Phone}}",
    "Channels": [
        "zalo",
        "sms"
    ],
    "Data": [
        {
            "TempID": "{{TempID}}",
            "Params": ["{{param1}}","{{param2}}","{{param3}}"],
            "OAID": "{{OAID}}",
            "campaignid": "{{campaignid}}",
            "CallbackUrl": "{{CallbackUrl}}",
            "RequestId":"{{RequestId}}",
            "Sandbox":"{{Sandbox}}",
            "SendingMode":"1"
        },
        {
            "Content": "{{Content}}",
            "IsUnicode": "{{IsUnicode}}",
            "SmsType": "{{SmsType}}",
            "Brandname": "{{Brandname}}",
            "CallbackUrl": "{{CallbackUrl}}",
            "RequestId":"{{RequestId}}",
            "Sandbox":"{{Sandbox}}"
        }
    ]
}'
```

{% endcode %}

* **Request body**

<table><thead><tr><th width="141.33331298828125">Parameter</th><th width="135">Type</th><th width="93.6666259765625" data-type="checkbox">Required</th><th>Description</th></tr></thead><tbody><tr><td>ApiKey </td><td>string</td><td>true</td><td>Your API Key.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Your Secret Key.</td></tr><tr><td>Phone</td><td>string</td><td>true</td><td>The phone number of receivers.</td></tr><tr><td>Params</td><td>array</td><td>true</td><td><p><br>The values that need to pass according to the template variables.</p><p>Giá trị cần truyền cho các biến trong Template <br>*Notes:</p><ol><li>The values must be placed in the correct order with the registered template.</li><li>If the parameter is duplicated, just place one.</li></ol></td></tr><tr><td>TempID</td><td>string</td><td>true</td><td>Template của The ID of template for the OA that is registered and provided by eSMS at Zalo to partner.<br>Each template will have a specified structure of body.</td></tr><tr><td>OAID</td><td>string</td><td>true</td><td><p>Zalo OA Id is the Zalo Official Account Id of the organization. It can be obtained by accessing to the Zalo administrator page.</p><p><strong>Note: Pre-registration is required.</strong></p></td></tr><tr><td>RequestId</td><td>string</td><td>false</td><td>The identification value for the request to prevent the the request from duplicated.</td></tr><tr><td>campaignid</td><td>string</td><td>false</td><td>The campaign name of request.</td></tr><tr><td>CallbackUrl</td><td>string</td><td>false</td><td>The webhook URL that will receive the status of message after it processed to the operator. It is used for determine whether the SMS is succcessfully delivered to the receiver or failed.<br>See the sample request at <a href="https://samplefordevelopers.esms.vn/#20f85e1f-3d9e-4ff4-bc4f-8d9c9edbc88a">here</a>.<br>More details at <a href="/pages/HxTrJlnDLexPUwac9BWb">here</a>.</td></tr><tr><td>Content</td><td>string</td><td>true</td><td>The OTP or marketing content.</td></tr><tr><td>IsUnicode</td><td>string</td><td>false</td><td><p>Message charset value (<strong>default is 0</strong>):<br>1: Unicode.</p><p>0: Non-Unicode.</p></td></tr><tr><td>SmsType </td><td>string</td><td>true</td><td>Message type:<br>2: Customer care message</td></tr><tr><td>Brandname</td><td>string</td><td>true</td><td>The name of the sender is shown in the header of the customer's message. <br><strong>Pre-registration is required.</strong></td></tr><tr><td>Sandbox</td><td>string</td><td>false</td><td>Sandbox option value (<strong>default is 0</strong>):<br>1: For testing purpose to verify the validation of the request. Message is not charged and sent to the receiver.<br>0: Message will be processed to the receiver properly.</td></tr><tr><td>SendingMode</td><td></td><td>false</td><td><p>Sending Modes: <br><kbd><strong>1</strong></kbd> Default (Normal Sending): Messages are sent using the standard ZNS delivery mechanism. <br><kbd><strong>3</strong></kbd> Exceed Quota Sending: Allows OA to send ZNS tagged messages exceeding the quota limits.</p><p><br><strong>Note:</strong> Exceed Quota Sending (SendingMode = 3) is only available for whitelisted OAs. Contact the Customer Support team for access.</p></td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d8e0f1f0702544b2acb456ca9ccfd111250"
}
```

**Valid request.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Invlid credential.**
{% endtab %}

{% tab title="789" %}

```json
{
    "CodeResult": "789",
    "CountRegenerate": 0,
    "ErrorMessage": "TemplateId is not config"
}
```

**The template is not configured on your account.**
{% endtab %}
{% endtabs %}

* **Response body**

| Parameter    | Type   | Description                                  |
| ------------ | ------ | -------------------------------------------- |
| CodeResult   | string | Response code.                               |
| SMSID        | string | The message id of eSMS system.               |
| ErrorMessage | string | The error message if the request is invalid. |

* *<mark style="color:yellow;">**The detail of error code can refer at**</mark>* [**Table of error codes**](/en/esms-api/table-of-error-codes) **.**
* *<mark style="color:yellow;">**Get the  sample of code for programing languagues to use in Postman refer at**</mark>* [**Link  of code samples**](https://samplefordevelopers.esms.vn/#850974b9-12cf-46f5-946c-e8e15aa3585b)**.**


# Send Zalo message Consulting in text form

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> [https://rest.esms.vn/MainService.svc/json/SendZaloFollowerMessage\_V4\_post\_json/](http://rest.esms.vn/MainService.svc/json/SendZaloFollowerMessage_V5_post_json/)

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location 'http://rest.esms.vn/mainservice.svc/json/SendZaloFollowerMessage_V4_post_json/' \
--header 'Content-Type: application/json' \
--header 'Cookie: ASP.NET_SessionId=5xcbl12ska5q5wocug3chmjz; ASP.NET_SessionId=wauhgrxpkq40wj00w52orug3' \
--data '{
 "ApiKey":"{{ApiKey}}",
 "SecretKey":"{{SecretKey}}",
 "OAID":"{{OAID}}",
 "User_id":"{{User_id}}",
 "Content":"{{Content}}",
  "CallbackUrl": "{{CallbackUrl}}",
  "RequestId": "{{RequestId}}"

}'
```

* **Body request**

<table><thead><tr><th width="166">Parameter</th><th width="123">Type</th><th width="140" data-type="checkbox">Required</th><th>Description</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>Your API Key.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Your Secret Key.</td></tr><tr><td>OAID</td><td>string</td><td>true</td><td><p>Zalo OA Id is the Zalo Official Account Id of the organization. It can be obtained by accessing to the Zalo administrator page.</p><p><strong>Note: Pre-registration is required.</strong></p></td></tr><tr><td>User_id</td><td>string</td><td>true</td><td>The identification value of user at Zalo.</td></tr><tr><td>Content</td><td>string</td><td>true</td><td>The message content.<br>Text content to send to users Maximum limit is 2,000 characters</td></tr><tr><td>CallbackUrl</td><td>string</td><td>false</td><td>The webhook URL that will receive the status of message after it processed to the operator. It is used for determine whether the SMS is succcessfully delivered to the receiver or failed.<br>See the sample request at <a href="https://samplefordevelopers.esms.vn/#20f85e1f-3d9e-4ff4-bc4f-8d9c9edbc88a">here</a>.<br>More details at <a href="/pages/HxTrJlnDLexPUwac9BWb">here</a>.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d8e0f1f0702544b2acb456ca9ccfd111250"
}
```

**Valid request.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Invalid credential.**
{% endtab %}
{% endtabs %}

* **Response body**

| Parameter    | Type   | Description                                  |
| ------------ | ------ | -------------------------------------------- |
| CodeResult   | string | Response code.                               |
| SMSID        | string | The message id eSMS system.                  |
| ErrorMessage | string | The error message if the request is invalid. |

* *<mark style="color:yellow;">**The detail of error code can refer at**</mark>* [**Table of error codes**](/en/esms-api/table-of-error-codes) **.**
* *<mark style="color:yellow;">**Get the  sample of code for programing languagues to use in Postman refer at**</mark>* [**Link  of code samples**](https://samplefordevelopers.esms.vn/#850974b9-12cf-46f5-946c-e8e15aa3585b)**.**


# Send Zalo message with attached photo

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> [https://rest.esms.vn/MainService.svc/json/SendZaloFollowerMessage\_V5\_post\_json/](http://rest.esms.vn/MainService.svc/json/SendZaloFollowerMessage_V5_post_json/)

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location 'http://rest.esms.vn/MainService.svc/json/SendZaloFollowerMessage_V5_post_json/' \
--header 'Content-Type: text/plain' \
--header 'Cookie: ASP.NET_SessionId=asfgp2dj1kt4kbg1yzuo35ky; ASP.NET_SessionId=5xcbl12ska5q5wocug3chmjz' \
--data '{
    "ApiKey": "{{ApiKey}}",
    "SecretKey": "{{SecretKey}}",
    "OAID": "{{OAID}}",
    "CallbackUrl": "{{CallbackUrl}}",
    "RequestId": "{{RequestId}}",
    "Payload": {
        "recipient": {
            "user_id": "{{user_id}}"
        },
        "message": {
            "text": "{{text}}",
            "attachment": {
                "type": "template",
                "payload": {
                    "template_type": "media",
                    "elements": [
                        {
                            "media_type": "image",
                            "url": "{{url}}"
                        }
                    ]
                }
            }
        }
    }
}'
```

* **Body request**

<table><thead><tr><th width="166">Parameter</th><th width="123">Type</th><th width="140" data-type="checkbox">Required</th><th>Description</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>Your API Key.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Your Secret Key.</td></tr><tr><td>OAID</td><td>string</td><td>true</td><td><p>Zalo OA Id is the Zalo Official Account Id of the organization. It can be obtained by accessing to the Zalo administrator page.</p><p><strong>Note: Pre-registration is required.</strong></p></td></tr><tr><td>user_id</td><td>string</td><td>true</td><td>The identification value of user at Zalo.</td></tr><tr><td>text</td><td>string</td><td>true</td><td>Text content to send to users Maximum limit is 2,000 characters</td></tr><tr><td>url</td><td>string</td><td>true</td><td><p>Image path </p><p>Supported image formats: jpg and png Maximum size: 1MB</p></td></tr><tr><td>RequestId</td><td>string</td><td>false</td><td>Partner ID passed to block duplicates and check if needed.<br>Maximum length 50 characters.<br>Each RequestId passed is valid for blocking for 24 hours.</td></tr><tr><td>CallbackUrl</td><td>string</td><td>false</td><td>The webhook URL that will receive the status of message after it processed to the operator. It is used for determine whether the SMS is succcessfully delivered to the receiver or failed.<br>See the sample request at <a href="https://samplefordevelopers.esms.vn/#20f85e1f-3d9e-4ff4-bc4f-8d9c9edbc88a">here</a>.<br>More details at <a href="/pages/HxTrJlnDLexPUwac9BWb">here</a>.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d8e0f1f0702544b2acb456ca9ccfd111250"
}
```

**Valid request.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Invalid credential.**
{% endtab %}
{% endtabs %}

* **Response body**

| Parameter    | Type   | Description                                  |
| ------------ | ------ | -------------------------------------------- |
| CodeResult   | string | Response code.                               |
| SMSID        | string | The message id eSMS system.                  |
| ErrorMessage | string | The error message if the request is invalid. |

* *<mark style="color:yellow;">**The detail of error code can refer at**</mark>* [**Table of error codes**](/en/esms-api/table-of-error-codes) **.**
* *<mark style="color:yellow;">**Get the  sample of code for programing languagues to use in Postman refer at**</mark>* [**Link  of code samples**](https://samplefordevelopers.esms.vn/#850974b9-12cf-46f5-946c-e8e15aa3585b)**.**


# Send Zalo message Consulting button

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> [https://rest.esms.vn/MainService.svc/json/SendZaloFollowerMessage\_V5\_post\_json/](http://rest.esms.vn/MainService.svc/json/SendZaloFollowerMessage_V5_post_json/)

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/SendZaloFollowerMessage_V5_post_json/' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey": "{{ApiKey}}",
    "SecretKey": "{{SecretKey}}",
    "OAID": "{{OAID}}",
    "CallbackUrl": "{{CallbackUrl}}",
    "RequestId": "{{RequestId}}",
    "Payload": {
        "recipient": {
            "user_id": "{{user_id}}"
        },
        "message": {
            "text": "{{text}}",
            "attachment": {
                "type": "template",
                "payload": {
                    "buttons": [
                        {
                            "title": "{{title}}",
                            "payload": {
                                "url": "{{url}}"
                            },
                            "type": "oa.open.url"
                        },
                        {
                            "title": "{{title}}",
                            "type": "oa.query.show",
                            "payload": "{{payload}}"
                        },
                        {
                            "title": "{{title}}",
                            "type": "oa.query.hide",
                            "payload": "{{payload}}"
                        },
                        {
                            "title": "{{title}}",
                            "type": "oa.open.sms",
                            "payload": {
                                "content": "{{content}}",
                                "phone_code": "{{phone_code}}"
                            }
                        },
                        {
                            "title": "{{title}}",
                            "type": "oa.open.phone",
                            "payload": {
                                "phone_code": "{{phone_code}}"
                            }
                        }
                    ]
                }
            }
        }
    }
}'
```

* **Body request**

<table><thead><tr><th width="166">Parameter</th><th width="123">Type</th><th width="140" data-type="checkbox">Required</th><th>Description</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>Your API Key.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Your Secret Key.</td></tr><tr><td>OAID</td><td>string</td><td>true</td><td><p>Zalo OA Id is the Zalo Official Account Id of the organization. It can be obtained by accessing to the Zalo administrator page.</p><p><strong>Note: Pre-registration is required.</strong></p></td></tr><tr><td>user_id</td><td>string</td><td>true</td><td>The identification value of user at Zalo.</td></tr><tr><td>text</td><td>string</td><td>true</td><td>Text content to send to users Maximum limit is 2,000 characters</td></tr><tr><td>RequestId</td><td>string</td><td>false</td><td>Partner ID passed to block duplicates and check if needed.<br>Maximum length 50 characters.<br>Each RequestId passed is valid for blocking for 24 hours.</td></tr><tr><td>attachment</td><td>string</td><td>true</td><td><p></p><ul><li>Tittle: template display title (max 100 characters).</li><li>Default_action<br>- Type oa.open.url: The URL that will be opened in Zalo application when the follower click on it.<br>- Type oa.open.sms: When the follower click on the action, a new window will be opened with 2 availabel values are phone code and the message text value in the data payload.<br>- Type oa.query.hide: Payload is a string such as "#eSMS". When the follower click on the action, the system will send a message with the content is the user data to the Official Account.<br>- Type oa.query.show:  The payload structure is a string such as "#eSMS". When the follower click on the action, the system will send a message with the content is the user data to the Official Account. This message will be displayed on the chat window of user.<br>- Type oa.open.phone: When the follower click on the action, a calling window will be opened  with the phone number is the phone_code value.</li></ul></td></tr><tr><td>CallbackUrl</td><td>string</td><td>false</td><td>The webhook URL that will receive the status of message after it processed to the operator. It is used for determine whether the SMS is succcessfully delivered to the receiver or failed.<br>See the sample request at <a href="https://samplefordevelopers.esms.vn/#20f85e1f-3d9e-4ff4-bc4f-8d9c9edbc88a">here</a>.<br>More details at <a href="/pages/HxTrJlnDLexPUwac9BWb">here</a>.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d8e0f1f0702544b2acb456ca9ccfd111250"
}
```

**Valid request.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Invalid credential.**
{% endtab %}
{% endtabs %}

* **Response body**

| Parameter    | Type   | Description                                  |
| ------------ | ------ | -------------------------------------------- |
| CodeResult   | string | Response code.                               |
| SMSID        | string | The message id eSMS system.                  |
| ErrorMessage | string | The error message if the request is invalid. |

* *<mark style="color:yellow;">**The detail of error code can refer at**</mark>* [**Table of error codes**](/en/esms-api/table-of-error-codes) **.**
* *<mark style="color:yellow;">**Get the  sample of code for programing languagues to use in Postman refer at**</mark>* [**Link  of code samples**](https://samplefordevelopers.esms.vn/#850974b9-12cf-46f5-946c-e8e15aa3585b)**.**


# Send Zalo Trading message

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> [https://rest.esms.vn/mainservice.svc/json/SendZaloFollowerMessage\_V5\_post\_json/](http://rest.esms.vn/mainservice.svc/json/SendZaloFollowerMessage_V5_post_json/)

* **Content Type:** <mark style="color:orange;">text/plain</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location 'https://rest.esms.vn/mainservice.svc/json/SendZaloFollowerMessage_V5_post_json/' \
--header 'Content-Type: text/plain' \
--data '{
    "ApiKey": "{{ApiKey}}",
    "SecretKey": "{{SecretKey}}",
    "OAID": "{{OAID}}",
    "RequestId": "96accf59-0c41-4bc7-a5c4-4a466c2e41c2", 
    "Payload": {
        "recipient": {
            "user_id": "{{user_id}}"
        },
        "message": {
            "attachment": {
                "type": "template",
                "payload": {
                    "template_type": "transaction_order",
                    "language": "VI",
                    "elements": [
                        {
                            "image_url": "https://minio.esms.vn/blogimg/agent-1/BlogImg/full_cccc34d4-3a46-4644-8613-1b226203c5d5.png",
                            "type": "banner"
                        },
                        {
                            "type": "header",
                            "content": "Trạng thái đơn hàng",
                            "align": "left"
                        },
                        {
                            "type": "text",
                            "align": "left",
                            "content": "• Cảm ơn bạn đã mua hàng tại cửa hàng.<br>• Thông tin đơn hàng của bạn như sau:"
                        },
                        {
                            "type": "table",
                            "content": [
                                {
                                    "value": "eSMS-001",
                                    "key": "Mã khách hàng"
                                },
                                {
                                    "style": "yellow",
                                    "value": "Đang giao",
                                    "key": "Trạng thái"
                                },
                                {
                                    "value": "250,000đ",
                                    "key": "Giá tiền"
                                }
                            ]
                        },
                        {
                            "type": "text",
                            "align": "center",
                            "content": "📲 Lưu ý điện thoại. Xin cảm ơn!"
                        }
                    ],
                    "buttons": [
                        {
                            "title": "Kiểm tra lộ trình",
                            "image_icon": "https://img.icons8.com/?size=100&id=kJlyCVWJrclv&format=png&color=000000",
                            "type": "oa.open.url",
                            "payload": {
                                "url": "https://esms.vn/huong-dan/huong-dan-tich-hop/huong-dan-tich-hop-api-cua-esms-vao-website"
                            }
                        },
                        {
                            "title": "Xem lại giỏ hàng",
                            "image_icon": "https://img.icons8.com/?size=100&id=S2Z1vzGMFT1v&format=png&color=000000",
                            "type": "oa.open.url",
                            "payload": {
                                "url": "https://esms.vn/huong-dan/huong-dan-su-dung"
                            }
                        },
                        {
                            "title": "Liên hệ tổng đài",
                            "image_icon": "https://img.icons8.com/?size=100&id=KKBDB20a4V6t&format=png&color=000000",
                            "type": "oa.open.phone",
                            "payload": {
                                "phone_code": "0901888484"
                            }
                        }
                    ]
                }
            }
        }
    }
}'
```

* **Body request**

<table><thead><tr><th width="158">Parameters</th><th width="120">Type</th><th width="121" data-type="checkbox">Required</th><th>Description</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>Your API Key.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Your Secret Key</td></tr><tr><td>OAID</td><td>string</td><td>true</td><td><p>Zalo OA Id is the Zalo Official Account Id of the organization. It can be obtained by accessing to the Zalo administrator page.</p><p><strong>Note: Pre-registration is required.</strong></p></td></tr><tr><td>user_id</td><td>string</td><td>true</td><td>The identification value of user at Zalo.</td></tr><tr><td>CallbackUrl</td><td>string</td><td>false</td><td>The webhook URL that will receive the status of message after it processed to the operator. It is used for determine whether the SMS is succcessfully delivered to the receiver or failed.<br>See the sample request at <a href="https://samplefordevelopers.esms.vn/#20f85e1f-3d9e-4ff4-bc4f-8d9c9edbc88a">here</a>.<br>More details at <a href="/pages/HxTrJlnDLexPUwac9BWb">here</a>.</td></tr><tr><td>RequestId</td><td>string</td><td>false</td><td>Partner ID passed to block duplicates and check if needed.<br>Maximum length 50 characters.<br>Each RequestId passed is valid for blocking for 24 hours.</td></tr><tr><td>template_type</td><td>string</td><td>true</td><td><p>Type of template:<br>- transaction_billing<br>- transaction_order<br>- transaction_reward<br>- transaction_contract<br>- transaction_booking<br>- transaction_membership<br>- transaction_event<br>- transaction_transaction<br>- transaction_account<br>- transaction_internal<br>- transaction_partnership<br>- transaction_education<br>- transaction_rating</p><p></p></td></tr><tr><td>language</td><td>string</td><td>false</td><td><p>Message languague values.<br>Giá trị nhận vào:</p><ul><li>language = <strong>VI</strong></li></ul><p>or</p><ul><li>language = <strong>EN</strong></li></ul><p><br>The default content of template will be transfered corresponding to the selected languague.</p></td></tr><tr><td>image_url</td><td>string</td><td>true</td><td>The image URL.</td></tr><tr><td>align</td><td>string</td><td>false</td><td><p></p><p>Align the content:</p><ul><li>left (or blank): Align to left.</li><li>center: Align to center.</li><li>right: Align to right.</li></ul></td></tr><tr><td>table</td><td>string</td><td>true</td><td><p><strong>The structure of an element in table</strong><br>{<br> "key": "key" // maxlength = 25 <br>"value": "the value of key" // maxlength = 100<br> }<br></p><p><mark style="color:red;">It is mandantory to have one of the two element below:</mark><br>VI: <br>{ <br>"key": "Mã..." // Start with "Mã", use for identify.<br>"value": "The value of key" <br>}</p><p>EN:<br> { <br>"key": "...Code..." // It is mandantory to have the string "Code" inside.<br>"value": "The value of key"<br> }<br><mark style="color:red;">Or:</mark><br>VI:</p><p> {<br> "key": "Tên khách hàng" //It is fixed with the value "Tên khách hàng",</p><p> "value": "The vlaue of key"<br> }</p><p>EN:</p><p> {<br> "key": "Customer Name" // It is fixed with value "Customer Name" ,</p><p>"value": "The value of key" <br>}<br><mark style="color:red;">Key “Trạng thái” / “Status” is the only one key that can use the "Style" paramter:</mark><br>VN: <br>{ <br>"key": "Trạng thái" //it is fixed with value "Trạng thái"<br> "value": "the value of key"<br> "style": "yellow" // Accepted values: green, blue, yellow, red, grey <br>}</p><p>EN:<br> { <br>"key": "Status" // It is fixed with value "Status"<br> "value": "the value of key" <br>"style": "yellow" // Accepted values: green, blue, yellow, red, grey<br> }</p><p><em><strong>****Note: Maximun 5 elements can be declared.</strong></em><br></p></td></tr><tr><td>button</td><td>string</td><td>false</td><td>Maximun 4 buttons can be added.</td></tr><tr><td>Sandbox</td><td>string</td><td>false</td><td>Sandbox option value (<strong>default is 0</strong>):<br>1: For testing purpose to verify the validation of the request. Message is not charged and sent to the receiver.<br>0: Message will be processed to the receiver properly.</td></tr></tbody></table>

***

* **Response**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d8e0f1f0702544b2acb456ca9ccfd111250"
}
```

**Valid request.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Invlid credential.**
{% endtab %}
{% endtabs %}

* **Response body**

| Parameter    | Type   | Description                                  |
| ------------ | ------ | -------------------------------------------- |
| CodeResult   | string | Response code.                               |
| SMSID        | string | The message id of eSMS system.               |
| ErrorMessage | string | The error message if the request is invalid. |

* *<mark style="color:yellow;">**The detail of error code can refer at**</mark>* [**Table of error codes**](/en/esms-api/table-of-error-codes) **.**
* *<mark style="color:yellow;">**Get the  sample of code for programing languagues to use in Postman refer at**</mark>* [**Link  of code samples**](https://samplefordevelopers.esms.vn/#850974b9-12cf-46f5-946c-e8e15aa3585b)**.**


# Send Zalo messages to request user's information

## HTTP request

\ <mark style="color:yellow;">**POST**</mark> [https://rest.esms.vn/MainService.svc/json/SendZaloFollowerMessage\_V5\_post\_json/](http://rest.esms.vn/MainService.svc/json/SendZaloFollowerMessage_V5_post_json/)

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/SendZaloFollowerMessage_V5_post_json/' \
--header 'Content-Type: application/json' \
--data '{
"ApiKey": "{{ApiKey}}",
"SecretKey": "{{SecretKey}}",
"OAID": "{{OAID}}",
"RequestId": "{{RequestId}}",
"CallbackUrl":"{{CallbackURL}}",
    "Payload": {
        "recipient": {
            "user_id": "{{UserID}}"
        },
        "message": {
            "attachment": {
                "type": "template",
                "payload": {
                    "template_type": "request_user_info",
                    "elements": [
                        {
                            "title": "{{Title}}",
                            "subtitle": "{{Subtitle}}",
                            "image_url": "{{ImageURL}}"
                        }
                    ]
                }
            }
        }
    }
}'
```

* **Body request**

<table><thead><tr><th width="135">Parameter</th><th width="120">Type</th><th width="152" data-type="checkbox">Required</th><th>Description</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>Your API Key</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Your Secret Key</td></tr><tr><td>OAID</td><td>string</td><td>true</td><td><p>Zalo OA Id is the Zalo Official Account Id of the organization. It can be obtained by accessing to the Zalo administrator page.</p><p><strong>Note: Pre-registration is required.</strong></p></td></tr><tr><td>User_id</td><td>string</td><td>true</td><td>The identification value of user at Zalo.</td></tr><tr><td>Title</td><td>string</td><td>true</td><td>The title of template.<br>Note: Max length is 100.</td></tr><tr><td>Subtitle</td><td>string</td><td>true</td><td>The subtitle of template.<br>Note: Max length is 500.</td></tr><tr><td>ImageUrl</td><td>string</td><td>true</td><td>The image URL. Only accept .PNG or .JPG file</td></tr><tr><td>RequestId</td><td>string</td><td>false</td><td>Partner ID passed to block duplicates and check if needed.<br>Maximum length 50 characters.<br>Each RequestId passed is valid for blocking for 24 hours.</td></tr><tr><td>CallbackUrl</td><td></td><td>false</td><td><p>The webhook URL that will receive the status of message after it processed to the operator. It is used for determine whether the SMS is succcessfully delivered to the receiver or failed.</p><p><br>See the sample request at <a href="https://samplefordevelopers.esms.vn/#20f85e1f-3d9e-4ff4-bc4f-8d9c9edbc88a">here</a>.<br>More detail at <a href="/pages/HxTrJlnDLexPUwac9BWb">here</a>.</p></td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d8e0f1f0702544b2acb456ca9ccfd111250"
}
```

**Valid request.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Invalid credential.**
{% endtab %}
{% endtabs %}

* **Response body**

| Parameter    | Type   | Description                                  |
| ------------ | ------ | -------------------------------------------- |
| CodeResult   | string | Response code.                               |
| SMSID        | string | The message id eSMS system.                  |
| ErrorMessage | string | The error message if the request is invalid. |

* *<mark style="color:yellow;">**The detail of error code can refer at**</mark>* [**Table of error codes**](/en/esms-api/table-of-error-codes) **.**
* *<mark style="color:yellow;">**Get the  sample of code for programing languagues to use in Postman refer at**</mark>* [**Link  of code samples**](https://samplefordevelopers.esms.vn/#850974b9-12cf-46f5-946c-e8e15aa3585b)**.**


# Send Journey ZNS message

The endpoint is ideal for sending the message to the Zalo users.

To send the journey message to Zalo&#x20;

Below is the requirement that is required to send the journey message to Zalo.

* Register and authorize Zalo Official Account (Zalo OA).
* Register the journey message template.&#x20;

You can contact your sale man or contact us via Hotline 0901888484 to complete the requirement.\
\
Below is the journey message sample:

<figure><img src="/files/QKfppgw4hZRwLZHhQ234" alt=""><figcaption></figcaption></figure>

## HTTP request

<mark style="color:yellow;">**`POST`**</mark> [https://rest.esms.vn/MainService.svc/json/SendZaloMessage\_V4\_post\_json/](http://rest.esms.vn/MainService.svc/json/SendZaloMessage_V4_post_json/)

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location 'https://rest.esms.vn//MainService.svc/json/SendZaloMessage_V4_post_json/' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey": "{{APIKEY}}",
    "SecretKey": "{{SecretKey}}",
    "Phone": "{{Phone}}",
    "Params": ["{{PARAM1}}","{{PARAM2}}","{{PARAM3}}"],
    "IsJourney": true,
    "OrderId": "{{ORDERID}}",
    "TempID": "{{TempID}}",
    "OAID": "{{OAID}}",
    "RequestId": "{{RequestId}}",
    "campaignid": "{{campaignid}}",
    "CallbackUrl":"{{CallbackUrl}}"
}'
```

* **Request body**

<table><thead><tr><th width="142">Tham số</th><th width="148">Kiểu dữ liệu </th><th width="141" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>Your API Key</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Your SecretKey</td></tr><tr><td>Phone</td><td>string</td><td>true</td><td>The Zalo user's phone number.</td></tr><tr><td>Params</td><td>Array</td><td>true</td><td>The array values of parameters in your template.<br>Note:<br>1. The input value have to put in the same of its order in your template.<br>2. If it's duplicated, just place it once.</td></tr><tr><td>IsJourney</td><td>string</td><td>true</td><td>True: it's the journey message.<br>False: it's not the journey message. Normal ZNS message.</td></tr><tr><td>OrderId</td><td>string</td><td>true</td><td>Id of the journey, it is used for marking the journey and required if sending the journey message.</td></tr><tr><td>TempID</td><td>string</td><td>true</td><td>The template of Zalo OA that you  have registered at eSMS.<br>For ZNS journey message, you have to register the template at Zalo.</td></tr><tr><td>OAID </td><td>string</td><td>true</td><td><p>Zalo OA Id is the Zalo Official Account Id of the organization. It can be obtained by accessing to the Zalo administrator page.</p><p><strong>Note: Pre-registration is required.</strong></p></td></tr><tr><td>campaignid</td><td>string</td><td>false</td><td>The campaign name of request</td></tr><tr><td>RequestId</td><td>string</td><td>false</td><td>Partner ID passed to block duplicates and check if needed.<br>Maximum length 50 characters.<br>Each RequestId passed is valid for blocking for 24 hours.</td></tr><tr><td>CallbackUrl</td><td>string</td><td>false</td><td><p>The webhook URL that will receive the status of message after it processed to the operator. It is used for determine whether the SMS is succcessfully delivered to the receiver or failed.</p><p><br>See the sample request at <a href="https://samplefordevelopers.esms.vn/#20f85e1f-3d9e-4ff4-bc4f-8d9c9edbc88a">here</a>.<br>More detail at <a href="/pages/HxTrJlnDLexPUwac9BWb">here</a>.</p></td></tr><tr><td>Sandbox</td><td>string</td><td>false</td><td>Sandbox option value (<strong>default is 0</strong>):<br>1: For testing purpose to verify the validation of the request. Message is not charged and sent to the receiver.<br>0: Message will be processed to the receiver properly.</td></tr></tbody></table>

***

* **Response**:

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d8e0f1f0702544b2acb456ca9ccfd111250"
}
```

**Valid request.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Invalid credential.**
{% endtab %}
{% endtabs %}

* **Response body**

| Parameter    | Type   | Description                                  |
| ------------ | ------ | -------------------------------------------- |
| CodeResult   | string | Response code.                               |
| SMSID        | string | The message id eSMS system.                  |
| ErrorMessage | string | The error message if the request is invalid. |

* *<mark style="color:yellow;">**The detail of error code can refer at**</mark>* [**Table of error codes**](/en/esms-api/table-of-error-codes) **.**
* *<mark style="color:yellow;">**Get the  sample of code for programing languagues to use in Postman refer at**</mark>* [**Link  of code samples**](https://samplefordevelopers.esms.vn/#850974b9-12cf-46f5-946c-e8e15aa3585b)**.**


# Send auto-generated SMS

This endpoint is ideal for sending the automatically generated OTP to the customer by brandname.

The OTP is generated randomly and handled by ViHAT.

## HTTP request

\ <mark style="color:green;">**`GET`**</mark> [https://rest.esms.vn/MainService.svc/json/SendMessageAutoGenCode\_V4\_get?Phone={Phone}\&ApiKey={ApiKey}\&SecretKey={SecretKey}\&TimeAlive={TimeAlive}\&NumCharOfCode={NumCharOfCode}\&Brandname={Brandname}\&Type=2\&message={Content}](http://rest.esms.vn/MainService.svc/json/SendMessageAutoGenCode_V4_get?Phone={Phone}\&ApiKey={ApiKey}\&SecretKey={SecretKey}\&TimeAlive={TimeAlive}\&NumCharOfCode={NumCharOfCode}\&Brandname={Brandname}\&Type=2\&message={Content})<br>

* **Response Type:** <mark style="color:orange;">application/json</mark>

{% code overflow="wrap" %}

```json
curl --location --globoff 'https://rest.esms.vn/MainService.svc/json/SendMessageAutoGenCode_V4_get?Phone={{Phone}}&ApiKey={{ApiKey}}&SecretKey={{SecretKey}}&TimeAlive={{TimeAlive}}&NumCharOfCode={{NumCharOfCode}}&Brandname={{Brandname}}&Type=2&message={{Content}}&IsNumber={{IsNumber}}'
```

{% endcode %}

* **Request body**

<table><thead><tr><th width="183">Parameter</th><th width="117">Type</th><th width="147" data-type="checkbox">Required</th><th>Description</th></tr></thead><tbody><tr><td>Phone</td><td>string</td><td>true</td><td>The phone number of receiver.</td></tr><tr><td>ApiKey</td><td>string</td><td>true</td><td>Your API Key.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Your Secret Key.</td></tr><tr><td>TimeAlive</td><td>string</td><td>false</td><td>The time-to-live of the OTP.<br>Unit of cal: <strong>minute</strong> <br>Min: 2<br>Max: 15<br>Do not pass this parameter, default validity is 5 minutes</td></tr><tr><td>NumCharOfCode</td><td>string</td><td>false</td><td>Number of characters in the OTP. Default is 6.</td></tr><tr><td>Brandname</td><td>string</td><td>true</td><td>The name of the sender is shown in the header of the customer's message. <br><strong>Pre-registration is required.</strong></td></tr><tr><td>Type</td><td>string</td><td>true</td><td>2: Send customer care message</td></tr><tr><td>message</td><td>string</td><td>true</td><td><br>The content of message, you shoule place the {OTP} in your content that will contain the the generated OTP.<br>Example:<br>To send the message "12345 is your code."<br>-> The content you should put is "{OTP} is your code."</td></tr><tr><td>IsNumber</td><td>string</td><td>false</td><td>0: mixed between digits and chars.<br>1: only digits.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d533459ee42b2b9525ba9eabf6a8156"
}
```

**Valid request**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Invalid credential.**
{% endtab %}
{% endtabs %}

* **Response body:**

| Parameter    | Type   | Description                                  |
| ------------ | ------ | -------------------------------------------- |
| CodeResult   | string | Response code.                               |
| SMSID        | string | The message id eSMS system.                  |
| ErrorMessage | string | The error message if the request is invalid. |

* *<mark style="color:yellow;">**The detail of error code can refer at**</mark>* [**Table of error codes**](/en/esms-api/table-of-error-codes) **.**
* *<mark style="color:yellow;">**Get the  sample of code for programing languagues to use in Postman refer at**</mark>* [**Link  of code samples**](https://samplefordevelopers.esms.vn/#850974b9-12cf-46f5-946c-e8e15aa3585b)**.**
* <mark style="color:orange;">**Use API Checkcode to check the validation of OTP. See it at**</mark> [**API Checkcode**](/en/esms-api/other-apis/check-code)**.**&#x20;


# The multichannel auto-generated OTP

This endpoint is ideal for sending the OTP using multichannel mechanism.

The message will switch to SMS in case of the ZNS message gets failed with the same OTP.

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> [https://rest.esms.vn/MainService.svc/json/SendMessageAutoGenCode\_V5](http://rest.esms.vn/MainService.svc/json/SendMessageAutoGenCode_V5)

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

{% code overflow="wrap" %}

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/SendMessageAutoGenCode_V5' \
--header 'Content-Type: application/json' \
--data '{
 "ApiKey": "{{ApiKey}}",
 "Phone": "{{Phone}}",
 "TimeAlive": "{{TimeAlive}}",
 "SecretKey": "{{SecretKey}}",
 "MultiChannelTempId": "{{MultiChannelTempId}}",
 "TypeId":"{{TypeId}}"
}'
```

{% endcode %}

* **Request body:**

<table><thead><tr><th width="207">Parameter</th><th width="124">Type</th><th width="143" data-type="checkbox">Required</th><th>Description</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>Your API Key.</td></tr><tr><td>Phone</td><td>string</td><td>true</td><td>The phone number of receiver.</td></tr><tr><td>TimeAlive</td><td>string</td><td>false</td><td>The time-to-live of the OTP.<br>Unit of cal: <strong>minute</strong> </td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Your Secret Key.</td></tr><tr><td>MultiChannelTempId</td><td>string</td><td>true</td><td>The Id vaue provided by ViHAT. <br>To use this endpoint, you must have the OA and brandname. <br>You have to send the ZNS and SMS template id to your saleman for creating.</td></tr><tr><td>TypeId</td><td>string</td><td>true</td><td>1: Only generate the OTP<br>2: Generate and send the OTP to phone.</td></tr></tbody></table>

***

* **Response**:&#x20;

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "d533459ee42b2b9525ba9eabf6a8156"
}
```

**Valid request.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "100",
    "CountRegenerate": 0,
    "SMSID": "ebe101db-87cd-4285-b97b-6a7a90455ded30"
}
```

**Invalid credential.**
{% endtab %}
{% endtabs %}

* **Response body**

| Parameter    | Type   | Description                                  |
| ------------ | ------ | -------------------------------------------- |
| CodeResult   | string | Response code.                               |
| SMSID        | string | The message id eSMS system.                  |
| ErrorMessage | string | The error message if the request is invalid. |

* *<mark style="color:yellow;">**The detail of error code can refer at**</mark>* [**Table of error codes**](/en/esms-api/table-of-error-codes) **.**
* *<mark style="color:yellow;">**Get the  sample of code for programing languagues to use in Postman refer at**</mark>* [**Link  of code samples**](https://samplefordevelopers.esms.vn/#850974b9-12cf-46f5-946c-e8e15aa3585b)**.**
* <mark style="color:orange;">**Use API Checkcode to check the validation of OTP. See it at**</mark> [**API Checkcode**](/en/esms-api/other-apis/check-code)**.**&#x20;


# Retrive and register functions

Version: v2\_08\_2022


# Get balance

This endpoint is used to get your balance of the account.

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> <http://rest.esms.vn/MainService.svc/json/GetBalance_json><br>

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location 'http://rest.esms.vn/MainService.svc/json/GetBalance_json' \
--header 'Content-Type: application/json' \
--data '{
"ApiKey":"{{ApiKey}}",
"SecretKey":"{{SecretKey}}"
}'
```

* **Request body:**

<table><thead><tr><th width="145">Parameter</th><th width="140">Type</th><th data-type="checkbox">Require</th><th>Description</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>Your API Key.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Your Secret Key.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "Balance": 36693,
    "CodeResponse": "100",
    "UserID": 9999
}
```

**Valid request.**
{% endtab %}

{% tab title="101" %}

```json
{
    "Balance": 0,
    "CodeResponse": "101",
    "ErrorMessage": "Authorize Failed"
}
```

**Invalid credentials.**
{% endtab %}
{% endtabs %}

* **Response body:**

| Parameter    | Type   | Description           |
| ------------ | ------ | --------------------- |
| Balance      | string | Your account balance. |
| CodeResponse | string | Response code.        |
| UserID       | string | The user' id at eSMS. |

* *<mark style="color:yellow;">**The detail of error code can refer at**</mark>* [**Table of error codes**](/en/esms-api/table-of-error-codes) **.**
* *<mark style="color:yellow;">**Get the  sample of code for programing languagues to use in Postman refer at**</mark>* [**Link  of code samples**](https://samplefordevelopers.esms.vn/#850974b9-12cf-46f5-946c-e8e15aa3585b)**.**


# Get the message status

This endpoint is ideal for retriving the SMS data in a time range.

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> [https://rest.esms.vn/MainService.svc/json/GetSmsSentData\_V2](http://rest.esms.vn/MainService.svc/json/GetSmsSentData_V2')

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/GetSmsSentData_V2' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey":"{{ApiKey}}",
    "SecretKey":"{{SecretKey}}",
    "SmsType":"{{SmsType}}",
    "From": "{{DateFrom}}",
    "To":"{{DateTo}}",
    "Page":{{Page}},
    "PageSize":{{PageSize}}
}'
```

* **Body request:**

<table><thead><tr><th width="172">Parameter</th><th width="133">Type</th><th width="180" data-type="checkbox">Required</th><th>Description</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>Your API Key.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Your Secret Key.</td></tr><tr><td>From </td><td>string</td><td>true</td><td>Start date<br>Format: <strong>yyyy-MM-dd HH:mm:ss</strong></td></tr><tr><td>To</td><td>string</td><td>true</td><td>End date<br>Format: <strong>yyyy-MM-dd HH:mm:ss</strong></td></tr><tr><td>Page</td><td>string</td><td>true</td><td>The start page.</td></tr><tr><td>PageSize</td><td>string</td><td>true</td><td><br>The number of SMS per page. Max: 500 SMS</td></tr><tr><td>SmsType</td><td>string</td><td>true</td><td>Type of SMS<br>1: Advertising SMS.<br>2: Customer care SMS.<br>8: Fixed number.<br>23: Viber OTT.<br>24: Priority ZNS.<br>25: Normally ZNS.<br>26: Zalo Follower.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```
{
    "CodeResult": "100",
    "CountTotal": 2
    "SentData": [
        {
            "Campaign": "Chiến dịch 02/10/2023",
            "Content": "Cam on quy khach da su dung dich vu cua chung toi. Chuc quy khach mot ngay tot lanh!",
            "Phone": "0901888484",
            "ReferenceId": "35781d6c25524e40a035c26663189549",
            "SellPrice": 345.0,
            "SendResult": 0,
            "SendStatus:5,
            "SentTime": "/Date(1705484048995+0700)/",
            "SmsId": 29028845,
            "SmsType": 2
        },
        {
            "Campaign": "Chiến dịch 02/10/2023",
            "Content": "Cam on quy khach da su dung dich vu cua chung toi. Chuc quy khach mot ngay tot lanh!",
            "Phone": "0901888484",
            "ReferenceId": "0aac72e0-ba9b-4348-8530-d18d105778db18",
            "SellPrice": 790.0000,
            "SendResult": 1,
            "SendStatus:5,
            "SentTime": "/Date(1705484048995+0700)/",
            "SmsId": 29028845,
            "SmsType": 2
        }
    ]
```

**Valid request.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "ErrorMessage": "Authorize Failed."
}
```

**Invalid credentials.**
{% endtab %}
{% endtabs %}

* **Response body:**

| Parameter    | Type   | Description                                                                                                                                                              |
| ------------ | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| CodeResult   | string | Response code.                                                                                                                                                           |
| CountTotal   | string | The total SMS in this period.                                                                                                                                            |
| Campaign     | string | Campaign name.                                                                                                                                                           |
| Content      | string | The message content                                                                                                                                                      |
| Phone        | string | The phone number of receiver.                                                                                                                                            |
| RefercenceId | string | The id that returned on sending function.                                                                                                                                |
| Sellprice    | string | Unit price of message.                                                                                                                                                   |
| SendResult   | string | <p>State of message.</p><p>1: Success<br>0: Failed<br>2: Not acknowdege</p>                                                                                              |
| SendStatus   | string | <p>0: Composing<br>1: On review.<br>2: Enqueue.<br>4: Rejected.<br>5: SENT.<br>7: SENT (waiting for last result)</p>                                                     |
| SentTime     | string | The time that message is sent out.                                                                                                                                       |
| SmsId        | string | ID of message in portal.                                                                                                                                                 |
| SmsType      | string | <p>Type of SMS<br>1: Advertising SMS.<br>2: Customer care SMS.<br>8: Fixed number.<br>23: Viber OTT.<br>24: Priority ZNS.<br>25: Normally ZNS.<br>26: Zalo Follower.</p> |

* *<mark style="color:yellow;">**The detail of error code can refer at**</mark>* [**Table of error codes**](/en/esms-api/table-of-error-codes) **.**
* *<mark style="color:yellow;">**Get the  sample of code for programing languagues to use in Postman refer at**</mark>* [**Link  of code samples**](https://samplefordevelopers.esms.vn/#850974b9-12cf-46f5-946c-e8e15aa3585b)**.**


# Get SMS by SMSID

This endpoint is used for retriving the message status that sent to ViHAT in last 7 days.

## HTTP request

\ <mark style="color:green;">**`GET`**</mark> <https://rest.esms.vn/MainService.svc/json/GetSendStatus?RefId={{SMSID}}&ApiKey={{ApiKey}}&SecretKey={{SecretKey}}>

* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location --globoff 'http://rest.esms.vn/MainService.svc/json/GetSendStatus?RefId={{SMSID}}&ApiKey={{ApiKey}}&SecretKey={{SecretKey}}'
```

* **Request body:**

<table><thead><tr><th width="139">Parameter</th><th width="129">Type</th><th width="155" data-type="checkbox">Required</th><th>Description</th></tr></thead><tbody><tr><td>RefId</td><td>string</td><td>true</td><td>The message id returned by ViHAT</td></tr><tr><td>ApiKey</td><td>string</td><td>true</td><td>Your API key.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Your Secret key.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```
{
    "CodeResponse": "100",
    "SMSID": "434a124c-7818-4f45-bdf2-7f7b07fff210100",
    "SendFailed": 0,
    "SendStatus": 5,
    "SendSuccess": 1,
    "TotalPrice": 850.0000,
    "TotalReceiver": 1,
    "TotalSent": 1
}
```

**Valid request.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResponse": "101",
    "SMSID": "47756317-0cbe-494a-9d02-c85703a1baff20"
}
```

**Invalid request.**
{% endtab %}
{% endtabs %}

* **Response body:**

<table><thead><tr><th width="174">Paramter</th><th width="155">Type</th><th>Description</th></tr></thead><tbody><tr><td>CodeResponse</td><td>string</td><td>Response code.</td></tr><tr><td>SMSID</td><td>string</td><td>The message id returned by ViHAT</td></tr><tr><td>SendFailed</td><td>string</td><td>Total of failed messages.</td></tr><tr><td>SendStatus</td><td>string</td><td>Message status<br>1: In review.<br>2: Waiting.<br>5: Send to operator.</td></tr><tr><td>SendSuccess</td><td>string</td><td>Total of success messages.</td></tr><tr><td>TotalPrice</td><td>string</td><td>The cost of submit.</td></tr><tr><td>TotalReceiver</td><td>string</td><td>Total phone numbers.</td></tr><tr><td>TotalSent</td><td>string</td><td>Total of phone numbers that sent to operator.</td></tr></tbody></table>

* *<mark style="color:yellow;">**The detail of error code can refer at**</mark>* [**Table of error codes**](/en/esms-api/table-of-error-codes) **.**
* *<mark style="color:yellow;">**Get the  sample of code for programing languagues to use in Postman refer at**</mark>* [**Link  of code samples**](https://samplefordevelopers.esms.vn/#850974b9-12cf-46f5-946c-e8e15aa3585b)**.**


# Get message details

This endpoint is used for retriving the list of receivers by SmsId in last 7 days.

The response is the detail of each message including the message status.

## HTTP request

\ <mark style="color:green;">**`GET`**</mark> <http://rest.esms.vn/MainService.svc/json/GetSmsReceiverStatus_get?&ApiKey={{ApiKey}}&SecretKey={{SecretKey}}&RefId={{SMSID}}>

* **Response Type:** <mark style="color:orange;">application/json</mark>

```
curl --location --globoff 'https://rest.esms.vn/MainService.svc/json/GetSmsReceiverStatus_get?ApiKey={{ApiKey}}&SecretKey={{SecretKey}}&RefId={{SMSID}}'
```

* **Request body:**

<table><thead><tr><th width="139">Parameter</th><th width="131">Type</th><th width="149" data-type="checkbox">Required</th><th>Description</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>Your API key.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Your Secret key.</td></tr><tr><td>RefId</td><td>string</td><td>true</td><td>The message id that returned by ViHAT</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "ReceiverList": [
        {
            "IsSent": true,
            "NetworkName": "Viettel",
            "Phone": "0901888484",
            "Retry": 0,
            "SentResult": true
        }
    ]
}
```

**Valid request.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "ErrorMessage": "Authorize Failed"
}
```

**Invalid credential.**
{% endtab %}
{% endtabs %}

* **Response body:**

| Paramter    | Type   | Description                                                                           |
| ----------- | ------ | ------------------------------------------------------------------------------------- |
| IsSent      | string | <p>The state of message:<br>true: Message is sent.<br>false: Message is not sent.</p> |
| NetworkName | string | The telco of phone number.                                                            |
| Phone       | string | The phone number of user.                                                             |
| Retry       | string | The number of retries.                                                                |
| SentResult  | string | <p>The result of message:<br>True: Success.<br>False: Failed.</p>                     |

* *<mark style="color:yellow;">**The detail of error code can refer at**</mark>* [**Table of error codes**](/en/esms-api/table-of-error-codes) **.**
* *<mark style="color:yellow;">**Get the  sample of code for programing languagues to use in Postman refer at**</mark>* [**Link  of code samples**](https://samplefordevelopers.esms.vn/#850974b9-12cf-46f5-946c-e8e15aa3585b)**.**


# Get list registered brandnames

This endpoint is ideal for getting the list of brandnames that registered at ViHAT.

## HTTP request

\ <mark style="color:green;">**`GET`**</mark> <https://rest.esms.vn/MainService.svc/json/GetListBrandname/{{ApiKey}}/{{SecretKey}}>

* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location --globoff 'https://rest.esms.vn/MainService.svc/json/GetListBrandname/{{ApiKey}}/{{SecretKey}}'
```

* **Request body:**

<table><thead><tr><th>Parameter</th><th width="152">Type</th><th width="134" data-type="checkbox">Required</th><th>Description</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>Your API key.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Your Secret key.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResponse": "100",
    "ListBrandName": [
        {
            "Brandname": "Baotrixemay",
            "Type": 2
        },
        {
            "Brandname": "QC_ONLINE",
            "Type": 1
        },
        {
            "Brandname": "BAT DONG SAN GIA TOT",
            "Type": 23
        }
    ]
}
```

**Valid request.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "ErrorMessage": "Authorize Failed"
}
```

**Invalid credentials.**
{% endtab %}
{% endtabs %}

* **Response body:**

| Paramter     | Type   | Description                                                                     |
| ------------ | ------ | ------------------------------------------------------------------------------- |
| CodeResponse | string | Response code.                                                                  |
| Brandname    | string | Name of brandname.                                                              |
| Type         | string | <p>Type of brandname:<br>1: Advertising.<br>2: Customer care.<br>23: Viber.</p> |

* *<mark style="color:yellow;">**The detail of error code can refer at**</mark>* [**Table of error codes**](/en/esms-api/table-of-error-codes) **.**
* *<mark style="color:yellow;">**Get the  sample of code for programing languagues to use in Postman refer at**</mark>* [**Link  of code samples**](https://samplefordevelopers.esms.vn/#850974b9-12cf-46f5-946c-e8e15aa3585b)**.**


# Get list customer care templates

This endpoint is used for getting the registered brandname template at ViHAT according to the given brandname.

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark>[ ](http://rest.esms.vn/MainService.svc/json/GetTemplate/)<https://rest.esms.vn/MainService.svc/json/GetTemplate/>

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/GetTemplate/' \
--header 'Content-Type: application/json' \
--data '{
 "ApiKey":"{{ApiKey}}",
 "SecretKey":"{{SecretKey}}",
 "SmsType":"2",
 "Brandname":"{{Brandname}}"
}'
```

* **Request body:**

<table><thead><tr><th>Paramter</th><th width="136">Type</th><th width="167" data-type="checkbox">Required</th><th>Description</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>Your API key.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Your Secret key.</td></tr><tr><td>SmsType</td><td>string</td><td>true</td><td>Type of brandname<br>2: Customer care</td></tr><tr><td>BrandName</td><td>string</td><td>true</td><td>The input brandname registered at ViHAT.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "BrandnameTemplates": [
        {
            "NetworkID": 6,
            "TempContent": "{P1,20} la ma xac minh dang ky Baotrixemay cua ban",
            "TempId": 458
        },
        {
            "NetworkID": 4,
            "TempContent": "Baotrixemay da nhan duoc so tien thanh toan {P2,20} VND luc {P2,20} cho don hang {P1,20}. Cam on quy khach!",
            "TempId": 466
        },
        {
            "NetworkID": 2,
            "TempContent": "Cam on quy khach da su dung dich vu cua chung toi. Chuc quy khach mot ngay tot lanh!",
            "TempId": 12640
        },
        {
            "NetworkID": 5,
            "TempContent": "Cam on quy khach da su dung dich vu cua chung toi. Chuc quy khach mot ngay tot lanh!",
            "TempId": 12647
        },
        {
            "NetworkID": 3,
            "TempContent": "Chuc mung sinh nhat {P2,50}. Kinh chuc QK co nhieu suc khoe, thanh cong va hanh phuc! Nhan dip sinh nhat xin gui den {P2,50} coupon {P2,20}. Tran trong.",
            "TempId": 12899
        },
        {
            "NetworkID": 1,
            "TempContent": "Cam on quy khach da su dung dich vu cua chung toi. Chuc quy khach mot ngay tot lanh!",
            "TempId": 12884
        }
    ],
    "CodeResult": "100",
    "ErrorMessage": "success"
}
```

**Valid request.**
{% endtab %}

{% tab title="101" %}

{% endtab %}

{% tab title="104" %}

```
```

{% endtab %}
{% endtabs %}

* **Response body:**

<table><thead><tr><th width="175">Thuộc tính</th><th>Kiểu dữ liệu</th><th>Mô tả</th></tr></thead><tbody><tr><td>NetworkID</td><td>string</td><td>1: Viettel<br>2: Mobi<br>3: Vinaphone<br>4: Vietnammobile<br>5: Gtel<br>6: Itel<br>7: Reddi</td></tr><tr><td>TempContent</td><td>string</td><td>Content đã đăng ký với nhà mạng</td></tr><tr><td>TempId</td><td>string</td><td>TempId của nhà mạng</td></tr></tbody></table>

* *<mark style="color:yellow;">**Thông tin chi tiết mã lỗi xem ở bảng:**</mark>* [**Mã lỗi**](/en/esms-api/table-of-error-codes) **.**
* *<mark style="color:yellow;">**Lấy code mẫu của các ngôn ngữ ở link:**</mark>* [**Code mẫu**](https://samplefordevelopers.esms.vn/#ca4176c1-a1af-4d93-bf29-81cd9dc3a85c) **.**


# Summary your customer care submit

This endpoint is ideal for getting the overview of your customer care submit.

The response will include the total cost of the submit as well as showing the invalid parameters that will help you re-compose the submit before sending to ViHAT.

## HTTP request

\ <mark style="color:green;">**`GET`**</mark> <https://rest.esms.vn/MainService.svc/json/SummaryMultipleMessage_V4_get?Phone={{Phone}}&Content={{Content}}&ApiKey={{ApiKey}}&SecretKey={{SecretKey}}&SmsType=2&BrandName={{BrandName}}>

* **Response Type:** <mark style="color:orange;">application/json</mark>

```
curl --location --globoff 'https://rest.esms.vn/MainService.svc/json/SummaryMultipleMessage_V4_get?Phone={{Phone}}&Content={{Content}}&ApiKey={{ApiKey}}&SecretKey={{SecretKey}}&SmsType=2&BrandName={{BrandName}}'
```

* **Request body:**

<table><thead><tr><th width="184">Parameter</th><th width="137">Type</th><th width="154" data-type="checkbox">Required</th><th>Description</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>Your API key.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Your Secret key.</td></tr><tr><td>Brandname</td><td>string</td><td>true</td><td>The name of the sender is shown in the header of the customer's message. <br><strong>Pre-registration is required.</strong></td></tr><tr><td>SmsType</td><td>string</td><td>true</td><td>Message type:<br>2: Customer care message.</td></tr><tr><td>Phone</td><td>string</td><td>true</td><td>The phone number of receiver.</td></tr><tr><td>Content</td><td>string</td><td>true</td><td>The content of message.</td></tr><tr><td>IsUnicode</td><td>string</td><td>false</td><td><p>Message charset value (<strong>default is 0</strong>):<br>1: Unicode.</p><p>0: Non-Unicode.</p></td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "ErrorMessage": "success",
    "TotalPrice": 850,
    "TotalReceiver": 1
}
```

**Valid request.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "ErrorMessage": "Authorize Failed."
}
```

**Invalid credential.**
{% endtab %}

{% tab title="104" %}

```
{
    "CodeResult": "104",
    "ErrorMessage": "Brand name code is not exist"
}
```

**Wrong brandname or brandname is inactive.**
{% endtab %}
{% endtabs %}

* **Response body:**

| Paramter      | Type   | Description                                  |
| ------------- | ------ | -------------------------------------------- |
| CodeResult    | string | Response code.                               |
| ErrorMessage  | string | The error message if the request is invalid. |
| TotalPrice    | string | The cost of submit.                          |
| TotalReceiver | string | Total valid receivers in submit.             |

* *<mark style="color:yellow;">**The detail of error code can refer at**</mark>* [**Table of error codes**](/en/esms-api/table-of-error-codes) **.**
* *<mark style="color:yellow;">**Get the  sample of code for programing languagues to use in Postman refer at**</mark>* [**Link  of code samples**](https://samplefordevelopers.esms.vn/#850974b9-12cf-46f5-946c-e8e15aa3585b)**.**


# Summary your advertising submit

This endpoint is ideal for getting the overview of your advertising submit.

The response will include the total cost of the submit as well as showing the invalid parameters that will help you re-compose the submit before sending to ViHAT.

## HTTP request&#x20;

\ <mark style="color:yellow;">**`POST`**</mark> <https://rest.esms.vn/MainService.svc/json/SummaryMultipleSMSBrandname/>

* **Content Type:** <mark style="color:orange;">text/plain</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```
curl --location 'https://rest.esms.vn/MainService.svc/json/SummaryMultipleSMSBrandname/' \
--header 'Content-Type: text/plain' \
--data '<RQST>
<APIKEY>{{APIKEY}}</APIKEY>
<SECRETKEY>{{SECRETKEY}}</SECRETKEY>
<CONTENT>{{CONTENT}}</CONTENT>
<SMSTYPE>1</SMSTYPE>
<BRANDNAME>{{BRANDNAME}}</BRANDNAME>
<CONTACTS>
<CUSTOMER><PHONE>{{PHONE}}</PHONE></CUSTOMER>
<CUSTOMER><PHONE>{{PHONE}}</PHONE></CUSTOMER>
<CUSTOMER><PHONE>{{PHONE}}</PHONE></CUSTOMER>
<CUSTOMER><PHONE>{{PHONE}}</PHONE></CUSTOMER>
<CUSTOMER><PHONE>{{PHONE}}</PHONE></CUSTOMER>
<CUSTOMER><PHONE>{{PHONE}}</PHONE></CUSTOMER>
</CONTACTS>
</RQST>'
```

* **Request body:**

<table><thead><tr><th width="187">Paramter</th><th width="146">Type</th><th width="137" data-type="checkbox">Required</th><th>Description</th></tr></thead><tbody><tr><td>APIKEY</td><td>string</td><td>true</td><td>Your API Key.</td></tr><tr><td>SECRETKEY</td><td>string</td><td>true</td><td>Your Secret Key.</td></tr><tr><td>CONTENT</td><td>string</td><td>true</td><td>The content of message.</td></tr><tr><td>SMSTYPE</td><td>string</td><td>true</td><td>Message type:<br>1: Advertising.</td></tr><tr><td>BRANDNAME</td><td>string</td><td>true</td><td>Advertising brandname.</td></tr><tr><td>PHONE</td><td>string</td><td>true</td><td>The phone number. </td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "ErrorMessage": "success",
    "TotalPrice": 1691300.0000,
    "TotalReceiver": 2997
}
```

**Valid request.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "CountRegenerate": 0,
    "ErrorMessage": "Authorize Failed"
}
```

**Invalid credential.**
{% endtab %}

{% tab title="104" %}

```json
{
    "CodeResult": "104",
    "ErrorMessage": "Brand name code is not exist"
}
```

**Wrong brandname or brandname is inactive.**
{% endtab %}
{% endtabs %}

* **Response body:**

| Paramter      | Type   | Description                                  |
| ------------- | ------ | -------------------------------------------- |
| CodeResult    | string | Response code.                               |
| ErrorMessage  | string | The error message if the request is invalid. |
| TotalPrice    | string | The cost of submit.                          |
| TotalReceiver | string | Total valid receivers in submit.             |

* *<mark style="color:yellow;">**The detail of error code can refer at**</mark>* [**Table of error codes**](/en/esms-api/table-of-error-codes) **.**
* *<mark style="color:yellow;">**Get the  sample of code for programing languagues to use in Postman refer at**</mark>* [**Link  of code samples**](https://samplefordevelopers.esms.vn/#850974b9-12cf-46f5-946c-e8e15aa3585b)**.**


# Get list OA

This endpoing is ideal for retriving the list of connected OA at ViHAT.

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> <https://rest.esms.vn/MainService.svc/json/ZNS/GetListZOA/>

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/ZNS/GetListZOA/' \
--header 'Content-Type: application/json' \
--data '{
 "ApiKey":"{{ApiKey}}",
 "SecretKey":"{{SecretKey}}"
}'
```

* **Request body:**

<table><thead><tr><th width="162">Paramter</th><th width="136">Type</th><th width="143" data-type="checkbox">Required</th><th>Description</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>Your API key.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Your Secret key.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```json
{
    "CodeResult": "100",
    "ErrorMessage": "success",
    "ZOAList": [
        {
            "OAID": "745830328927467685",
            "OAName": "Hệ thống ESMS Marketing"
        },
        {
            "OAID": "4097311281936189049",
            "OAName": "SVoucher"
        }
    ]
}   
```

**Valid request.**
{% endtab %}

{% tab title="101" %}

```json
{
    "CodeResult": "101",
    "ErrorMessage": "Authorize Failed."
}
```

**Invalid credential.**
{% endtab %}
{% endtabs %}

* **Body response:**

<table><thead><tr><th width="168">Paramter</th><th width="165">Type</th><th>Description</th></tr></thead><tbody><tr><td>OAID</td><td>string</td><td>Zalo OA ID is the id at Zalo Official Account of the company or organization.<br>The company need to login to the Zalo OA management page to get this value.<br><strong>Note: Pre-registration is required.</strong></td></tr><tr><td>OAName</td><td>string</td><td>The name of OA according to the Id</td></tr></tbody></table>

* *<mark style="color:yellow;">**The detail of error code can refer at**</mark>* [**Table of error codes**](/en/esms-api/table-of-error-codes) **.**
* *<mark style="color:yellow;">**Get the  sample of code for programing languagues to use in Postman refer at**</mark>* [**Link  of code samples**](https://samplefordevelopers.esms.vn/#850974b9-12cf-46f5-946c-e8e15aa3585b)**.**


# Get list templates of OA

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> <https://rest.esms.vn/MainService.svc/json/GetTemplate/>

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/GetTemplate/' \
--header 'Content-Type: application/json' \
--data '{
  "ApiKey": "{{ApiKey}}",
  "SecretKey": "{{SecretKey}}",
  "OAId": "{{OAId}}",
  "SmsType": "{{SmsType}}"
}'
```

* **Request body**:

<table><thead><tr><th width="159">Paramter</th><th width="126">Type</th><th width="155" data-type="checkbox">Required</th><th>Type</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>Your API key.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Your Secret key.</td></tr><tr><td>OAId</td><td>string</td><td>true</td><td>ID of OA</td></tr><tr><td>SmsType</td><td>string</td><td>true</td><td>Type of SMS<br>24: Priority.<br>25: Normal.</td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```
{
    "CodeResult": "100",
    "ErrorMessage": "success",
    "ZNSTemplates": [
        {
            "TempContent": "<div class=\"group-desc\" style=\"box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); color: #131820; font-family: Muli, sans-serif; font-size: 16px;\"> <p style=\"box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); margin: 0px; padding: 0px; color: #394e60; font-size: 0.875rem; line-height: 20px;\">Mã OTP của bạn là</p> </div> <p><span class=\"otp-code\" style=\"box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-weight: bold; color: #131820; font-size: 1.5rem; letter-spacing: 3.75px; line-height: 24px; display: block; padding: 12px 0px; font-family: Muli, sans-serif;\">{{otp}}</span></p> <div class=\"group-desc\" style=\"box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); color: #131820; font-family: Muli, sans-serif; font-size: 16px;\"> <p style=\"box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); margin: 0px; padding: 0px; color: #394e60; font-size: 0.875rem; line-height: 20px;\">Không tiết lộ cho bất kỳ ai, Mã xác nhận sẽ có hiệu lực trong 5 phút.</p> </div>",
            "TempId": 205644,
            "TempName": "Xác nhận đăng ký dịch vụ",
            "ZNSTempDetail": [
                {
                    "Limit": 10,
                    "Param": "otp",
                    "ParamLevel": 1,
                    "RequireType": "type_text"
                }
            ]
        }
    ]
}
```

**Valid request.**
{% endtab %}

{% tab title="101" %}

```
{
    "CodeResult": "101",
    "ErrorMessage": "Authorize Failed"
}
```

**Invalid credential.**
{% endtab %}
{% endtabs %}

* **Response body**:

<table><thead><tr><th width="174">Parameter</th><th width="201">Type</th><th>Description</th></tr></thead><tbody><tr><td>TempContent</td><td>string</td><td>The content of template in html.</td></tr><tr><td>Tempid</td><td>string</td><td>ID of template.</td></tr><tr><td>TempName</td><td>string</td><td>Name of template.</td></tr><tr><td>ZNSTempDetail</td><td>Array object</td><td>Detail of template.</td></tr><tr><td>Limit</td><td>string</td><td>The length limit of parameter.</td></tr><tr><td>Param</td><td>string</td><td>Name of parameter.</td></tr><tr><td>ParamLevel</td><td>string</td><td>Parameter index.</td></tr><tr><td>RequireType</td><td>string</td><td>Data type of paramter.</td></tr></tbody></table>

* *<mark style="color:yellow;">**The detail of error code can refer at**</mark>* [**Table of error codes**](/en/esms-api/table-of-error-codes) **.**
* *<mark style="color:yellow;">**Get the  sample of code for programing languagues to use in Postman refer at**</mark>* [**Link  of code samples**](https://samplefordevelopers.esms.vn/#850974b9-12cf-46f5-946c-e8e15aa3585b)**.**


# Summary Zalo message

## HTTP request

\ <mark style="color:yellow;">**`POST`**</mark> <https://rest.esms.vn/MainService.svc/json/SummaryZaloMessage_V4_post_json/><br>

* **Content Type:** <mark style="color:orange;">application/json</mark>
* **Response Type:** <mark style="color:orange;">application/json</mark>

```json
curl --location 'https://rest.esms.vn/MainService.svc/json/SummaryZaloMessage_V4_post_json/' \
--header 'Content-Type: application/json' \
--data '{
    "ApiKey": "{{ApiKey}}",
    "SecretKey": "{{SecretKey}}",
    "Phone": "{{Phone}}",
    "Params": [
        "{{value1}}",
        "{{value2}}",
        "{{value3}}"
    ],
    "TempID": "{{TempID}}",
    "OAID": "{{OAID}}"
}'
```

* **Request body:**

<table><thead><tr><th width="146">Tham số</th><th width="132">Kiểu dữ liệu </th><th width="143" data-type="checkbox">Tính bắt buộc</th><th>Mô tả</th></tr></thead><tbody><tr><td>ApiKey</td><td>string</td><td>true</td><td>Your API Key.</td></tr><tr><td>SecretKey</td><td>string</td><td>true</td><td>Your Secret Key.</td></tr><tr><td>Phone</td><td>string</td><td>true</td><td>The phone number of receivers.</td></tr><tr><td>Params</td><td>string</td><td>true</td><td><p></p><p>The values that need to pass according to the template variables.<br>*Notes:</p><ol><li>The values must be placed in the correct order with the registered template.</li><li>If the parameter is duplicated, just place one.</li></ol></td></tr><tr><td>TempID</td><td>string</td><td>true</td><td>Template của The ID of template for the OA that is registered and provided by eSMS at Zalo to partner.<br>Each template will have a specified structure of body.</td></tr><tr><td>OAID</td><td>string</td><td>true</td><td><p>Zalo OA Id is the Zalo Official Account Id of the organization. It can be obtained by accessing to the Zalo administrator page.</p><p><strong>Note: Pre-registration is required.</strong></p></td></tr></tbody></table>

***

* **Response:**

{% tabs %}
{% tab title="100" %}

```
{
    "CodeResult": "100",
    "ErrorMessage": "success",
    "TotalPrice": 660.0000,
    "TotalReceiver": 1
}
```

**Valid request.**
{% endtab %}

{% tab title="101" %}

```
{
    "CodeResult": "101",
    "ErrorMessage": "Authorize Failed"
}
```

**Invalid credential.**
{% endtab %}
{% endtabs %}

* **Response body:**

| Paramter      | Type   | Description                                  |
| ------------- | ------ | -------------------------------------------- |
| CodeResult    | string | Response code.                               |
| ErrorMessage  | string | The error message if the request is invalid. |
| TotalPrice    | string | The cost of submit.                          |
| TotalReceiver | string | Total valid receivers in submit.             |

* *<mark style="color:yellow;">**The detail of error code can refer at**</mark>* [**Table of error codes**](/en/esms-api/table-of-error-codes) **.**
* *<mark style="color:yellow;">**Get the  sample of code for programing languagues to use in Postman refer at**</mark>* [**Link  of code samples**](https://samplefordevelopers.esms.vn/#850974b9-12cf-46f5-946c-e8e15aa3585b)**.**




---

[Next Page](/llms-full.txt/1)

