Kết nối kênhAgent Management

Agent Management

Tạ Quốc Thắng·6/2/2026

Agent Management API

General Authentication:All APIs use Kong dual-auth: Header Authorization(API key) is required. Header X-Tenant-IDinjected by Kong — if testing internal without going through Kong, omit this header, backend will resolve tenantId based on Authorization key. Do not use JWT (x-access-token) in this flow.


GET /v1/agents

Retrieve the list of all agents for the tenant. Supports filtering by status, queue, and pagination.

Authentication:Header X-Api-Key(scope: agent). Kong dual-auth: prioritizes X-Tenant-IDheader, fallback to query DB based on Authorization key.

Base URL:Dev: https://xapi-dev.alohub.vn |  Prod: https://xapi.alohub.vn

Parameters

Parameters

Location

Required

Type

Description

Example

team_id

query

No

number

Filter by specific tenantId (default from auth)

20260310

status

query

No

number

1 = active, 0 = inactive

1

queue_id

query

No

number

Filter agents belonging to this callin queue

1001226

page

query

No

number

Page, starting from 0 (default: 0)

0

size

query

No

number

Number of records per page (default: 20)

20

Request Body

Sample Code

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())

Response 200

{
  "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"
    }
  ]
}

Response Fields

Field

Type

Description

success

string

"1" = success, "0" = error

error_code

string

Error code

totalRecord

number

Total number of agents

data[].tenantId

number

Tenant ID

data[].tenantName

string

Tenant name

data[].agentId

string

Extension number — used as {id} in PUT /queues and PUT /recording

data[].status

number

1 = active, 0 = inactive

data[].userName

string

null

Username

data[].queueCallin

string

null

"-" — callin queue currently attached

data[].queueCallinId

string

null

Callin queue ID

data[].queueCallout

number

null

Callout queue ID

data[].queueCalloutName

string

null

Callout queue name

data[].isFollowMe

number

null

1 = enable follow-me

data[].priority

string

null

Priority in queue

data[].systemStatus

string

null

AVAILABLE / NOT AVAILABLE

data[].userStatus

string

null

AVAILABLE / LOGOUT

Error Codes

HTTP

error_code

Description

FE handling

401

UNAUTHORIZED

Missing or incorrect API key

Redirect to re-enter key

403

INSUFFICIENT_SCOPE

Key does not have scope agent

Show message

404

NOT_FOUND

Not found

Show message

429

RATE_LIMIT_EXCEEDED

Exceeded request limit

Retry after Retry-After seconds

500

FAIL

System error

General error toast

Rate Limit Headers

Header

Description

X-RateLimit-Limit-Tenant

Limit tenant/10s

X-RateLimit-Remaining-Tenant

Remaining tenant/10s

X-RateLimit-Limit-Route

Limit route/10s

X-RateLimit-Remaining-Route

Remaining route/10s

Retry-After

Seconds to wait when receiving 429


PUT /v1/agents/{id}/queues

Assign agent to callin or callout queue. type=callin: REPLACE ENTIRE old queue list — to add a queue, need to send both old + new list.

Authentication:Header X-Api-Key(scope: agent). Kong dual-auth: prioritizes X-Tenant-IDheader, fallback to query DB based on Authorization key.

Base URL:Dev: https://xapi-dev.alohub.vn |  Prod: https://xapi.alohub.vn

Parameters

Parameters

Location

Required

Type

Description

Example

{id}

path

Yes

number

agentId = extension number (obtained from GET /v1/agents)

082018

type

query

No

string

"callin" (default) or "callout"

callin

Request Body

{
  "queue_ids": [
    1001226,
    1000886
  ],
  "priority": 1
}

Field

Required

Description

queue_ids

Yes

Array of queue IDs. Must not be empty.

priority

No

Priority in callin queue. Only applies type=callin.

Sample Code

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())

Response 200

{
  "success": "1",
  "error_code": "SUCCESS",
  "error_message": "Agent queues updated successfully"
}

Response Fields

Field

Type

Description

success

string

"1" = success

error_code

string

SUCCESS when updated successfully

error_message

string

Result description

Error Codes

HTTP

error_code

Description

FE handling

401

UNAUTHORIZED

Missing or incorrect API key

Redirect to re-enter key

403

INSUFFICIENT_SCOPE

Key does not have scope agent

Show message

400

INVALID_INPUT

Incorrect input

Show specific error

404

NOT_FOUND

Not found

Show message

429

RATE_LIMIT_EXCEEDED

Exceeded request limit

Retry after Retry-After seconds

500

FAIL

System error

General error toast

Rate Limit Headers

Header

Description

X-RateLimit-Limit-Tenant

Limit tenant/10s

X-RateLimit-Remaining-Tenant

Remaining tenant/10s

X-RateLimit-Limit-Route

Limit route/10s

X-RateLimit-Remaining-Route

Remaining route/10s

Retry-After

Seconds to wait when receiving 429


PUT /v1/agents/{id}/recording

Enable or disable recording feature for agent. Requires DBA to run migration_add_is_record.sql first.

Authentication:Header X-Api-Key(scope: agent). Kong dual-auth: prioritizes X-Tenant-IDheader, fallback to query DB based on Authorization key.

Base URL:Dev: https://xapi-dev.alohub.vn |  Prod: https://xapi.alohub.vn

Parameters

Parameters

Location

Required

Type

Description

Example

{id}

path

Yes

number

agentId = extension number

082018

Request Body

{
  "enabled": true
}

Field

Required

Description

enabled

Yes

true = enable recording, false = disable recording

Sample Code

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())

Response 200

{
  "success": "1",
  "error_code": "SUCCESS",
  "error_message": "Recording enabled for agent 082018"
}

Response Fields

Field

Type

Description

success

string

"1" = success

error_code

string

SUCCESS when updated successfully

error_message

string

"Recording enabled/disabled for agent {id}"

Error Codes

HTTP

error_code

Description

FE handling

401

UNAUTHORIZED

Missing or incorrect API key

Redirect to re-enter key

403

INSUFFICIENT_SCOPE

Key does not have scope agent

Show message

400

INVALID_INPUT

Incorrect input

Show specific error

404

NOT_FOUND

Not found

Show message

429

RATE_LIMIT_EXCEEDED

Exceeded request limit

Retry after Retry-After seconds

500

FAIL

System error

General error toast

Rate Limit Headers

Header

Description

X-RateLimit-Limit-Tenant

Limit tenant/10s

X-RateLimit-Remaining-Tenant

Remaining tenant/10s

X-RateLimit-Limit-Route

Limit route/10s

X-RateLimit-Remaining-Route

Remaining route/10s

Retry-After

Seconds to wait when receiving 429


Was this article helpful?
Updated: 6/2/2026