3CX WEB API Debian installation guide (manual mode)

Created by Oleg Agapov, Modified on Thu, 4 Jul at 10:12 PM by Oleg Agapov

Make sure that the 3CX server is installed and activated

1. Upload files


Create /var/www/webapi/


Download link https://download.creomate.com/webapi_debian_en.zip


Place files in a folder:

  • TCXWebAPI
  • TCXWebAPI.ini
  • AuthKeys.csv
  • AllowedIP.txt


Create /var/www/webapi/mp3 (for MP3 records) 


Don't forget grant write permissions to mp3 and log folders and make chmod +x TCXWebAPI for execute permission.


2. Install Nano for edit

apt install nano


3. Create daemon

nano /etc/systemd/system/webapi.service

Insert and save (ctrl+x -> y -> enter):

[Unit]
Description=webapi
After=nginx.service
After=3CXAudioProvider01.service
After=3CXCallFlow01.service
After=3CXCfgServ01.service
After=3CXEventNotificationManager.service
After=3CXIVR01.service
After=3CXMediaServer.service
After=3CXPhoneSystem01.service
After=3CXPhoneSystemMC01.service
After=3CXQueueManager01.service
After=3CXSystemService01.service
After=3CXTunnel01.service
[Service]
Environment=DOTNET_BUNDLE_EXTRACT_BASE_DIR=/var/tmp
WorkingDirectory=/var/www/webapi/
ExecStart=/var/www/webapi/TCXWebAPI --urls=http://127.0.0.1:8081
Restart=always
RestartSec=10
SyslogIdentifier=webapi

[Install]
WantedBy=multi-user.target


4. Enable and start daemon

systemctl enable webapi
systemctl start webapi



5. Edit nginx conf file (this operation must be performed every time 3CX is updated)


nano /etc/nginx/sites-enabled/3cxpbx
or
nano /var/lib/3cxpbx/Bin/nginx/conf/nginx.conf

 After


    client_max_body_size 300m;

    root "C:/ProgramData/3CX/Data/Http/wwwroot";


add


location ~ ^/webapi/?(.*) 

{
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8081/webapi/$1$is_args$args;
proxy_buffering off;
}


Restart NGNIX

systemctl restart nginx


6. Check

Local http - http://127.0.0.1:8081/webapi/tcx

Public https - https://{fqdn and port 3СХ}/webapi/tcx

You'll receive: {"product":"3CX REST API","version":"2.2.0","release":"Webhooks","licenseExpire":"01.01.0001 00:00:00","clientLicensesNum":"forbidden","concurrentCalls":0,"callRecords":false,"api":false,"quality":false}


7. License activation

https://{FQDN and port 3СХ}:5001/webapi/admin/

login - TCXWebAPI
password- Activate (after activation will be license XXXX-XXXX)

For trial activation use NHQE-QRND-TRIAL (only once)


8. Install lame for wav into mp3 conversion

3CX changes the standard repositories to its own, if lame is not installed, then you need to add repositories (for example, debian):


9. (After 3CX Update) Nginx configuration setup

After 3CX update you should run the WebAPI update script according this manual.


Open the file for editing sources.list

nano /etc/apt/sources.list

Edit the file:


deb [arch=amd64 by-hash=yes signed-by=/usr/share/keyrings/3cx-archive-keyring.gpg] http://repo.3cx.com/debian/1806 buster main


deb [arch=amd64 by-hash=yes signed-by=/usr/share/keyrings/3cx-archive-keyring.gpg] http://repo.3cx.com/debian-security/1806 buster main


deb http://deb.debian.org/debian buster main contrib non-free

deb http://deb.debian.org/debian buster-updates main contrib non-free

deb http://deb.debian.org/debian buster-backports main contrib non-free

deb http://security.debian.org/debian-security/ buster/updates main contrib non-free



Save the file ctrl+z - y - enter


Update:

apt update

Install lame:

apt install lame


For restart WebAPI

service webapi stop
service webapi start

or

systemctl restart webapi


For test daemon status

systemctl status 'webapi'


For getting a debug journal

journalctl -fu webapi


Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article