Yeastar P-Series API

🇹🇭 ภาษาไทย

ภาพรวม

Yeastar P-Series มี REST API (Application Programming Interface) สำหรับ integrate กับ third-party applications เช่น Call Center, Hotel PMS, CRM และระบบอื่นๆ ใน enterprise

ข้อจำกัด: API รองรับเฉพาะรุ่น P550, P560, P570 เท่านั้น (ไม่รองรับ P520)
Firmware ขั้นต่ำ: 37.7.0.16 ขึ้นไป


ความต้องการก่อนใช้งาน

  1. เปิดใช้งาน API บน PBX: Integrations > API > เปิด Toggle API
  2. (ไม่บังคับ) เปิด IP Restriction — กำหนด IP ที่อนุญาตเข้าถึง API
  3. ตั้งค่า Extension/Trunk Status Monitor ตามต้องการ
  4. บันทึก Client ID และ Client Secret จาก PBX web portal

รูปแบบการสื่อสาร

API รองรับ 2 รูปแบบ:

รูปแบบคำอธิบาย
API Request/ResponseApplication ส่ง HTTP request → PBX ตอบ response ทันที
Event SubscriptionApplication subscribe event → PBX push notification แบบ real-time

Protocol: HTTP (port 80) หรือ HTTPS (port 8088, แนะนำ)
Methods: GET และ POST
ทุก request ต้องใส่ header: User-Agent: OpenAPI


Authentication Flow

1. POST /openapi/v1.0/get_token
   → ส่ง username (Client ID) + password (Client Secret)
   → รับ access_token (หมดอายุ 30 นาที) + refresh_token (หมดอายุ 24 ชั่วโมง)

2. ใช้ access_token ใน URL ทุก request:
   GET /openapi/v1.0/{endpoint}?access_token={token}

3. ก่อน token หมดอายุ → POST /openapi/v1.0/refresh_token

4. เสร็จแล้ว → GET /openapi/v1.0/del_token

ข้อจำกัด: แต่ละ application มี valid token พร้อมกันได้สูงสุด 8 tokens

ตัวอย่าง — ขอ Access Token

POST /openapi/v1.0/get_token
Host: 192.168.5.150:8088
Content-Type: application/json
User-Agent: OpenAPI
{
    "username": "UEnH9Dmv6uBJEXsYcag1trNfQThYXXXX",
    "password": "ZLcXl63S9EtMnYoHUnjbVo6sA8CbXXXX"
}
{
    "errcode": 0,
    "errmsg": "SUCCESS",
    "access_token_expire_time": 1800,
    "access_token": "EXZMpZAO86mbrKm6rFtgeb3rfcpC9uqS",
    "refresh_token_expire_time": 86400,
    "refresh_token": "SCduGecwbG9jIusiS8FxFUVn3kf0Q9R8"
}

รูปแบบ URL

{base_url}/{api_path}/{endpoint}?access_token={access_token}
ส่วนรายละเอียด
base_urlhttps://{pbx_ip}:8088 หรือ http://{pbx_ip}:80 หรือ FQDN
api_pathopenapi/v1.0 (Call Report ใหม่: openapi/v2.0)
endpointชื่อ endpoint เช่น extension/list
access_tokenToken ที่ได้จาก get_token

สรุป Endpoints ทั้งหมด

Authentication

MethodEndpointคำอธิบาย
POSTget_tokenขอ access token
POSTrefresh_tokenต่ออายุ token
GETdel_tokenยกเลิก token

System

MethodEndpointคำอธิบาย
GETsystem/informationข้อมูล PBX (model, firmware, uptime)
GETsystem/capacityความจุ (จำนวน extension, concurrent calls, AI transcription)
GETsystem/get_menuoptionsดึง option values สำหรับสร้าง/แก้ไข features
POSTsystem/sendemailส่ง email

Extension (จัดการผู้ใช้ภายใน)

MethodEndpointคำอธิบาย
GETextension/listรายการ extension ทั้งหมด
GETextension/searchค้นหา extension
GETextension/getดึงข้อมูล extension เดียว
GETextension/queryดึงข้อมูลหลาย extension พร้อมกัน
GETextension/getpasswordดึง registration password + voicemail PIN
POSTextension/createเพิ่ม SIP extension
POSTextension/send_welcome_emailส่ง Linkus welcome email
POSTextension/updateแก้ไข extension
GETextension/deleteลบ extension

