Setup of Call Control API

VoIPTools

3CX MVP
Platinum Partner
Advanced Certified
Joined
Feb 13, 2013
Messages
3,845
Reaction score
1,913
I am more than a little confused by this screen:

1735582722527.png

I have had success authenticating to the XAPI and calling methods, but which APIs work seems to depend on the choices made on the screen above. What I would like to achieve is the ability to invoke any XAPI method, in any Department, -- AND -- subscribe to any real-time events anywhere in the PBX. I can do all of these things with the original (non-web-based) Call Control API.
But perhaps I should start from the beginning.

The first field "Client ID" requires an integer. Is this supposed to be a new extension number, or an existing extension number, or any random integer? I randomly chose "200" on my 3-digit test PBX which is not currently used by any extension and that worked. But a more definitive explanation of what this should be would be helpful. Does this become a potential route destination?

For "Department" if I choose "System Wide" the "Role" field is set to "User" and cannot be changed. Perhaps "System Wide" is synonymous with the "System Owner" role? If so, then presumably the "Role" field should be set to "System Owner" rather than "User" or hidden entirely to avoid confusion. If it is indeed a "User" role, then what limitations does that place on calling the API's or subscribing to real-time events? Curiously, if I chose a specific department, then I can choose the "System Owner" role. That is pretty confusing to me since a System Owner has full rights to everything and every department...

I assume if I am using the WebSocket connection, enabling access to both the XAPI and the Call Control API are appropriate. However, it is unclear if calling the XAPI via the socket returns exactly the same information as a normal non-socket request? In the documentation it talks about data size limitations on the socket.

Finally, it appears I have successfully connected to the WebSocket, but if I place a phone call or delete an extension, I do not receive any events from the socket. Admittingly, I have always worked with SignalR rather than directly with WebSockets so I may be missing something in my C# code. Maybe.... maybe... you might have a multi-tenant scenario where the System Owner wants to limit a tenant's programmer to only do things within their department, but I just want full access to everything -- XAPI and Call Control API and it is unclear how I achieve that on this screen, and it is unclear how to subscribe to real-time events using c#.
 
I am now able to receive real-time events when making an extension-to-extension phone call. That is a very positive step. I'm still very confused by the API setup screen in the original post, but at least it is working at some level. Curiously, I'm getting a lot more events than I would have expected for a simple phone call, and the event data is VERY sparse. The data certainly does not provide enough information to understand why 10 events just to (1) initiate the call, (2) answer, then (3) hang up.

I thought perhaps the number of times the phone rang was a contributor to the number of events, but no -- the same number of events whether I allowed the phone to ring one or more times. I then thought perhaps it was the call progressing from dialing to ringing to answered to disconnected, but that doesn't match the number of events in any way that makes sense to me:

2024-12-30 20:03:35 [INF] (XAPI.ExternalApiService.) Received message: "{\r\n \"sequence\": 60,\r\n \"event\": {\r\n \"event_type\": 0,\r\n \"entity\": \"/callcontrol/101/participants/26\",\r\n \"attached_data\": null\r\n }\r\n}"

2024-12-30 20:03:35 [INF] (XAPI.ExternalApiService.) Received message: "{\r\n \"sequence\": 61,\r\n \"event\": {\r\n \"event_type\": 0,\r\n \"entity\": \"/callcontrol/101/participants/26\",\r\n \"attached_data\": null\r\n }\r\n}"

2024-12-30 20:03:35 [INF] (XAPI.ExternalApiService.) Received message: "{\r\n \"sequence\": 62,\r\n \"event\": {\r\n \"event_type\": 0,\r\n \"entity\": \"/callcontrol/100/participants/28\",\r\n \"attached_data\": null\r\n }\r\n}"

2024-12-30 20:03:35 [INF] (XAPI.ExternalApiService.) Received message: "{\r\n \"sequence\": 63,\r\n \"event\": {\r\n \"event_type\": 0,\r\n \"entity\": \"/callcontrol/100/participants/28\",\r\n \"attached_data\": null\r\n }\r\n}"

2024-12-30 20:03:42 [INF] (XAPI.ExternalApiService.) Received message: "{\r\n \"sequence\": 64,\r\n \"event\": {\r\n \"event_type\": 0,\r\n \"entity\": \"/callcontrol/100/participants/29\",\r\n \"attached_data\": null\r\n }\r\n}"

2024-12-30 20:03:43 [INF] (XAPI.ExternalApiService.) Received message: "{\r\n \"sequence\": 65,\r\n \"event\": {\r\n \"event_type\": 0,\r\n \"entity\": \"/callcontrol/101/participants/26\",\r\n \"attached_data\": null\r\n }\r\n}"

