Gửi thông báo theo mẫu đính kèm danh sách
Quyền cần có: Quyền gửi tin và thông báo qua OA
HTTP request
- URL: https://openapi.zalo.me/v2.0/oa/message
- Method: POST
- Content Type: application/json
- Response Type: text/json


Example request
curl
-X POST
-H "Content-Type: application/json"
-H 'access_token: <your_access_token>'
-d '{
"recipient": {
"user_id": "2468458835296117922"
},
"message": {
"attachment": {
"type": "template",
"payload": {
"template_type": "list",
"elements": [
{
"title": "Official Account API",
"subtitle": "There Is No Limit To What You Can Accomplish Using Zalo",
"image_url": "https://stc-developers.zdn.vn/images/bg_1.jpg",
"default_action": {
"type": "oa.open.url",
"url": "https://developers.zalo.me/docs/api/official-account-api-147"
}
},
{
"title": "Article API",
"image_url": "https://stc-zaloprofile.zdn.vn/pc/v1/images/zalo_sharelogo.png",
"default_action": {
"type": "oa.open.url",
"url": "https://developers.zalo.me/docs/api/article-api-151"
}
},
{
"title": "Social API",
"image_url": "https://stc-zaloprofile.zdn.vn/pc/v1/images/zalo_sharelogo.png",
"default_action": {
"type": "oa.open.url",
"url": "https://developers.zalo.me/docs/api/social-api-4"
}
}
]
}
}
}
}' "https://openapi.zalo.me/v2.0/oa/message"
Tham số header
| Tham số | Kiểu dữ liệu | Tính bắt buộc | Mô tả |
|---|---|---|---|
| access_token | string | yes | Token cho phép ứng dụng đại diện OA gọi API. Xem chi tiết cách lấy access token tại đây. |
Cấu trúc body của request
| Tham số | Kiểu dữ liệu | Tính bắt buộc | Mô tả |
|---|---|---|---|
recipient | object | yes | Thông tin người nhận |
message | object | yes | Nội dung cần gửi |
Cấu trúc thuộc tính recipient
| Tham số | Kiểu dữ liệu | Tính bắt buộc | Mô tả |
|---|---|---|---|
user_id | string | yes | ID của người nhận (nhận được thông qua API truy xuất chi tiết người dùng, API truy xuất danh sách người dùng) |
Cấu trúc thuộc tính message
| Tham số | Kiểu dữ liệu | Tính bắt buộc | Mô tả |
|---|---|---|---|
attachment | object | yes | Attachment cần gửi |
Cấu trúc thuộc tính message.attachment
| Tham số | Kiểu dữ liệu | Tính bắt buộc | Mô tả |
type | string | yes | Loại attachment. Giá trị nhận vào bắt buộc:
|
payload | object | yes | Chứa payload của attachment muốn gửi |
Cấu trúc thuộc tính message.attachment.payload
| Tham số | Kiểu dữ liệu | Tính bắt buộc | Mô tả |
template_type | string | yes | Loại template. Với template gửi thông báo theo mẫu đính kèm ảnh, giá trị nhận vào:
Tham khảo các template khác tại đây. |
elements | array | yes | OA API hỗ trợ gửi thông báo theo 2 dạng danh sách:
|
Example respond
{
"data": {
"message_id": "e6fa968f027",
"user_id": "2468458835296117922"
},
"error": 0,
"message": "Success"
}
Cấu trúc thuộc tính data
| Thuộc tính | Kiểu dữ liệu | Mô tả |
message_id | string | ID của thông báo |
user_id | string | ID của người nhận |