Hệ thống hỗ trợ 2 phương thức xác thực:
X-API-Key hoặc query parameter
api_key
# Sử dụng header (khuyến nghị)
curl -H "X-API-Key: zalo_your_api_key_here" http://localhost:3000/api/accounts
# Hoặc sử dụng query parameter
curl "http://localhost:3000/api/accounts?api_key=zalo_your_api_key_here"
💡 Lưu ý: API key có format zalo_ + 64 ký tự hex. Liên hệ admin để được cấp API
key.
Mục đích: Lấy danh sách tất cả tài khoản Zalo đã đăng nhập.
Endpoint: GET /api/accounts
Parameters: Không có
Response:
{
"success": true,
"data": [
{
"ownId": "123456789",
"phoneNumber": "0901234567",
"proxy": "http://proxy1:8080",
"displayName": "0901234567 (123456789)",
"isOnline": true
}
],
"total": 1
}
Ví dụ curl:
# Với API key (khuyến nghị)
curl -H "X-API-Key: zalo_your_api_key_here" http://localhost:3000/api/accounts
# Hoặc với query parameter
curl "http://localhost:3000/api/accounts?api_key=zalo_your_api_key_here"
# Không có API key (cần đăng nhập session)
curl http://localhost:3000/api/accounts
Mục đích: Lấy thông tin chi tiết của một tài khoản cụ thể.
Endpoint: GET /api/accounts/:ownId
Parameters:
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| ownId | string (URL param) | ID tài khoản Zalo cần lấy thông tin. | Có |
Response:
{
"success": true,
"data": {
"ownId": "123456789",
"phoneNumber": "0901234567",
"proxy": "http://proxy1:8080",
"profile": {
"displayName": "Tên hiển thị",
"avatar": "avatar_url"
},
"isOnline": true
}
}
Ví dụ curl:
# Với API key (khuyến nghị)
curl -H "X-API-Key: zalo_your_api_key_here" http://localhost:3000/api/accounts/123456789
# Hoặc với query parameter
curl "http://localhost:3000/api/accounts/123456789?api_key=zalo_your_api_key_here"
# Không có API key (cần đăng nhập session)
curl http://localhost:3000/api/accounts/123456789
Mục đích: Lấy danh sách tài khoản Zalo đã đăng nhập (qua QR code). Đây là endpoint yêu cầu API key
với quyền zalo:account_management.
Endpoint: GET /api/zalo-accounts
Permission: zalo:account_management
Parameters: Không có
Response:
{
"success": true,
"data": [
{
"ownId": "123456789",
"phoneNumber": "0901234567",
"proxy": "http://proxy1:8080",
"displayName": "0901234567 (123456789)",
"isOnline": true
}
],
"total": 1
}
Ví dụ curl:
# Với API key (bắt buộc)
curl -H "X-API-Key: zalo_your_api_key_here" http://localhost:3000/api/zalo-accounts
# Hoặc với query parameter
curl "http://localhost:3000/api/zalo-accounts?api_key=zalo_your_api_key_here"
💡 So sánh với /api/accounts:
/api/accounts: Auth linh hoạt (optional API key), có pagination/search, dùng
AccountController/api/zalo-accounts: Bắt buộc API key + permission zalo:account_management, trả về danh
sách đơn giảnMục đích: Lấy thông tin chi tiết một tài khoản Zalo cụ thể. Yêu cầu API key.
Endpoint: GET /api/zalo-accounts/:ownId
Permission: zalo:account_management
Parameters:
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| ownId | string (URL param) | ID tài khoản Zalo cần lấy thông tin. | Có |
Response:
{
"success": true,
"data": {
"ownId": "123456789",
"phoneNumber": "0901234567",
"proxy": "http://proxy1:8080",
"profile": {
"displayName": "Tên hiển thị",
"avatar": "avatar_url"
},
"isOnline": true
}
}
Ví dụ curl:
# Với API key (bắt buộc)
curl -H "X-API-Key: zalo_your_api_key_here" http://localhost:3000/api/zalo-accounts/123456789
# Hoặc với query parameter
curl "http://localhost:3000/api/zalo-accounts/123456789?api_key=zalo_your_api_key_here"
Lưu ý: Các APIs này sử dụng accountSelection thay vì ownId, giúp dễ dàng
sử dụng từ n8n workflows.
Mục đích: Tìm kiếm người dùng dựa trên số điện thoại với account selection.
Endpoint: POST /api/findUserByAccount
Parameters:
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| phone | string | Số điện thoại của người dùng cần tìm. | Có |
| accountSelection | string | Số điện thoại hoặc ownId của tài khoản để thực hiện tìm kiếm. | Có |
Response:
{
"success": true,
"data": { /* Kết quả tìm kiếm */ },
"usedAccount": {
"ownId": "123456789",
"phoneNumber": "0901234567"
}
}
Ví dụ:
{
"phone": "0987654321",
"accountSelection": "0901234567"
}
Ví dụ curl:
# Với API key (khuyến nghị)
curl -X POST -H "Content-Type: application/json" -H "X-API-Key: zalo_your_api_key_here" -d '{
"phone": "0987654321",
"accountSelection": "0901234567"
}' http://localhost:3000/api/findUserByAccount
# Hoặc với query parameter
curl -X POST -H "Content-Type: application/json" -d '{
"phone": "0987654321",
"accountSelection": "0901234567"
}' "http://localhost:3000/api/findUserByAccount?api_key=zalo_your_api_key_here"
# Không có API key (cần đăng nhập session)
curl -X POST -H "Content-Type: application/json" -d '{
"phone": "0987654321",
"accountSelection": "0901234567"
}' http://localhost:3000/api/findUserByAccount
Mục đích: Gửi tin nhắn với account selection.
Endpoint: POST /api/sendMessageByAccount
Parameters:
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| message | string | Nội dung tin nhắn | Có |
| threadId | string | ID người dùng/nhóm | Có |
| type | string | "user" hoặc "group" | Không |
| accountSelection | string | Số điện thoại hoặc ownId | Có |
Ví dụ:
{
"message": "Hello from n8n!",
"threadId": "user_thread_id",
"type": "user",
"accountSelection": "0901234567"
}
Ví dụ curl:
# Với API key (khuyến nghị)
curl -X POST -H "Content-Type: application/json" -H "X-API-Key: zalo_your_api_key_here" -d '{
"message": "Hello from n8n!",
"threadId": "user_thread_id",
"type": "user",
"accountSelection": "0901234567"
}' http://localhost:3000/api/sendMessageByAccount
# Hoặc với query parameter
curl -X POST -H "Content-Type: application/json" -d '{
"message": "Hello from n8n!",
"threadId": "user_thread_id",
"type": "user",
"accountSelection": "0901234567"
}' "http://localhost:3000/api/sendMessageByAccount?api_key=zalo_your_api_key_here"
# Không có API key (cần đăng nhập session)
curl -X POST -H "Content-Type: application/json" -d '{
"message": "Hello from n8n!",
"threadId": "user_thread_id",
"type": "user",
"accountSelection": "0901234567"
}' http://localhost:3000/api/sendMessageByAccount
Mục đích: Gửi hình ảnh với account selection.
Endpoint: POST /api/sendImageByAccount
Parameters:
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| imagePath | string | URL hình ảnh | Có |
| threadId | string | ID người dùng/nhóm | Có |
| type | string | "user" hoặc "group" | Không |
| accountSelection | string | Số điện thoại hoặc ownId | Có |
Ví dụ:
{
"imagePath": "https://example.com/image.jpg",
"threadId": "user_thread_id",
"type": "user",
"accountSelection": "0901234567"
}
Ví dụ curl:
# Với API key (khuyến nghị)
curl -X POST -H "Content-Type: application/json" -H "X-API-Key: zalo_your_api_key_here" -d '{
"imagePath": "https://example.com/image.jpg",
"threadId": "user_thread_id",
"type": "user",
"accountSelection": "0901234567"
}' http://localhost:3000/api/sendImageByAccount
# Hoặc với query parameter
curl -X POST -H "Content-Type: application/json" -d '{
"imagePath": "https://example.com/image.jpg",
"threadId": "user_thread_id",
"type": "user",
"accountSelection": "0901234567"
}' "http://localhost:3000/api/sendImageByAccount?api_key=zalo_your_api_key_here"
# Không có API key (cần đăng nhập session)
curl -X POST -H "Content-Type: application/json" -d '{
"imagePath": "https://example.com/image.jpg",
"threadId": "user_thread_id",
"type": "user",
"accountSelection": "0901234567"
}' http://localhost:3000/api/sendImageByAccount
# Với API key (khuyến nghị)
curl -X POST -H "Content-Type: application/json" -H "X-API-Key: zalo_your_api_key_here" -d '{
"userId": "user_id_here",
"accountSelection": "0901234567"
}' http://localhost:3000/api/getUserInfoByAccount
# Hoặc với query parameter
curl -X POST -H "Content-Type: application/json" -d '{
"userId": "user_id_here",
"accountSelection": "0901234567"
}' "http://localhost:3000/api/getUserInfoByAccount?api_key=zalo_your_api_key_here"
# Với API key (khuyến nghị)
curl -X POST -H "Content-Type: application/json" -H "X-API-Key: zalo_your_api_key_here" -d '{
"userId": "user_id_here",
"message": "Xin chào, hãy kết bạn với tôi!",
"accountSelection": "0901234567"
}' http://localhost:3000/api/sendFriendRequestByAccount
# Hoặc với query parameter
curl -X POST -H "Content-Type: application/json" -d '{
"userId": "user_id_here",
"message": "Xin chào, hãy kết bạn với tôi!",
"accountSelection": "0901234567"
}' "http://localhost:3000/api/sendFriendRequestByAccount?api_key=zalo_your_api_key_here"
# Với API key (khuyến nghị)
curl -X POST -H "Content-Type: application/json" -H "X-API-Key: zalo_your_api_key_here" -d '{
"members": ["user_id_1", "user_id_2"],
"name": "Tên nhóm mới",
"accountSelection": "0901234567"
}' http://localhost:3000/api/createGroupByAccount
# Hoặc với query parameter
curl -X POST -H "Content-Type: application/json" -d '{
"members": ["user_id_1", "user_id_2"],
"name": "Tên nhóm mới",
"accountSelection": "0901234567"
}' "http://localhost:3000/api/createGroupByAccount?api_key=zalo_your_api_key_here"
# Với API key (khuyến nghị)
curl -X POST -H "Content-Type: application/json" -H "X-API-Key: zalo_your_api_key_here" -d '{
"groupId": "group_id_here",
"accountSelection": "0901234567"
}' http://localhost:3000/api/getGroupInfoByAccount
# Hoặc với query parameter
curl -X POST -H "Content-Type: application/json" -d '{
"groupId": "group_id_here",
"accountSelection": "0901234567"
}' "http://localhost:3000/api/getGroupInfoByAccount?api_key=zalo_your_api_key_here"
# Với API key (khuyến nghị)
curl -X POST -H "Content-Type: application/json" -H "X-API-Key: zalo_your_api_key_here" -d '{
"groupId": "group_id_here",
"memberId": "user_id_here",
"accountSelection": "0901234567"
}' http://localhost:3000/api/addUserToGroupByAccount
# Hoặc với query parameter
curl -X POST -H "Content-Type: application/json" -d '{
"groupId": "group_id_here",
"memberId": "user_id_here",
"accountSelection": "0901234567"
}' "http://localhost:3000/api/addUserToGroupByAccount?api_key=zalo_your_api_key_here"
# Với API key (khuyến nghị)
curl -X POST -H "Content-Type: application/json" -H "X-API-Key: zalo_your_api_key_here" -d '{
"groupId": "group_id_here",
"memberId": "user_id_here",
"accountSelection": "0901234567"
}' http://localhost:3000/api/removeUserFromGroupByAccount
# Hoặc với query parameter
curl -X POST -H "Content-Type: application/json" -d '{
"groupId": "group_id_here",
"memberId": "user_id_here",
"accountSelection": "0901234567"
}' "http://localhost:3000/api/removeUserFromGroupByAccount?api_key=zalo_your_api_key_here"
# Với API key (khuyến nghị)
curl -X POST -H "Content-Type: application/json" -H "X-API-Key: zalo_your_api_key_here" -d '{
"imagePath": "https://example.com/image.jpg",
"threadId": "user_id_here",
"accountSelection": "0901234567"
}' http://localhost:3000/api/sendImageToUserByAccount
# Hoặc với query parameter
curl -X POST -H "Content-Type: application/json" -d '{
"imagePath": "https://example.com/image.jpg",
"threadId": "user_id_here",
"accountSelection": "0901234567"
}' "http://localhost:3000/api/sendImageToUserByAccount?api_key=zalo_your_api_key_here"
# Với API key (khuyến nghị)
curl -X POST -H "Content-Type: application/json" -H "X-API-Key: zalo_your_api_key_here" -d '{
"imagePaths": ["https://example.com/image1.jpg", "https://example.com/image2.jpg"],
"threadId": "user_id_here",
"accountSelection": "0901234567"
}' http://localhost:3000/api/sendImagesToUserByAccount
# Hoặc với query parameter
curl -X POST -H "Content-Type: application/json" -d '{
"imagePaths": ["https://example.com/image1.jpg", "https://example.com/image2.jpg"],
"threadId": "user_id_here",
"accountSelection": "0901234567"
}' "http://localhost:3000/api/sendImagesToUserByAccount?api_key=zalo_your_api_key_here"
# Với API key (khuyến nghị)
curl -X POST -H "Content-Type: application/json" -H "X-API-Key: zalo_your_api_key_here" -d '{
"imagePath": "https://example.com/image.jpg",
"threadId": "group_id_here",
"accountSelection": "0901234567"
}' http://localhost:3000/api/sendImageToGroupByAccount
# Hoặc với query parameter
curl -X POST -H "Content-Type: application/json" -d '{
"imagePath": "https://example.com/image.jpg",
"threadId": "group_id_here",
"accountSelection": "0901234567"
}' "http://localhost:3000/api/sendImageToGroupByAccount?api_key=zalo_your_api_key_here"
# Với API key (khuyến nghị)
curl -X POST -H "Content-Type: application/json" -H "X-API-Key: zalo_your_api_key_here" -d '{
"imagePaths": ["https://example.com/image1.jpg", "https://example.com/image2.jpg"],
"threadId": "group_id_here",
"accountSelection": "0901234567"
}' http://localhost:3000/api/sendImagesToGroupByAccount
# Hoặc với query parameter
curl -X POST -H "Content-Type: application/json" -d '{
"imagePaths": ["https://example.com/image1.jpg", "https://example.com/image2.jpg"],
"threadId": "group_id_here",
"accountSelection": "0901234567"
}' "http://localhost:3000/api/sendImagesToGroupByAccount?api_key=zalo_your_api_key_here"
🆕 Quét thông tin thành viên nhóm Zalo
# Với API key (khuyến nghị)
curl -X POST -H "Content-Type: application/json" -H "X-API-Key: zalo_your_api_key_here" -d '{
"groupUrl": "https://zalo.me/g/your_group_id",
"accountSelection": "0901234567"
}' http://localhost:3000/api/getGroupMembersByAccount
# Hoặc với query parameter
curl -X POST -H "Content-Type: application/json" -d '{
"groupUrl": "https://zalo.me/g/your_group_id",
"accountSelection": "0901234567"
}' "http://localhost:3000/api/getGroupMembersByAccount?api_key=zalo_your_api_key_here"
📋 Response mẫu:
{
"success": true,
"data": {
"groupInfo": {
"groupId": "your_group_id",
"name": "Tên nhóm",
"description": "Mô tả nhóm",
"avatar": "https://avatar-url.jpg",
"totalMembers": 25,
"createdTime": 1640995200000,
"creatorId": "creator_user_id"
},
"members": [
{
"userId": "user_id_1",
"displayName": "Nguyễn Văn A",
"phoneNumber": "0901234567",
"avatar": "https://avatar-url.jpg",
"role": "admin",
"isActive": true,
"lastActiveTime": 1640995200000,
"joinTime": null,
"gender": 1,
"status": "Đang hoạt động"
}
],
"summary": {
"totalMembers": 25,
"admins": 3,
"activeMembers": 20,
"membersWithPhone": 15,
"scannedAt": "2024-01-01T10:00:00.000Z"
}
},
"usedAccount": {
"ownId": "your_account_id",
"phoneNumber": "0901234567"
}
}
⚠️ Lưu ý quan trọng:
🔥 Ưu điểm của APIs *ByAccount:
📋 Workflow n8n mẫu:
1. Gọi GET /api/accounts để lấy danh sách tài khoản
2. Tạo dropdown từ field "displayName" hoặc "phoneNumber"
3. Sử dụng APIs *ByAccount với accountSelection
4. Kiểm tra usedAccount trong response để xác nhận
Test cơ bản với curl (sử dụng API key):
# 1. Lấy danh sách tài khoản
curl -H "X-API-Key: zalo_your_api_key_here" http://localhost:3000/api/accounts
# 2. Gửi tin nhắn test
curl -X POST -H "Content-Type: application/json" -H "X-API-Key: zalo_your_api_key_here" -d '{
"message": "Test message from API",
"threadId": "YOUR_THREAD_ID",
"accountSelection": "YOUR_PHONE_NUMBER"
}' http://localhost:3000/api/sendMessageByAccount
# 3. Tìm user
curl -X POST -H "Content-Type: application/json" -H "X-API-Key: zalo_your_api_key_here" -d '{
"phone": "TARGET_PHONE_NUMBER",
"accountSelection": "YOUR_PHONE_NUMBER"
}' http://localhost:3000/api/findUserByAccount
# 4. Gửi hình ảnh
curl -X POST -H "Content-Type: application/json" -H "X-API-Key: zalo_your_api_key_here" -d '{
"imagePath": "https://example.com/test-image.jpg",
"threadId": "YOUR_THREAD_ID",
"accountSelection": "YOUR_PHONE_NUMBER"
}' http://localhost:3000/api/sendImageByAccount
# 5. Quét thành viên nhóm
curl -X POST -H "Content-Type: application/json" -H "X-API-Key: zalo_your_api_key_here" -d '{
"groupUrl": "https://zalo.me/g/YOUR_GROUP_ID",
"accountSelection": "YOUR_PHONE_NUMBER"
}' http://localhost:3000/api/getGroupMembersByAccount
💡 Lưu ý khi test:
zalo_your_api_key_here bằng API key thực tế (liên hệ admin để
được cấp)YOUR_PHONE_NUMBER bằng số điện thoại từ response của
/api/accounts
YOUR_THREAD_ID bằng ID người dùng hoặc nhóm thực tếTARGET_PHONE_NUMBER bằng số điện thoại cần tìmusedAccount để xác nhận account đã sử
dụngX-API-Key
thay vì query parameter để bảo mật hơnEndpoint: POST /api/changeGroupAvatarByAccount
Permission: zalo:group_management
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| groupId | string | ID nhóm | Có |
| avatarPath | string | Đường dẫn/URL ảnh avatar mới | Có |
| accountSelection | string | SĐT hoặc ownId | Có |
Endpoint: POST /api/changeGroupNameByAccount
Permission: zalo:group_management
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| groupId | string | ID nhóm | Có |
| name | string | Tên nhóm mới | Có |
| accountSelection | string | SĐT hoặc ownId | Có |
Endpoint: POST /api/changeGroupOwnerByAccount
Permission: zalo:group_management
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| groupId | string | ID nhóm | Có |
| newOwnerId | string | ID thành viên sẽ làm chủ nhóm mới | Có |
| accountSelection | string | SĐT hoặc ownId | Có |
Endpoint: POST /api/addGroupDeputyByAccount
Permission: zalo:group_management
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| groupId | string | ID nhóm | Có |
| memberId | string | ID thành viên được bổ nhiệm phó nhóm | Có |
| accountSelection | string | SĐT hoặc ownId | Có |
Endpoint: POST /api/removeGroupDeputyByAccount
Permission: zalo:group_management
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| groupId | string | ID nhóm | Có |
| memberId | string | ID phó nhóm cần xóa | Có |
| accountSelection | string | SĐT hoặc ownId | Có |
Endpoint: POST /api/disperseGroupByAccount
Permission: zalo:group_management
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| groupId | string | ID nhóm cần giải tán | Có |
| accountSelection | string | SĐT hoặc ownId | Có |
Endpoint: POST /api/getGroupMembersInfoByAccount
Permission: zalo:group_management
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| groupId | string | ID nhóm | Có |
| accountSelection | string | SĐT hoặc ownId | Có |
Endpoint: POST /api/zalo/join-group-by-account
Permission: zalo:group_management
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| groupUrl | string | URL nhóm Zalo (https://zalo.me/g/...) | Có |
| accountSelection | string | SĐT hoặc ownId | Có |
Endpoint: POST /api/acceptFriendRequestByAccount
Permission: zalo:friend_management
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| userId | string | ID người gửi lời mời | Có |
| accountSelection | string | SĐT hoặc ownId | Có |
Endpoint: POST /api/changeFriendAliasByAccount
Permission: zalo:friend_management
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| userId | string | ID bạn bè | Có |
| alias | string | Biệt danh mới | Có |
| accountSelection | string | SĐT hoặc ownId | Có |
Endpoint: POST /api/blockUserByAccount
Permission: zalo:friend_management
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| userId | string | ID người dùng cần chặn | Có |
| accountSelection | string | SĐT hoặc ownId | Có |
Endpoint: POST /api/unblockUserByAccount
Permission: zalo:friend_management
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| userId | string | ID người dùng cần bỏ chặn | Có |
| accountSelection | string | SĐT hoặc ownId | Có |
Endpoint: POST /api/getAllFriendsByAccount
Permission: zalo:friend_management
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| accountSelection | string | SĐT hoặc ownId | Có |
Endpoint: POST /api/blockViewFeedByAccount
Permission: zalo:friend_management
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| userId | string | ID người dùng cần chặn xem feed | Có |
| accountSelection | string | SĐT hoặc ownId | Có |
Endpoint: POST /api/updateProfileByAccount
Permission: zalo:account_management
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| accountSelection | string | SĐT hoặc ownId | Có |
| ... | object | Các trường profile cần cập nhật | Có |
Endpoint: POST /api/setSettingsAccountByAccount
Permission: zalo:account_management
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| accountSelection | string | SĐT hoặc ownId | Có |
| ... | object | Các cài đặt cần thay đổi | Có |
Endpoint: POST /api/getQRByAccount
Permission: zalo:account_management
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| accountSelection | string | SĐT hoặc ownId | Có |
Endpoint: POST /api/getCookieByAccount
Permission: zalo:account_management
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| accountSelection | string | SĐT hoặc ownId | Có |
Endpoint: POST /api/getContextByAccount
Permission: zalo:account_management
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| accountSelection | string | SĐT hoặc ownId | Có |
Endpoint: POST /api/keepAliveByAccount
Permission: zalo:account_management
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| accountSelection | string | SĐT hoặc ownId | Có |
Endpoint: POST /api/parseLinkByAccount
Permission: zalo:account_management
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| accountSelection | string | SĐT hoặc ownId | Có |
| link | string | URL cần parse | Có |
Endpoint: POST /api/pinConversationsByAccount
Permission: zalo:account_management
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| accountSelection | string | SĐT hoặc ownId | Có |
| conversationId | string | ID cuộc hội thoại | Có |
Endpoint: POST /api/sendReportByAccount
Permission: zalo:account_management
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| accountSelection | string | SĐT hoặc ownId | Có |
| ... | object | Nội dung báo cáo | Có |
Endpoint: POST /api/customByAccount
Permission: zalo:account_management
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| accountSelection | string | SĐT hoặc ownId | Có |
| ... | object | Params tùy chỉnh | Tùy |
Endpoint: POST /api/sendStickerByAccount
Permission: zalo:send_message
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| stickerId | string | ID sticker | Có |
| threadId | string | ID người dùng/nhóm | Có |
| accountSelection | string | SĐT hoặc ownId | Có |
Endpoint: POST /api/sendVideoByAccount
Permission: zalo:send_message
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| videoUrl | string | URL video | Có |
| threadId | string | ID người dùng/nhóm | Có |
| accountSelection | string | SĐT hoặc ownId | Có |
Endpoint: POST /api/sendVoiceByAccount
Permission: zalo:send_message
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| voiceUrl | string | URL file âm thanh | Có |
| threadId | string | ID người dùng/nhóm | Có |
| accountSelection | string | SĐT hoặc ownId | Có |
Endpoint: POST /api/sendCardByAccount
Permission: zalo:send_message
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| cardUserId | string | ID user trong card | Có |
| threadId | string | ID người nhận | Có |
| accountSelection | string | SĐT hoặc ownId | Có |
Endpoint: POST /api/uploadAttachmentByAccount
Permission: zalo:send_image
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| filePath | string | URL file đính kèm | Có |
| threadId | string | ID người dùng/nhóm | Có |
| accountSelection | string | SĐT hoặc ownId | Có |
Endpoint: POST /api/deleteMessageByAccount
Permission: zalo:send_message
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| messageId | string | ID tin nhắn cần xóa | Có |
| threadId | string | ID người dùng/nhóm | Có |
| accountSelection | string | SĐT hoặc ownId | Có |
Endpoint: POST /api/addReactionByAccount
Permission: zalo:send_message
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| messageId | string | ID tin nhắn | Có |
| reaction | string | Emoji reaction | Có |
| threadId | string | ID người dùng/nhóm | Có |
| accountSelection | string | SĐT hoặc ownId | Có |
Endpoint: POST /api/undoByAccount
Permission: zalo:send_message
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| messageId | string | ID tin nhắn cần thu hồi | Có |
| threadId | string | ID người dùng/nhóm | Có |
| accountSelection | string | SĐT hoặc ownId | Có |
Endpoint: POST /api/sendSeenEventByAccount
Permission: zalo:send_message
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| threadId | string | ID cuộc hội thoại | Có |
| accountSelection | string | SĐT hoặc ownId | Có |
Endpoint: POST /api/sendDeliveredEventByAccount
Permission: zalo:send_message
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| threadId | string | ID cuộc hội thoại | Có |
| accountSelection | string | SĐT hoặc ownId | Có |
Endpoint: POST /api/sendTypingEventByAccount
Permission: zalo:send_message
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| threadId | string | ID cuộc hội thoại | Có |
| accountSelection | string | SĐT hoặc ownId | Có |
Mỗi API key được gán quyền cụ thể. Nếu chọn "Tất cả quyền", key có thể truy cập mọi API.
| Quyền | Mô tả | APIs liên quan |
|---|---|---|
* |
Tất cả quyền | Toàn bộ APIs |
zalo:find_user |
Tìm kiếm người dùng | findUser*, getUserInfo* |
zalo:send_message |
Gửi tin nhắn | sendMessage*, sendSticker*, sendVideo*, sendVoice*, sendCard*, deleteMessage*, addReaction*, undo*, sendSeen/Delivered/Typing* |
zalo:send_image |
Gửi hình ảnh | sendImage*, sendImages*, uploadAttachment* |
zalo:group_management |
Quản lý nhóm | createGroup*, getGroupInfo*, addUser/removeUser*, changeGroup*, Deputy*, disperseGroup*, getGroupMembers*, joinGroup* |
zalo:friend_management |
Quản lý bạn bè | sendFriendRequest*, acceptFriendRequest*, changeFriendAlias*, block/unblock*, getAllFriends*, blockViewFeed* |
zalo:account_management |
Quản lý tài khoản | accounts, updateProfile*, setSettings*, getQR*, getCookie*, getContext*, keepAlive*, parseLink*, pinConversations*, custom* |
Lưu ý: Các APIs này vẫn hoạt động nhưng khuyến nghị sử dụng APIs *ByAccount ở trên.
Mục đích: Tìm kiếm người dùng dựa trên số điện thoại.
Endpoint: POST /api/findUser
Parameters:
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| phone | string | Số điện thoại của người dùng. | Có |
| ownId | string | ID tài khoản Zalo đang đăng nhập (lấy từ /accounts). | Có |
Ví dụ:
{
"phone": "0123456789",
"ownId": "0000000000000000001"
}
Ví dụ curl:
curl -X POST -H "Content-Type: application/json" -d '{
"phone": "0123456789",
"ownId": "0000000000000000001"
}' http://localhost:3000/api/findUser
Mục đích: Lấy thông tin chi tiết của một người dùng.
Endpoint: POST /api/getUserInfo
Parameters:
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| userId | string | ID của người dùng cần lấy thông tin. | Có |
| ownId | string | ID tài khoản Zalo đang đăng nhập (lấy từ /accounts). | Có |
Ví dụ:
{
"userId": "0000000000000000001",
"ownId": "0000000000000000009"
}
Ví dụ curl:
curl -X POST -H "Content-Type: application/json" -d '{
"userId": "0000000000000000001",
"ownId": "0000000000000000009"
}' http://localhost:3000/api/getUserInfo
Mục đích: Gửi lời mời kết bạn đến người dùng.
Endpoint: POST /api/sendFriendRequest
Parameters:
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| userId | string | ID của người dùng nhận lời mời. | Có |
| ownId | string | ID tài khoản Zalo đang đăng nhập (lấy từ /accounts). | Có |
Ví dụ:
{
"userId": "0000000000000000002",
"ownId": "0000000000000000001"
}
Ví dụ curl:
curl -X POST -H "Content-Type: application/json" -d '{
"userId": "0000000000000000002",
"ownId": "0000000000000000001"
}' http://localhost:3000/api/sendFriendRequest
Mục đích: Gửi tin nhắn văn bản (hoặc object) đến người dùng hoặc nhóm.
Endpoint: POST /api/sendmessage
Parameters:
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| message | string | Object | Nội dung tin nhắn (có thể là string hoặc object MessageContent). | Có |
| threadId | string | ID của người dùng/nhóm để gửi tin. | Có |
| type | number | Loại thread (0: User hoặc 1: Group). Mặc định là 0. | Không |
| ownId | string | ID tài khoản Zalo đang đăng nhập (lấy từ /accounts). | Có |
Ví dụ:
{
"message": "Xin chào",
"threadId": "0000000000000000001",
"type": 0,
"ownId": "0000000000000000009"
}
Ví dụ curl:
curl -X POST -H "Content-Type: application/json" -d '{
"message": "Xin chào",
"threadId": "0000000000000000001",
"type": 0,
"ownId": "0000000000000000009"
}' http://localhost:3000/api/sendmessage
Mục đích: Tạo một nhóm mới.
Endpoint: POST /api/createGroup
Parameters:
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| members | string[] | Mảng ID các thành viên (không bao gồm bản thân). | Có |
| name | string | Tên của nhóm. | Không |
| avatarPath | string | Đường dẫn ảnh nhóm (nếu có). | Không |
| ownId | string | ID tài khoản Zalo đang đăng nhập (lấy từ /accounts). | Có |
Ví dụ:
{
"members": ["0000000000000000002", "0000000000000000003"],
"name": "Nhóm Mới",
"avatarPath": "./avatar.jpg",
"ownId": "0000000000000000001"
}
Ví dụ curl:
curl -X POST -H "Content-Type: application/json" -d '{
"members": ["0000000000000000002", "0000000000000000003"],
"name": "Nhóm Mới",
"avatarPath": "./avatar.jpg",
"ownId": "0000000000000000001"
}' http://localhost:3000/api/createGroup
Mục đích: Lấy thông tin chi tiết của các nhóm.
Endpoint: POST /api/getGroupInfo
Parameters:
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| groupId | string | string[] | ID của nhóm hoặc mảng các ID. | Có |
| ownId | string | ID tài khoản Zalo đang đăng nhập (lấy từ /accounts). | Có |
Ví dụ:
{
"groupId": "0000000000000000000",
"ownId": "0000000000000000009"
}
Ví dụ curl:
curl -X POST -H "Content-Type: application/json" -d '{
"groupId": "0000000000000000000",
"ownId": "0000000000000000009"
}' http://localhost:3000/api/getGroupInfo
Mục đích: Thêm thành viên vào nhóm.
Endpoint: POST /api/addUserToGroup
Parameters:
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| groupId | string | ID của nhóm. | Có |
| memberId | string | string[] | ID của thành viên (hoặc mảng ID) cần thêm vào nhóm. | Có |
| ownId | string | ID tài khoản Zalo đang đăng nhập (lấy từ /accounts). | Có |
Ví dụ:
{
"groupId": "0000000000000000000",
"memberId": ["0000000000000000001", "0000000000000000002"],
"ownId": "0000000000000000009"
}
Ví dụ curl:
curl -X POST -H "Content-Type: application/json" -d '{
"groupId": "0000000000000000000",
"memberId": ["0000000000000000001", "0000000000000000002"],
"ownId": "0000000000000000009"
}' http://localhost:3000/api/addUserToGroup
Mục đích: Xóa thành viên khỏi nhóm.
Endpoint: POST /api/removeUserFromGroup
Parameters:
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| groupId | string | ID của nhóm. | Có |
| memberId | string | string[] | ID của thành viên (hoặc mảng ID) cần xóa khỏi nhóm. | Có |
| ownId | string | ID tài khoản Zalo đang đăng nhập (lấy từ /accounts). | Có |
Ví dụ:
{
"groupId": "0000000000000000000",
"memberId": ["0000000000000000001", "0000000000000000002"],
"ownId": "0000000000000000009"
}
Ví dụ curl:
curl -X POST -H "Content-Type: application/json" -d '{
"groupId": "0000000000000000000",
"memberId": ["0000000000000000001", "0000000000000000002"],
"ownId": "0000000000000000009"
}' http://localhost:3000/api/removeUserFromGroup
Mục đích: Gửi một hình ảnh đến người dùng.
Endpoint: POST /api/sendImageToUser
Parameters:
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| imagePath | string | Đường dẫn hoặc URL đến hình ảnh cần gửi (gửi trong request body dưới tên imageUrl). | Có |
| threadId | string | ID của người dùng nhận tin nhắn. | Có |
| ownId | string | ID tài khoản Zalo đang đăng nhập (lấy từ /accounts). | Có |
Ví dụ:
{
"imageUrl": "./path/to/image.jpg",
"threadId": "0000000000000000001",
"ownId": "0000000000000000009"
}
Ví dụ curl:
curl -X POST -H "Content-Type: application/json" -d '{
"imageUrl": "./path/to/image.jpg",
"threadId": "0000000000000000001",
"ownId": "0000000000000000009"
}' http://localhost:3000/api/sendImageToUser
Mục đích: Gửi nhiều hình ảnh đến người dùng.
Endpoint: POST /api/sendImagesToUser
Parameters:
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| imagePaths | string[] | Mảng đường dẫn hoặc URL hình ảnh (gửi trong request body dưới tên imageUrls). | Có |
| threadId | string | ID của người dùng nhận tin nhắn. | Có |
| ownId | string | ID tài khoản Zalo đang đăng nhập (lấy từ /accounts). | Có |
Ví dụ:
{
"imageUrls": ["./path/to/image1.jpg", "./path/to/image2.jpg"],
"threadId": "0000000000000000001",
"ownId": "0000000000000000009"
}
Ví dụ curl:
curl -X POST -H "Content-Type: application/json" -d '{
"imageUrls": ["./path/to/image1.jpg", "./path/to/image2.jpg"],
"threadId": "0000000000000000001",
"ownId": "0000000000000000009"
}' http://localhost:3000/api/sendImagesToUser
Mục đích: Gửi một hình ảnh đến nhóm.
Endpoint: POST /api/sendImageToGroup
Parameters:
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| imagePath | string | Đường dẫn hoặc URL đến hình ảnh cần gửi (gửi trong request body dưới tên imageUrl). | Có |
| threadId | string | ID của nhóm nhận tin nhắn. | Có |
| ownId | string | ID tài khoản Zalo đang đăng nhập (lấy từ /accounts). | Có |
Ví dụ:
{
"imagePath": "./path/to/group-image.jpg",
"threadId": "0000000000000000000",
"ownId": "0000000000000000009"
}
Ví dụ curl:
curl -X POST -H "Content-Type: application/json" -d '{
"imageUrl": "./path/to/group-image.jpg",
"threadId": "0000000000000000000",
"ownId": "0000000000000000009"
}' http://localhost:3000/api/sendImageToGroup
Mục đích: Gửi nhiều hình ảnh đến nhóm.
Endpoint: POST /api/sendImagesToGroup
Parameters:
| Field | Loại | Mô tả | Bắt buộc |
|---|---|---|---|
| imagePaths | string[] | Mảng đường dẫn hoặc URL hình ảnh (gửi trong request body dưới tên imageUrls). | Có |
| threadId | string | ID của nhóm nhận tin nhắn. | Có |
| ownId | string | ID tài khoản Zalo đang đăng nhập (lấy từ /accounts). | Có |
Ví dụ:
{
"imageUrls": ["./path/to/group-image1.jpg", "./path/to/group-image2.jpg"],
"threadId": "0000000000000000000",
"ownId": "0000000000000000009"
}
Ví dụ curl:
curl -X POST -H "Content-Type: application/json" -d '{
"imageUrls": ["./path/to/group-image1.jpg", "./path/to/group-image2.jpg"],
"threadId": "0000000000000000000",
"ownId": "0000000000000000009"
}' http://localhost:3000/api/sendImagesToGroup