ZNS message sending API group (Zalo Notification Service): send ZNS to customers and retrieve the list of available ZNS templates.
Authentication: All requests need to send the header
X-Api-Key. Contact Alohub to obtain an API Key.
Requirements: Before sending ZNS, you need to have a Zalo OA connected to Alohub and the ZNS template approved by Zalo. Use the API List Template ZNS to check available templates.
/v1/zns/sendSend ZNS message to the customer's phone number via the specified campaign. Supports passing personalization information to fill in the ZNS template.
Header | Required | Description |
|---|---|---|
| Yes | API Key for authentication |
| Yes |
|
Parameter | Type | Required | Description |
|---|---|---|---|
| string | Yes | Customer's phone number (registered with Zalo) |
| number | Yes | ZNS campaign ID |
| string | No | Transaction ID created by the client for result matching |
| string | No | Customer name |
| string | No | Customer email |
| string | No | Customer address |
| string | No | Personalization information fields (up to 6 fields). Values will be assigned to corresponding variables in the ZNS template |
curl --location -g '{{base_url}}/v1/zns/send' \
--header 'X-Api-Key: {{api_key}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"phone": "0123456789",
"campaignId": 1,
"transactionId": "TXN_004",
"name": "Nguyễn Văn A",
"email": "nguyenvana@example.com",
"pField1": "Đơn hàng #12345",
"pField2": "Đang giao hàng"
}'const axios = require('axios')
const response = await axios.post('{{base_url}}/v1/zns/send', {
phone: '0123456789',
campaignId: 1,
transactionId: 'TXN_004',
name: 'Nguyễn Văn A',
email: 'nguyenvana@example.com',
pField1: 'Đơn hàng #12345',
pField2: 'Đang giao hàng'
}, {
headers: {
'X-Api-Key': '{{api_key}}',
'Content-Type': 'application/json'
}
})
console.log(response.data)import requests
response = requests.post('{{base_url}}/v1/zns/send',
json={
'phone': '0123456789',
'campaignId': 1,
'transactionId': 'TXN_004',
'name': 'Nguyễn Văn A',
'email': 'nguyenvana@example.com',
'pField1': 'Đơn hàng #12345',
'pField2': 'Đang giao hàng'
},
headers={
'X-Api-Key': '{{api_key}}',
'Content-Type': 'application/json'
}
)
print(response.json())/v1/zns/templateRetrieve the list of ZNS templates approved by Zalo. Can filter by Zalo OA, status, and include parameter or mapping information.
Header | Required | Description |
|---|---|---|
| Yes | API Key for authentication |
| Yes |
|
Parameter | Type | Required | Description |
|---|---|---|---|
| string | No | ID of Zalo OA. Leave empty |
| string | No | Filter by template status. Leave empty |
| boolean | No |
|
| boolean | No |
|
curl --location -g '{{base_url}}/v1/zns/template' \
--header 'X-Api-Key: {{api_key}}' \
--header 'Content-Type: application/json' \
--data '{
"oaId": "",
"status": "",
"includeParams": true,
"includeMappings": true
}'const axios = require('axios')
const response = await axios.post('{{base_url}}/v1/zns/template', {
oaId: '',
status: '',
includeParams: true,
includeMappings: true
}, {
headers: {
'X-Api-Key': '{{api_key}}',
'Content-Type': 'application/json'
}
})
console.log(response.data)import requests
response = requests.post('{{base_url}}/v1/zns/template',
json={
'oaId': '',
'status': '',
'includeParams': True,
'includeMappings': True
},
headers={
'X-Api-Key': '{{api_key}}',
'Content-Type': 'application/json'
}
)
print(response.json())