Monitor WebSocket API Events with Postman
This topic provides an example of capturing call events to demonstrate how to monitor API events of Yeastar P-Series Cloud Edition with Postman.
Prerequisites
- You have downloaded and installed Postman desktop app.
- You have enabled Yeastar P-Series Cloud Edition API.Note: If you want to monitor extension status or trunk status, make sure that the corresponding monitor settings in the Advanced Settings are enabled.
- You have got an access token.
Procedure
- Sign in to Postman.
- At the side-bar, click to open a new request tab.
- Establish a WebSocket connection with Yeastar P-Series Cloud Edition
API.
- In the request field, compose the WebSocket connection request.
In this example, compose the following request:
wss://yeastardocs.example.yeastarcloud.com/openapi/v1.0/subscribe?access_token=ah1i5B5uGYBY4W4ITiOV9lBwrDp2KPyQ
- Click Connect.
The Response field returns "Connected", indicating that the WebSocket connection is successfully established.
- In the request field, compose the WebSocket connection request.
- Subscribe to the desired events.
- Query the desired event ID in API Event Summary, and compose the event subscription
message in the Message tab.
In this example, subscribe to the events (30011) Call Status Changed and (30012) New CDR.
{"topic_list":[30011,30012]}
- Click Send.
The Response field returns "SUCCESS", indicating that the event subscription is successful.
- Query the desired event ID in API Event Summary, and compose the event subscription
message in the Message tab.
- Send a heartbeat request at regular intervals to keep the connection
alive.Note: If there is no interaction between the Postman and PBX for 60 seconds, the WebSocket connection will be automatically disconnected.
- In the Message tab, enter
heartbeat
. - Click Send.
The Response field returns a heartbeat response, indicating that the request is successful.
- In the Message tab, enter
Result
When a subscribed event occurs, the system automatically sends the event report.
In this example, when the monitored extension receives, answers and ends a call, the system automatically sends the event report of "(30011) Call Status Changed" and "(30012) New CDR".