Skip to content

Máy nhánh (Extensions) ​

Quản lý máy nhánh SIP của tổng đài: liệt kê, tạo mới, sửa, xoá, lấy số khả dụng, đổi mật khẩu SIP.

GET /api/pbx/extensions — Liệt kê ​

Query parameters ​

FieldTypeRequiredMô tảGiá trị hợp lệ
searchstringoptionalTìm theo extension_number hoặc display_name (LIKE)
statusstringoptionalLọc theo trạng thái configactive, disabled
pageintegeroptionalSố trang≥ 1 (default 1)
per_pageintegeroptionalSố bản ghi/trang1-200 (default 50)

Response fields (mỗi item trong data[]) ​

FieldTypeMô tảGiá trị
extension_numberstringSố máy nhánh dùng để đăng ký SIP.3-10 chữ số
display_namestring|nullTên hiển thị (Tên hiển thị khi gọi nội bộ (Caller ID Name).)max 100 ký tự
voicemail_enabledboolCó bật voicemail khôngtrue / false
outbound_caller_idstring|nullSố gọi ra mặc địnhPhải tồn tại trong /caller-ids
recording_modestringChế độ ghi âmnone, inbound, outbound, all
statusstringTrạng thái cấu hình adminactive, disabled
team_idinteger|nullID nhóm
department_idinteger|nullID phòng ban
max_concurrentintegerSố cuộc gọi đồng thời tối đa1-10
tls_enabledboolCó bật SIPS/TLS khôngtrue / false
created_atdatetimeNgày tạo (ISO 8601 + offset)
updated_atdatetimeNgày cập nhật cuối

Response Body (JSON) — 200 ​

json
{
  "current_page": 1,
  "data": [
    {
      "extension_number": "1001",
      "display_name": "Mac I5",
      "voicemail_enabled": true,
chọn outbound_caller_id
      "recording_mode": "all",
      "status": "active",
      "team_id": 2,
      "department_id": null,
      "max_concurrent": 2,
      "tls_enabled": false,
      "created_at": "2026-04-06T12:19:13+00:00",
      "updated_at": "2026-06-18T11:01:47+00:00"
    }
  ],
  "last_page": 2,
  "per_page": 10,
  "total": 17
}

GET /api/pbx/extensions/{ext} — Chi tiết ​

Path parameter ​

FieldTypeMô tả
extstringextension_number (KHÔNG phải id)

Response = 12 trường giống API danh sách, bổ sung thêm trường sip_registration. sip_registration realtime.

Response Body (JSON) — 200 ​

json
{
  "data": {
    "extension_number": "1001",
    "display_name": "Mac I5",
    "voicemail_enabled": true,
    "outbound_caller_id": null,
    "recording_mode": "all",
    "status": "active",
    "team_id": 2,
    "department_id": null,
    "max_concurrent": 2,
    "tls_enabled": false,
    "created_at": "2026-04-06T12:19:13+00:00",
    "updated_at": "2026-06-18T11:01:47+00:00",
    "sip_registration": "registered"
  }
}
FieldTypeMô tảGiá trị hợp lệ
statusstringCấu hình adminactive, disabled
sip_registrationstringTrạng thái Trạng thái đăng ký SIP theo thời gian thực. — CRM dùng để biết softphone online hay khôngregistered, unregistered, unknown

POST /api/pbx/extensions — Tạo mới ​

Request body fields ​

FieldTypeRequiredMô tảGiá trị hợp lệ
extension_numberstring✅Số máy nhánh — duy nhất trong mỗi tài khoảnRegex ^[0-9]{3,10}$ (3-10 chữ số)
display_namestringoptionalTên hiển thịmax 100 ký tự
team_idintegeroptionalID nhómPhải tồn tại trong teams
sip_passwordstringoptionalMật khẩu SIP register — Nếu không truyền, hệ thống tự sinh mật khẩu gồm 24 ký tự chữ và số.min 8, max 100 ký tự
voicemail_enabledbooloptionalBật voicemailtrue / false (default false)
voicemail_pinstringoptionalPIN truy cập voicemailmax 20 ký tự
recording_modestringoptionalChế độ ghi âmnone / inbound / outbound / all (default none)
max_concurrentintegeroptionalCuộc gọi đồng thời tối đa1-10 (default 2)
outbound_caller_idstringoptionalSố gọi ra mặc địnhPhải tồn tại trong /api/pbx/caller-ids (active)

Request Body (JSON) ​

json
{
  "extension_number": "9001",
  "display_name": "Sales 01",
  "voicemail_enabled": true,
  "recording_mode": "all",
  "max_concurrent": 2,
  "outbound_caller_id": "0900000020"
}

Response body fields (12 field như list + 2 field bổ sung khi tạo) ​

FieldTypeMô tả
sip_passwordstringMật khẩu SIP — chỉ trả 1 lần, lưu lại để cấu hình Softphone vì chỉ hiển thị một lần.
generated_passwordbooltrue nếu Zorio tự sinh, false nếu client truyền

Response Body (JSON) — 201 ​