2024-12-30 20:03:43 [INF] (XAPI.ExternalApiService.) Received message: "{\r\n \"sequence\": 66,\r\n \"event\": {\r\n \"event_type\": 0,\r\n \"entity\": \"/callcontrol/101/participants/26\",\r\n \"attached_data\": null\r\n }\r\n}"

2024-12-30 20:03:43 [INF] (XAPI.ExternalApiService.) Received message: "{\r\n \"sequence\": 67,\r\n \"event\": {\r\n \"event_type\": 1,\r\n \"entity\": \"/callcontrol/100/participants/28\",\r\n \"attached_data\": null\r\n }\r\n}"

2024-12-30 20:03:52 [INF] (XAPI.ExternalApiService.) Received message: "{\r\n \"sequence\": 68,\r\n \"event\": {\r\n \"event_type\": 1,\r\n \"entity\": \"/callcontrol/100/participants/29\",\r\n \"attached_data\": null\r\n }\r\n}"

2024-12-30 20:03:52 [INF] (XAPI.ExternalApiService.) Received message: "{\r\n \"sequence\": 69,\r\n \"event\": {\r\n \"event_type\": 1,\r\n \"entity\": \"/callcontrol/101/participants/26\",\r\n \"attached_data\": null\r\n }\r\n}"

2024-12-30 20:05:45 [INF] (XAPI.ExternalApiService.) Received message: "{\r\n \"sequence\": 70,\r\n \"event\": {\r\n \"event_type\": 0,\r\n \"entity\": \"/callcontrol/101/participants/30\",\r\n \"attached_data\": null\r\n }\r\n}"

I'm still working on it...
 
I've read this thread about a week after you posted, looking for more info. Now some 3 months later I have at least some information.

I haven't used call control API, only XAPI, but they're similar.

Anyway, about the setup screen, that did change a bit as well in the meantime (I think) but generally what I've found:
- client ID can be anything, used text and numbers
- selecting one of the checkboxes enables it for /callcontroll/ or /xapi/v1/ endpoint, or both if both are checked
- even if enabled, further permissions apply
- I haven't tried much in permission settings, just two, using DEFAULT with either System Admin or System Owner
- interesting enough Admin will be blocked from Call & Chat History, Recordings, etc, which needs Owner permission
- why is that interesting? Because Admin can initiate whole system Backup, then download it, and extract most if not all of it from backup archive... go figure.. futile attempt at some kind of security

I am writing my findings to readme on GitHub, I assume you got way further than me past few months, since you're doing this primarily while we're just end users... But if you find it helpful, or want to contribute some findings, please get back to me!

GitHub: https://github.com/luxzg/3CX-XAPI_examples

I've added couple of XAPI scripts there as well.
 
We are also running into this. WebSocket connection has been successfully set up but it is completely unclear how to proceed. Events are missing essential details.

Input from 3CX would be greatly appreciated. @NicholasP_3CX, perhaps you or a colleague can provide us with the much-needed information?

Thanks,
Matthijs

 
  • Like
Reactions: Ecki
There's no support for the APIs. They are provided as is with the documentation. That's it.
 
  • Like
Reactions: NicholasP_3CX
I am completely new to this. I am attempting to connect the 3CX API to Monday.com. Is the 3CX API located in Settings>Integrations, because I do now see it anywhere. Different help files and searches reveal conflicting instructions. Thanks in advance.
 
I am completely new to this. I am attempting to connect the 3CX API to Monday.com. Is the 3CX API located in Settings>Integrations, because I do now see it anywhere. Different help files and searches reveal conflicting instructions. Thanks in advance.
Are you using v20 U5?

FYI we have an integration for Monday already, depending on your goals.
 
Are you using v20 U5?

FYI we have an integration for Monday already, depending on your goals.
I honestly am not even sure. I did manage to locate the API. I was not logged in as an Admin. I appreciate your response, more than you know. Could you perhaps send me the information on your 3CX to Monday solution? I would love to review it and if appropriate, consider it as an option. Once again, thank you so much.

Damian Kemper
[email protected]
 
  • Like
Reactions: Evolute IT
In case anyone is interested, I'm doing the following for testing:

Connect to the WebSocket:
npx wscat -c wss://url_3cx/callcontrol/ws -H "Authorization: Bearer access_token"

Send a request:
{"RequestID": "call-tracking","Path": "/callcontrol"}

I make a call and get these responses:
{
"sequence": 28,
"event": {
"event_type": 0,
"entity": "/callcontrol/1000/participants/15",
"attached_data": null
}

The issues I'm having are:

- API configuration: To receive events, I have to select the extensions. If I leave it blank, I don't receive any.

- In the events I receive, I don't have any event information; they're always empty.


I don't understand how they can offer an API and not provide support or good documentation.

Regards!
 

Latest Posts

Forum statistics

Threads
111,973
Messages
590,075
Members
164,895
Latest member
jasonkkrause