Organization

MethodEndpointคำอธิบาย
GET/POST`organization/listsearch

Trunk (SIP Trunk)

MethodEndpointคำอธิบาย
GET/POST`trunk/listsearch

Contacts & Phonebook

MethodEndpointคำอธิบาย
GET/POST`company_contact/listsearch
GET/POST`phonebook/listsearch

Auto Provisioning (จัดการ IP Phone)

MethodEndpointคำอธิบาย
GETphone/search, phone/getค้นหาและดูข้อมูล IP phone
GETauto_provisioning/compatibilityดู config options สำหรับ provisioning
POST`phone/batchcreatebatchupdate

Routing

MethodEndpointคำอธิบาย
GET/POST`inbound_route/listsearch
GET/POST`outbound_route/listsearch

Voicemail

MethodEndpointคำอธิบาย
GET/POST`vm/queryget

IVR / Queue / Conference / Paging

MethodEndpointคำอธิบาย
GET/POST`ivr/listsearch
GET/POST`queue/list+queue/call_status
GET/POST`conference/list+conference/start_interim
GET/POST`paging/listsearch

Recording & CDR

MethodEndpointคำอธิบาย
GET`recording/listsearch
GET/POST`cdr/listsearch
GET`call_report/listdetail

Settings

MethodEndpointคำอธิบาย
GET/POST`auto_recording/getupdate`
GET/POSTpin_list/...CRUD PIN list
GET/POSTblocked_number/..., allowed_number/...Blocked/Allowed numbers
GET/POST`call_note/getupdate`
GET/POST`web_server/getupdate`
GETstorage/listStorage list
GET/POSTcertificate/...CRUD certificates
GET/POSTbackup/... + `backup/downloadgetstatus`
GET`system_log/listdownload`

Messaging (SMS/WhatsApp/Facebook/LiveChat)

MethodEndpointคำอธิบาย
GET/POSTmessage/channel/..., message/queue/...Message channels + queues
GET/POSTmessage/campaign/..., message/session/..., message/message/...Campaigns, sessions, messages
POSTsms/createส่ง SMS ผ่าน GSM/3G/4G trunk

API Feature Settings

MethodEndpointคำอธิบาย
GET/POSTextension_status_monitor/...ตั้งค่า extension status monitoring
GET/POSTtrunk_status_monitor/...ตั้งค่า trunk status monitoring
GET/POST`webhook/queryupdate

Hotel

MethodEndpointคำอธิบาย
GET/POST`wakeupcall/listget
POSThotel/checkoutเช็คเอาท์แขก hotel

Call Control (สำคัญมาก)

MethodEndpointคำอธิบาย
GETcall/queryดูสถานะสายที่กำลัง active
POSTcall/dialโทรออก (หลายประเภท)
POSTcall/accept_inboundรับสายเข้าในโหมด inbound control
POSTcall/refuse_inboundปฏิเสธสายเข้า
POSTcall/listenMonitoring สาย (ดักฟัง)
POSTcall/holdพักสาย
POSTcall/unholdรับสายคืน
POSTcall/muteปิดเสียง
POSTcall/unmuteเปิดเสียง
POSTcall/parkPark สาย
GETcall/park_statusดูสายที่ park อยู่
POSTcall/directly_forward_to_voicemailโอนสายไป voicemail
POSTcall/transferโอนสาย (blind/attended)
POSTcall/add_memberเพิ่มคนในสาย
POSTcall/play_promptเล่น audio prompt
POSTcall/hangupวางสาย
POST`call/record_startrecord_pause

uaCSTA Call Control