json
{
  "data": {
    "extension_number": "9001",
    "display_name": "Sales 01",
    "voicemail_enabled": true,
    "recording_mode": "all",
    "status": "active",
    "max_concurrent": 2,
    "outbound_caller_id": "0900000020",
    "team_id": null,
    "department_id": null,
    "tls_enabled": false,
    "created_at": "2026-06-29T04:53:59+00:00",
    "updated_at": "2026-06-29T04:53:59+00:00",
    "sip_password": "<sip_password_chỉ_hiển_thị_1_lần>",
    "generated_password": true
  }
}

PUT /api/pbx/extensions/{ext} — Cập nhật ​

Request body fields (Tất cả trường đều là tùy chọn, chỉ cần gửi các trường cần cập nhật. — chỉ truyền field cần đổi) ​

FieldTypeMô tảGiá trị hợp lệ
display_namestring|nullTên hiển thịmax 100 ký tự
team_idinteger|nullID nhóm
voicemail_enabledboolBật voicemailtrue / false
voicemail_pinstring|nullPIN voicemailmax 20
recording_modestringChế độ ghi âmnone / inbound / outbound / all
max_concurrentintegerCuộc đồng thời tối đa1-10
outbound_caller_idstring|nullSố gọi raPhải có trong /api/pbx/caller-ids (active)
statusstringTrạng thái cấu hìnhactive / disabled

Lưu ý

extension_number và sip_password KHÔNG đổi qua PUT. Đổi sip_password → dùng endpoint /change-password.

Request Body (JSON) ​

json
{
  "display_name": "Sales 01 (renamed)",
  "voicemail_enabled": false,
  "max_concurrent": 4,
  "recording_mode": "all",
  "outbound_caller_id": "0900000020"
}

Response Body (JSON) — 200 ​

json
{
  "data": {
    "extension_number": "1001",
    "display_name": "Sales 01 (renamed)",
    "voicemail_enabled": false,
    "outbound_caller_id": "0900000020",
    "recording_mode": "all",
    "status": "active",
    "team_id": null,
    "department_id": null,
    "max_concurrent": 4,
    "tls_enabled": false,
    "created_at": "2026-04-06T12:19:13+00:00",
    "updated_at": "2026-06-29T07:55:12+00:00"
  }
}

DELETE /api/pbx/extensions/{ext} — Xoá ​

Không có Request Body.

Response Body (JSON) — 200 ​

json
{
  "data": { "deleted": true }
}

Thực hiện Soft Delete và làm mới (flush) bộ nhớ đệm.

GET /api/pbx/caller-ids — Liệt kê số khả dụng ​

Trả các outbound caller ID status=active của khách hàng — dùng khi pick outbound_caller_id cho ext hoặc caller_id cho click-to-call.

Query parameters ​

FieldTypeMô tảGiá trị
searchstringMatch number hoặc display_name
pageintegerSố trang≥ 1
per_pageintegerSố bản ghi/trang1-200 (default 50)

Response body fields ​

FieldTypeMô tảGiá trị
numberstringSố gọi ra (E.164 hoặc nội địa VN)8-15 chữ số
display_namestring|nullTên hiển thị nội bộ
carrierstringNhà mạngviettel / mobifone / vinaphone / vietnamobile / landline / other
cli_typestringLoại sốmobile / fixed_02x / hotline_1900 / hotline_1800 / brandname
statusstringTrạng tháiactive (luôn vì query lọc)

Response Body (JSON) — 200 ​

json
{
  "current_page": 1,
  "data": [
    { "number": "0900000020", "display_name": "POC", "carrier": "landline", "cli_type": "mobile", "status": "active" },
    { "number": "0900000021", "display_name": "POC", "carrier": "landline", "cli_type": "mobile", "status": "active" }
  ],
  "last_page": 1, "per_page": 50, "total": 7
}

Khi POST/PUT extension với outbound_caller_id không có trong list → HTTP 422:

json
{ "errors": { "outbound_caller_id": ["Giá trị đã chọn cho outbound caller id không hợp lệ."] } }

POST /api/pbx/extensions/{ext}/change-password — Xoay mật khẩu SIP ​

Request body fields ​

FieldTypeRequiredMô tảGiá trị
new_passwordstringoptionalMật khẩu SIP mới — không truyền → tự sinh 24 ký tự alphanumericmin 8, max 100

Request Body (JSON) — tự sinh mật khẩu (body rỗng) ​

json
{}

Request Body (JSON) — đặt mật khẩu thủ công ​

json
{
  "new_password": "MyNewStrongPwd123"
}

Response body fields ​

FieldTypeMô tả
extension_numberstringSố máy nhánh đã đổi
sip_passwordstringMật khẩu mới chỉ được trả về một lần, cần lưu lại ngay sau khi nhận.
generated_passwordbooltrue nếu Zorio tự sinh, false nếu client truyền

Response Body (JSON) — 200 ​

json
{
  "data": {
    "extension_number": "1001",
    "sip_password": "AbC123...",
    "generated_password": true
  }
}

Cấp phép theo điều khoản sử dụng của Zorio.