Gửi tin ZNS
Gửi tin nhắn ZNS tới số điện thoại
HTTP request
URL: https://zns.api.gobysend.com/api/message/send
Method: POST
Content Type: application/json
Response Type: application/json
Example request
curl
-X POST
-H "Content-Type: application/json" -d '{
"phone": "84987654321",
"template_id": "7895417a7d3f9461cd2e",
"template_data": {
"ky": "1",
"thang": "4/2020",
"start_date": "20/03/2020",
"end_date": "20/04/2020",
"customer": "Nguyễn Thị Hoàng Anh",
"cid": "PE010299485",
"address": "VNG Campus, TP.HCM",
"amount": "100",
"total": "100000",
},
"tracking_id":"tracking_id",
"has_fallback_sms": true,
"fallback_sms": {
"brandname": "Freetalk",
"content": "Nội dung tin nhắn cần gửi",
"delay_seconds": 60
}
}' "https://zns.api.gobysend.com/api/message/send"
Tham số header
Tham số
Kiểu dữ liệu
Tính bắt buộc
Mô tả
Cấu trúc body của request
Tham số
Kiểu dữ liệu
Tính bắt buộc
Mô tả
phone
string
yes
SĐT của người nhận.
Lưu ý: SĐT phải được liên kết với tài khoản Zalo và được viết ở định dạng chuẩn hóa theo mã quốc gia. (VD: SĐT 0987654321 viết theo định dạng chuẩn hóa của Việt Nam là 84987654321)
template_id
string
yes
ID của template muốn sử dụng.
template_id sẽ được phía Zalo cung cấp riêng cho từng đối tác.
template_data
JSON object
yes
Các thuộc tính của template mà đối tác đã đăng ký với Zalo.
Lưu ý: Cấu trúc template_data được quy định riêng ứng với từng template.
tracking_id
string
yes
Mã số đánh dấu lần gọi API của đối tác, do đối tác định nghĩa. Đối tác có thể dùng tracking_id để đối soát mà không phụ thuộc vào message_id của Zalo cung cấp.
Lưu ý: Zalo khuyến khích sử dụng tham số có độ dài tối đa 48 ký tự và không chứa kí tự đặc biệt.
has_fallback_sms
boolean
no
Tham số cho biết tin nhắn có sử dụng SMS thay thế khi không gửi thành công sau 1 khoảng thời gian hay không.
Có 2 giá trị là true hoặc false. Có thể bỏ trống nếu không sử dụng.
fallback_sms
JSON object
no
Xem chi tiết ở bảng dưới
Tham số fallback_sms
Tham số
Kiểu dữ liệu
Tính bắt buộc
Mô tả
brandname
string
yes
Tên SMS brandname dùng để gửi tin
content
string
yes
Nội dung tin nhắn muốn gửi đi. Độ dài tối đa 450 ký tự.
delay_seconds
integer
yes
Thời gian chờ tin nhắn ZNS trước khi kiểm tra trạng thái và gửi fallback SMS.
Sau khoảng thời gian chờ này nếu tin ZNS không gửi thành công hệ thống sẽ gửi tin SMS thay thế.
Ghi chú: ZNS API Send Message có hỗ trợ mã hoá RSA. Xem thêm API Gửi tin ZNS với mã hóa RSA hoặc trao đổi trực tiếp với hỗ trợ kỹ thuật của Gobysend trong lúc thực thi tích hợp nếu doanh nghiệp có yêu cầu.
Example response
{
"error": 0,
"message": "Success",
"data": {
"msg_id": "a4d0243feee163bd3af2"
}
}
Cấu trúc thuộc tính data
Thuộc tính
Kiểu dữ liệu
Mô tả
msg_id
string
ID của thông báo ZNS được sinh ra bởi GobyZNS để truy vấn trạng thái gửi tin
English version:
HTTP request
URL: https://zns.api.gobysend.com/api/message/send
Method: POST
Content Type: application/json
Response Type: application/json
Example request
curl
-X POST
-H "Content-Type: application/json" -d '{
"phone": "84987654321",
"template_id": "7895417a7d3f9461cd2e",
"template_data": {
"ky": "1",
"thang": "4/2020",
"start_date": "20/03/2020",
"end_date": "20/04/2020",
"customer": "Nguyễn Thị Hoàng Anh",
"cid": "PE010299485",
"address": "VNG Campus, TP.HCM",
"amount": "100",
"total": "100000",
},
"tracking_id":"tracking_id",
"has_fallback_sms": true,
"fallback_sms": {
"brandname": "Freetalk",
"content": "Nội dung tin nhắn cần gửi",
"delay_seconds": 60
}
}' "https://zns.api.gobysend.com/api/message/send"
Header param
Param
Data type
Compulsory
Description
Request body structure
Param
Data type
Compulsory
Description
phone
string
yes
Recipient phone number
Note: Phone number must be linked to the Zalo account and written in normalized format of the country code
template_id
string
yes
ID of the template you want to use Zalo will provide template ID for each business partner
template_data
JSON object
yes
Attributes of the template that the partner has registered with zalo. Note: the template_data structure is set specifically for each template
tracking_id
string
yes
Your partner' s API number markup, defined by the partner. Partner can use tracking_id to check without dependence on the message_id of zalo. Note: Zalo encourages using a maximum length of 48 characters, and does not contain special characters
has_fallback_sms
boolean
no
The parameter indicates whether a message uses an alternative sms when it is not successfully sent after a period of time. There are two values true or false. You can leave it blank if you don' t use it.
fallback_sms
JSON object
no
See details in the table below
Parameter fallback_sms
Param
Data type
Compulsory
Description
brandname
string
yes
SMS Brandname
content
string
yes
Message content wants to send. Maximum length 450 characters.
delay_seconds
string
yes
ZNS message timeout before checking status and sending fallback SMS. After this timeout period, if the ZNS message is not sent successfully, the system will send a replacement SMS.
Note: The ZNS API Send Message supports RSA encryption. See more at Send Messages with RSA encryption or talk directly with Gobysend's technical support during integration implementation if required.
Example request
{
"error": 0,
"message": "Success",
"data": {
"msg_id": "a4d0243feee163bd3af2"
}
}
Data attribute structure
Attribute
Data type
Description
msg_id
string
The ID of the ZNS message is created by GobyZNS to query the sending state.
Last updated