MethodEndpointคำอธิบาย
POST`uacsta_call/acceptrefuse

Event Monitoring

WebSocket vs Webhook

WebSocketWebhook
รูปแบบLong-lived connectionHTTP callback (push)
URLwss://{pbx}:{port}/openapi/v1.0/subscribe?access_token=...URL ที่กำหนดใน PBX settings
Subscribeส่ง {"topic_list":[30011,30012]}Auto push ทุก subscribed event
Heartbeatต้องส่งทุก 60 วินาทีไม่ต้องการ
เหมาะกับReal-time dashboard, call centerWebhook integration, CRM

รายการ Events ทั้งหมด

Event IDชื่อคำอธิบาย
30005Organization Status Switch State Changedสถานะ organization feature เปลี่ยน
30006Organization Structure Changedโครงสร้าง organization เปลี่ยน
30007Extension Registration Status Changedสถานะการลงทะเบียน extension เปลี่ยน (SIP/Linkus)
30008Extension Call State Changedสถานะสาย extension เปลี่ยน
30009Extension Presence State ChangedPresence status extension เปลี่ยน
30010Trunk Registration State Changedสถานะ trunk เปลี่ยน
30011Call State Changedสถานะสายโทรศัพท์เปลี่ยน (real-time)
30012Call End Details Notificationสายวาง → ส่ง CDR ใหม่
30013Call Transfer Reportมีการโอนสาย
30014Call Forwarding Reportมีการ forward สาย
30015Call Failure Reportสายล้มเหลว
30016Incoming Call Requestสายเข้าจาก monitored trunk
30017DTMF Digit Reportกดปุ่มระหว่างสาย
30018Prompt Playback Completed Reportเล่น audio prompt เสร็จ
30019Satisfaction Survey Feedbackแขกกด DTMF ประเมินความพึงพอใจ
30020uaCSTA Call Reportสถานะ uaCSTA call เปลี่ยน
30022Extension Information UpdatedExtension ถูกสร้าง/แก้ไข/ลบ
30023Trunk Information UpdatedTrunk ถูกสร้าง/แก้ไข/ลบ
30024No-hosted ConferenceHost ออกจาก conference
30025Agent Automatic PauseAgent ถูก pause อัตโนมัติ (missed calls เกิน limit)
30026Agent Ringing TimeoutAgent พลาดสายเพราะ ringing timeout
30027Call Report Download Resultดาวน์โหลด report แบบ async เสร็จ
30028Call Note Status Updatedสถานะ call note เปลี่ยน
30029Agent Status Changedสถานะ agent เปลี่ยน
30030Bulk Message Sending Failedส่ง bulk message บางส่วนล้มเหลว
30031New Message Notificationได้รับ inbound message ใหม่
30032Message Sending Resultผลลัพธ์การส่ง message
30033Recording Download Completedดาวน์โหลด recording แบบ async เสร็จ
30034System Event Notification (Information)System event ระดับ info
30035System Event Notification (Warning)System event ระดับ warning

Use Cases สำหรับออฟฟิค

ScenarioEndpoint/Event ที่ใช้
CRM popup เมื่อมีสายเข้าEvent 30016 + call/query
Click-to-call จาก CRMcall/dial
Dashboard live call statusEvent 30011 + call/query
Auto provisioning Yealink T31Gphone/batchcreate + phone/batchreprovision
Hotel wake-up callwakeupcall/create + hotel/checkout
Export CDR ไป databasecdr/list + Event 30012
Queue monitoringqueue/agent_status + Event 30029

ความเชื่อมโยง

  • Yeastar P-Series — parent system; API ต้องการรุ่น P550/P560/P570
  • Yeastar P-Series Features — Contact Center, Hotel Management ที่ API รองรับ
  • Yeastar P-Series Admin Guide — Extension, Trunk, IVR, Queue ที่ API จัดการได้
  • Yealink T31G — IP phone ที่ใช้ auto provisioning API + uaCSTA event
  • Dahua.Api — pattern เดียวกัน: C# wrapper → REST API → integration

🇬🇧 English

Overview

Yeastar P-Series provides a RESTful API for integration with third-party applications such as call centers, hotel PMS systems, CRM platforms, and other enterprise software.

Supported models: P550, P560, P570 only (P520 is NOT supported)
Minimum firmware: 37.7.0.16


Prerequisites

  1. Enable API on the PBX: Integrations > API > Toggle API On
  2. (Optional) Enable IP Restriction to whitelist permitted IP addresses
  3. Configure Extension/Trunk Status Monitors as needed
  4. Note down the Client ID and Client Secret from the PBX web portal

Communication Methods

ModeDescription
API Request/ResponseApplication sends HTTP request → PBX returns response immediately
Event SubscriptionApplication subscribes to events → PBX pushes real-time notifications

Protocol: HTTP (port 80) or HTTPS (port 8088, recommended)
HTTP Methods: GET and POST only
Required header on every request: User-Agent: OpenAPI


Authentication Flow

1. POST /openapi/v1.0/get_token
   → Send username (Client ID) + password (Client Secret)
   → Receive access_token (expires in 30 min) + refresh_token (expires in 24 h)

2. Include access_token in every subsequent request URL:
   GET /openapi/v1.0/{endpoint}?access_token={token}

3. Before token expires → POST /openapi/v1.0/refresh_token

4. When done → GET /openapi/v1.0/del_token

Limit: Maximum 8 simultaneous valid tokens per application.

Example — Get Access Token

POST /openapi/v1.0/get_token
Host: 192.168.5.150:8088
Content-Type: application/json
User-Agent: OpenAPI
{
    "username": "UEnH9Dmv6uBJEXsYcag1trNfQThYXXXX",
    "password": "ZLcXl63S9EtMnYoHUnjbVo6sA8CbXXXX"
}
{
    "errcode": 0,
    "errmsg": "SUCCESS",
    "access_token_expire_time": 1800,
    "access_token": "EXZMpZAO86mbrKm6rFtgeb3rfcpC9uqS",
    "refresh_token_expire_time": 86400,
    "refresh_token": "SCduGecwbG9jIusiS8FxFUVn3kf0Q9R8"
}

URL Format

{base_url}/{api_path}/{endpoint}?access_token={access_token}
ComponentDetails
base_urlhttps://{pbx_ip}:8088 or http://{pbx_ip}:80 or FQDN
api_pathopenapi/v1.0 (Call Report v2: openapi/v2.0)
endpointSpecific endpoint e.g. extension/list
access_tokenToken obtained from get_token

API Endpoint Reference

Authentication

MethodEndpointDescription
POSTget_tokenGet API access token
POSTrefresh_tokenRefresh API access token
GETdel_tokenRevoke API access token

System

MethodEndpointDescription
GETsystem/informationQuery PBX info (model, firmware, uptime)
GETsystem/capacityQuery capacity (extensions, concurrent calls, AI transcription quota)
GETsystem/get_menuoptionsQuery option values for creating/updating features
POSTsystem/sendemailSend an email

Extension Management

MethodEndpointDescription
GETextension/listList all extensions
GETextension/searchSearch extensions
GETextension/getGet single extension details
GETextension/queryGet multiple extensions at once
GETextension/getpasswordGet registration password + voicemail PIN
POSTextension/createCreate a SIP extension
POSTextension/send_welcome_emailSend Linkus welcome email
POSTextension/updateEdit an extension
GETextension/deleteDelete an extension

Organization

MethodEndpointDescription
GET/POSTorganization/list|search|get|query|create|update|deleteFull CRUD for organizations

Trunk (SIP Trunks)

MethodEndpointDescription
GET/POSTtrunk/list|search|get|query|itsp_list|create|update|deleteCRUD SIP trunks + query ITSP list

Contacts & Phonebook

MethodEndpointDescription
GET/POSTcompany_contact/...CRUD company contacts
GET/POSTphonebook/...CRUD phonebooks

Auto Provisioning

MethodEndpointDescription
GETphone/search, phone/getSearch/view IP phone details
GETauto_provisioning/compatibilityQuery config options for provisioning
POSTphone/batchcreate|batchupdate|batchreprovision|batchreboot|batchdeleteBulk IP phone management

Routing

MethodEndpointDescription
GET/POSTinbound_route/...CRUD inbound routes
GET/POSToutbound_route/...CRUD outbound routes

Voicemail

MethodEndpointDescription
GET/POSTvm/query|get|download|create|update|delete|delete_extension_vmVoicemail message management

IVR / Queue / Conference / Paging

MethodEndpointDescription
GET/POSTivr/...CRUD IVR menus
GET/POSTqueue/... + agent controlsCRUD queues + agent login/pause/status
GET/POSTconference/... + real-time controlsCRUD conferences + invite/kick/mute members
GET/POSTpaging/...CRUD paging groups

Recording & CDR & Reports

MethodEndpointDescription
GETrecording/list|search|download|playtoextensionRecording file management
GET/POSTcdr/list|search|download|getoption|updateoptionCDR queries + options
GETcall_report/list|detail|downloadCall statistics reports
GETcall_schedule_report/list|downloadScheduled report management

Call Control (Core Integration)

MethodEndpointDescription
GETcall/queryQuery active call details
POSTcall/dialInitiate a call (multiple types)
POSTcall/accept_inboundAccept inbound call (inbound control mode)
POSTcall/refuse_inboundRefuse inbound call
POSTcall/listenMonitor/spy a call
POSTcall/hold / call/unholdHold/resume a call
POSTcall/mute / call/unmuteMute/unmute a call member
POSTcall/park / GET call/park_statusPark a call / query parked calls
POSTcall/directly_forward_to_voicemailForward to voicemail
POSTcall/transferBlind or attended transfer
POSTcall/add_memberInvite member to active call
POSTcall/play_promptPlay audio prompt to a number
POSTcall/hangupHang up a call
POSTcall/record_start|record_pause|record_unpauseControl call recording

uaCSTA Call Control

MethodEndpointDescription
POSTuacsta_call/accept|refuse|hangupControl calls via uaCSTA (IP phones)

Hotel

MethodEndpointDescription
GET/POSTwakeupcall/list|get|query|create|update|deleteWake-up call (alarm) management
POSThotel/checkoutPerform hotel guest checkout

Messaging

MethodEndpointDescription
GET/POSTmessage/channel|queue|campaign|session|message/...Messaging (SMS/WhatsApp/Facebook/LiveChat)
POSTsms/createSend SMS via GSM/3G/4G trunk

Event Monitoring

WebSocket vs Webhook Comparison

WebSocketWebhook
ConnectionPersistent long-lived connectionHTTP callback (no persistent connection)
URLwss://{pbx}:{port}/openapi/v1.0/subscribe?access_token=...User-defined URL in PBX settings
SubscribeSend {"topic_list":[30011,30012]}Auto-push on subscribed events
HeartbeatRequired every 60 secondsNot required
Best forReal-time dashboard, call controlCRM webhook, automation triggers

Complete Events List

Event IDNameTrigger
30005Organization Status Switch State ChangedOrganization feature enabled/disabled
30006Organization Structure ChangedOrganization config modified
30007Extension Registration Status ChangedSIP/Linkus registration state change
30008Extension Call State ChangedExtension call status change
30009Extension Presence State ChangedExtension presence (DND/available/etc.) changes
30010Trunk Registration State ChangedTrunk registration state change
30011Call State ChangedAny call status change (real-time)
30012Call End Details NotificationCall ends — CDR sent
30013Call Transfer ReportCall transferred
30014Call Forwarding ReportCall forwarded
30015Call Failure ReportCall initiation failed
30016Incoming Call RequestInbound call on monitored trunk
30017DTMF Digit ReportKey pressed during a call
30018Prompt Playback Completed ReportAudio prompt finished playing
30019Satisfaction Survey FeedbackCaller completed DTMF satisfaction survey
30020uaCSTA Call ReportuaCSTA-controlled call state change
30022Extension Information UpdatedExtension created/edited/deleted
30023Trunk Information UpdatedTrunk created/edited/deleted
30024No-hosted ConferenceConference host left
30025Agent Automatic PauseAgent auto-paused (max missed calls reached)
30026Agent Ringing TimeoutAgent missed call due to ringing timeout
30027Call Report Download ResultAsync report download URL ready
30028Call Note Status UpdatedCall note availability changed
30029Agent Status ChangedAgent status change
30030Bulk Message Sending FailedMessage campaign partial/total failure
30031New Message NotificationInbound message received via API channel
30032Message Sending ResultOutbound message delivery status changed
30033Recording Download CompletedAsync recording download complete
30034System Event Notification (Information)Info-level system event
30035System Event Notification (Warning)Warning-level system event

Common Use Cases

ScenarioEndpoints / Events
CRM screen pop on inbound callEvent 30016 + call/query
Click-to-call from CRMcall/dial
Live call dashboardEvent 30011 + call/query
Auto-provision Yealink T31G phonesphone/batchcreate + phone/batchreprovision
Hotel wake-up callswakeupcall/create + hotel/checkout
CDR export to databasecdr/list + Event 30012
Queue agent monitoringqueue/agent_status + Event 30029
Call recording on demandcall/record_start + recording/download