Fetch Extension-Status by API

Status
Not open for further replies.

davidlienhard

Customer
Joined
Apr 29, 2020
Messages
2
Reaction score
4
Hello everybody
I was wondering whether it is possible to fetch the status of an Extension over an API. There have been some questions about a REST API in this forum but without any suitable answer: https://www.3cx.com/community/threads/rest-api-for-3cx.55646/
There also seems to be a 3CX API Client written in Typescript (https://github.com/3cx/3cx-api) but I could not find any documentation about that API.

The main reason why I'm asking is because many of our employees set their status to lunch but forget to reset this when they return leaving the status to lunch the whole afternoon. If I could fetch that status over an API I could remind the users to reset that status.

Best regards
David
 
Hello David,

Maybe you can use a CFD app for this. The CFD has the Get Extension Status component, which tells you the current profile in the property "CurrentProfileName".

So, you can create a Dialer app, which could check the status of the extension, and if it's not what it should be, you can send an email to the user, call the user, or even automatically change the status using the Set Extension Status component.

A Dialer app is a CFD flow that is executed repeatedly. But you are not forced to make calls in each cycle. So a Dialer app is also useful to keep tasks running in background, doing other monitoring tasks, like what you need now...
 
If you know how to use the 3CX Call Control API, it is a property on the extension object. Alternatively, we have a VoIPTools REST API.
 
Thanks for the replies. The CFD sounded like a solution but a pretty complicated one for my needs, so I did some additional research and I found the perfect solution for me.
There is a REST API in 3CX, it just does not seem to be in the docs (for whatever reason).
So what I did is the following:

Send a Post-Request with the following data and Content-type: application/json to this endpoint: https://yourhost/api/login
Code:
{Username: 'admin', Password: 'password'}

If the login was successful you get the text AuthSuccess and some cookies back.
After that you can send a get request (with the given cookies) to this endpoint:
https://yourhost/api/ExtensionList

and this will return something like this:
Code:
{
  "list": [
    {
      "Id": "3060",
      "IsOperator": true,
      "IsRegistered": false,
      "_str": "3060 Hauptnummer",
      "Number": "3060",
      "FirstName": "Hauptnummer",
      "LastName": "",
      "Email": "[email protected]",
      "Password": "123456",
      "MobileNumber": "",
      "OutboundCallerId": "",
      "Phones": 1,
      "MacAddress": "",
      "Membership": "DEFAULT",
      "CurrentProfile": "Available",
      "QueueStatus": 0,
      "DND": 0,
      "Warning": {
        "invalidPasswords": [
          "EXTENSIONS.WEAK.AUTH_ID",
          "EXTENSIONS.WEAK.AUTH_PASS",
          "EXTENSIONS.WEAK.PASS_MANAGEMENT_CONSOLE"
        ],
        "highAlert": ""
      }
    },
    ...,
    ...,
    ...
}

Where CurrentProfile is the status of the extension.
Looking at this file, there seem to be more endpoints: https://github.com/3cx/3cx-api/blob/master/dist/console-client.js

But to be honest I'm still wondering why this is not to be found in the docs.
But maybe this posts helps some other people with similar problems.
 
Status
Not open for further replies.

Forum statistics

Threads
112,326
Messages
591,900
Members
165,479
Latest member
Senergia