Authentication chung: Tất cả API sử dụng Kong dual-auth: Header
Authorization(API key) bắt buộc. HeaderX-Tenant-IDdo Kong inject — nếu test internal không qua Kong thì bỏ header này, backend tự resolve tenantId theo Authorization key. Không dùng JWT (x-access-token) trong luồng này.
/v1/agentsLấy danh sách tất cả agent của tenant. Hỗ trợ filter theo status, queue và phân trang.
Authentication: Header
X-Api-Key(scope:agent). Kong dual-auth: ưu tiênX-Tenant-IDheader, fallback query DB theo Authorization key.
Base URL: Dev:
https://xapi-dev.alohub.vn| Prod:https://xapi.alohub.vn
Tham số | Vị trí | Bắt buộc | Kiểu | Mô tả | Ví dụ |
|---|---|---|---|---|---|
| query | Không |
| Filter theo tenantId cụ thể (mặc định từ auth) | 20260310 |
| query | Không |
| 1 = active, 0 = inactive | 1 |
| query | Không |
| Filter agents thuộc callin queue này | 1001226 |
| query | Không |
| Trang, bắt đầu từ 0 (default: 0) | 0 |
| query | Không |
| Số record/trang (default: 20) | 20 |
curl -X GET "https://xapi.alohub.vn/v1/agents" \
-H "X-Api-Key: sk_live_xxx" \
-H "X-Tenant-ID: 20260310"
# Filter active + queue
curl -X GET "https://xapi.alohub.vn/v1/agents?status=1&queue_id=1001226&page=0&size=20" \
-H "X-Api-Key: sk_live_xxx" \
-H "X-Tenant-ID: 20260310"const axios = require('axios');
const response = await axios.get(
'{{host}}/api/v1/agents?team_id=20260310&status=1&queue_id=1001226&page=0&size=20',
{ headers: { 'Authorization': '{{api-key}}', 'X-Tenant-ID': '{{tenant-id}}', 'Content-Type': 'application/json' } }
);
console.log(response.data);import requests
params = {"team_id": "20260310", "status": "1", "queue_id": "1001226", "page": "0", "size": "20"}
headers = {"Authorization": "{{api-key}}", "X-Tenant-ID": "{{tenant-id}}", "Content-Type": "application/json"}
response = requests.get(
'{{host}}/api/v1/agents',
headers=headers, params=params
)
print(response.json())
{
"success": "1",
"error_code": "SUCCESS",
"error_message": "SUCCESS",
"totalRecord": 413,
"data": [
{
"tenantId": 20260310,
"tenantName": "AloHub",
"agentId": "082018",
"status": 1,
"userName": "AloHub.admin",
"queueCallin": "1001226-test",
"queueCallout": 13876,
"queueCalloutName": "AloHub",
"queueCallinId": "1001226",
"isFollowMe": 1,
"priority": "1",
"systemStatus": "AVAILABLE",
"userStatus": "LOGOUT"
}
]
}
Field | Kiểu | Mô tả | |
|---|---|---|---|
|
| "1" = thành công, "0" = lỗi | |
|
| Mã lỗi | |
|
| Tổng số agent | |
|
| ID tenant | |
|
| Tên tenant | |
|
| Extension number — dùng làm {id} trong PUT /queues và PUT /recording | |
|
| 1 = active, 0 = inactive | |
|
| null | Tên đăng nhập |
|
| null | "-" — callin queue đang gắn |
|
| null | ID callin queue |
|
| null | ID callout queue |
|
| null | Tên callout queue |
|
| null | 1 = bật follow-me |
|
| null | Độ ưu tiên trong queue |
|
| null | AVAILABLE / NOT AVAILABLE |
|
| null | AVAILABLE / LOGOUT |
HTTP | error_code | Mô tả | FE xử lý |
|---|---|---|---|
401 | UNAUTHORIZED | Thiếu hoặc sai API key | Redirect nhập lại key |
403 | INSUFFICIENT_SCOPE | Key không có scope | Hiện thông báo |
404 | NOT_FOUND | Không tìm thấy | Hiện thông báo |
429 | RATE_LIMIT_EXCEEDED | Vượt giới hạn request | Retry sau Retry-After giây |
500 | FAIL | Lỗi hệ thống | Toast lỗi chung |
Header | Mô tả |
|---|---|
| Giới hạn tenant/10s |
| Còn lại tenant/10s |
| Giới hạn route/10s |
| Còn lại route/10s |
| Giây cần chờ khi bị 429 |
/v1/agents/{id}/queuesGán agent vào callin hoặc callout queue. type=callin: REPLACE HOÀN TOÀN danh sách queue cũ — muốn thêm 1 queue cần gửi cả danh sách cũ + mới.
Authentication: Header
X-Api-Key(scope:agent). Kong dual-auth: ưu tiênX-Tenant-IDheader, fallback query DB theo Authorization key.
Base URL: Dev:
https://xapi-dev.alohub.vn| Prod:https://xapi.alohub.vn
Tham số | Vị trí | Bắt buộc | Kiểu | Mô tả | Ví dụ |
|---|---|---|---|---|---|
| path | Có |
| agentId = extension number (lấy từ GET /v1/agents) | 082018 |
| query | Không |
| "callin" (default) hoặc "callout" | callin |
{
"queue_ids": [
1001226,
1000886
],
"priority": 1
}
Field | Bắt buộc | Mô tả |
|---|---|---|
| Có | Mảng queue ID. Không được rỗng. |
| Không | Độ ưu tiên trong callin queue. Chỉ áp dụng type=callin. |
curl -X PUT "https://xapi.alohub.vn/v1/agents/082018/queues?type=callin" \
-H "X-Api-Key: sk_live_xxx" \
-H "X-Tenant-ID: 20260310" \
-H "Content-Type: application/json" \
-d '{"queue_ids":[1001226,1000886],"priority":1}'
# Gán callout queue
curl -X PUT "https://xapi.alohub.vn/v1/agents/082018/queues?type=callout" \
-H "X-Api-Key: sk_live_xxx" \
-H "X-Tenant-ID: 20260310" \
-H "Content-Type: application/json" \
-d '{"queue_ids":[13876]}'const axios = require('axios');
const response = await axios.put(
'{{host}}/api/v1/agents/{{id}}/queues?type=callin',
{
"queue_ids": [
1001226,
1000886
],
"priority": 1
},
{ headers: { 'Authorization': '{{api-key}}', 'X-Tenant-ID': '{{tenant-id}}', 'Content-Type': 'application/json' } }
);
console.log(response.data);import requests
params = {"type": "callin"}
headers = {"Authorization": "{{api-key}}", "X-Tenant-ID": "{{tenant-id}}", "Content-Type": "application/json"}
payload = {
"queue_ids": [
1001226,
1000886
],
"priority": 1
}
response = requests.put(
'{{host}}/api/v1/agents/{{id}}/queues',
json=payload,
headers=headers, params=params
)
print(response.json())
{
"success": "1",
"error_code": "SUCCESS",
"error_message": "Agent queues updated successfully"
}
Field | Kiểu | Mô tả |
|---|---|---|
|
| "1" = thành công |
|
| SUCCESS khi cập nhật thành công |
|
| Mô tả kết quả |
HTTP | error_code | Mô tả | FE xử lý |
|---|---|---|---|
401 | UNAUTHORIZED | Thiếu hoặc sai API key | Redirect nhập lại key |
403 | INSUFFICIENT_SCOPE | Key không có scope | Hiện thông báo |
400 | INVALID_INPUT | Sai input | Hiện lỗi cụ thể |
404 | NOT_FOUND | Không tìm thấy | Hiện thông báo |
429 | RATE_LIMIT_EXCEEDED | Vượt giới hạn request | Retry sau Retry-After giây |
500 | FAIL | Lỗi hệ thống | Toast lỗi chung |
Header | Mô tả |
|---|---|
| Giới hạn tenant/10s |
| Còn lại tenant/10s |
| Giới hạn route/10s |
| Còn lại route/10s |
| Giây cần chờ khi bị 429 |
/v1/agents/{id}/recordingBật hoặc tắt tính năng ghi âm cho agent. Yêu cầu DBA đã chạy migration_add_is_record.sql trước.
Authentication: Header
X-Api-Key(scope:agent). Kong dual-auth: ưu tiênX-Tenant-IDheader, fallback query DB theo Authorization key.
Base URL: Dev:
https://xapi-dev.alohub.vn| Prod:https://xapi.alohub.vn
Tham số | Vị trí | Bắt buộc | Kiểu | Mô tả | Ví dụ |
|---|---|---|---|---|---|
| path | Có |
| agentId = extension number | 082018 |
{
"enabled": true
}
Field | Bắt buộc | Mô tả |
|---|---|---|
| Có | true = bật ghi âm, false = tắt ghi âm |
curl -X PUT "https://xapi.alohub.vn/v1/agents/082018/recording" \
-H "X-Api-Key: sk_live_xxx" \
-H "X-Tenant-ID: 20260310" \
-H "Content-Type: application/json" \
-d '{"enabled":true}'
# Tắt ghi âm
curl -X PUT "https://xapi.alohub.vn/v1/agents/082018/recording" \
-H "X-Api-Key: sk_live_xxx" \
-H "X-Tenant-ID: 20260310" \
-H "Content-Type: application/json" \
-d '{"enabled":false}'const axios = require('axios');
const response = await axios.put(
'{{host}}/api/v1/agents/{{id}}/recording',
{
"enabled": true
},
{ headers: { 'Authorization': '{{api-key}}', 'X-Tenant-ID': '{{tenant-id}}', 'Content-Type': 'application/json' } }
);
console.log(response.data);import requests
headers = {"Authorization": "{{api-key}}", "X-Tenant-ID": "{{tenant-id}}", "Content-Type": "application/json"}
payload = {
"enabled": true
}
response = requests.put(
'{{host}}/api/v1/agents/{{id}}/recording',
json=payload,
headers=headers
)
print(response.json())
{
"success": "1",
"error_code": "SUCCESS",
"error_message": "Recording enabled for agent 082018"
}
Field | Kiểu | Mô tả |
|---|---|---|
|
| "1" = thành công |
|
| SUCCESS khi cập nhật thành công |
|
| "Recording enabled/disabled for agent {id}" |
HTTP | error_code | Mô tả | FE xử lý |
|---|---|---|---|
401 | UNAUTHORIZED | Thiếu hoặc sai API key | Redirect nhập lại key |
403 | INSUFFICIENT_SCOPE | Key không có scope | Hiện thông báo |
400 | INVALID_INPUT | Sai input | Hiện lỗi cụ thể |
404 | NOT_FOUND | Không tìm thấy | Hiện thông báo |
429 | RATE_LIMIT_EXCEEDED | Vượt giới hạn request | Retry sau Retry-After giây |
500 | FAIL | Lỗi hệ thống | Toast lỗi chung |
Header | Mô tả |
|---|---|
| Giới hạn tenant/10s |
| Còn lại tenant/10s |
| Giới hạn route/10s |
| Còn lại route/10s |
| Giây cần chờ khi bị 429 |