1. Uploading Files to the System


  • Download required files for Windows from here.

  • Extract all files to the folder named "webapi" and copy them to the directory shown below:
    C:\Program Files\3CX Phone System\Bin\webapi

  • Create an "mp3" folder in the following directory as shown for MP3 files:
    C:\Program Files\3CX Phone System\Bin\webapi\mp3

  • Create a folder for log files as shown.
    C:\3CXlogs\

important:

Don't forget to grant write permissions to the MP3 and Log folders!

 

2. Installation of .NET SDK 6.0


Go to the following address to download and install the SDK package suitable for your operating system:

.NET SDK 6.0

Note:

Do not proceed to the next steps until the installation of .NET SDK 6.0 is complete.

3. Editing the Settings.ini File 


  • Open the "Settings.ini" file located in the following directory.

    Directory

    C:\Program Files\3CX Phone System\Bin\webapi\Settings.ini

     

  • Replace the value of the "LICENSE_KEY" parameter below with the license key provided to you.

  • Settings.ini
    LICENSE_KEY=AAAA-AAAA-AAAA-AAAA

 

  • If you want to use WebHooks, you should set the "WEBHOOK_POST_ENABLED" setting under the WebHook section in this file to true. Just below it, you will find the "WEBHOOK_URL" field. You should write the URL address to which you want to send data from your PBX in this field. At the end of the process, the "webhooks" section within the file should look like the following.
Settings.ini
WEBHOOK_POST_ENABLED = true
WEBHOOK_URL = https://your-endpointto-post-data

 

4. Editing AccessKeys.csv File


Directory

C:\Program Files\3CX Phone System\Bin\webapi\AccessKeys.csv

The "key" field within this file will be the access key you will use to access the APIs. Create an access key. After entering the email address and name information for this access key, the last section will be the permission field. In this field, you can configure which API endpoints you want to access with this key:

All: Grants access to all (SET, GET and CallControl) APIs.

Get: Grants access to APIs with names starting with "GET" as mentioned in the Postman documentation.

Set: Grants access to APIs with names starting with "SET" and "GET" as mentioned in the Postman documentation.

 

Important:

By default, all customers who install WebAPI will have an access key in the AccessKeys.csv file. We recommend either deleting or changing this key.

 

After completing the editing process, save and close the file.

 

 

5. Installation of WebApi Service


  1. Run Command Prompt as an administrator and type and execute the following command:

    CMD

    sc create webapi binpath= "\"C:\Program Files\3CX Phone System\Bin\webapi\WebhooksApi.exe\" --urls=http://127.0.0.1:8081" displayname= "3CX WebAPI" start= auto obj= "NT AUTHORITY\LocalService"

  2. After executing the command, you should see the message CreateService SUCCESS  

 

  • To start the service: sc start webapi

  • To stop the service: sc stop webapi

  • To remove the service: sc delete webapi

 

6. Editing the nginx.conf File


  • Access the nginx.conf file from the file path below..

    Directory

    C:\Program Files\3CX Phone System\Bin\nginx\conf\nginx.conf

     

    Not:

    You must have administrator rights for your changes to the nginx.conf file to take effect.

  • Open "nginx.conf" and find the following field:

    nginx.conf

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

  • Add the following field under the field you found:

    nginx.conf
    location ~ ^/webapi/?(.*) 
    {
    include "shared-headers.conf";
    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;
    }
  • After completing these steps, you must restart the 3CX Phone System Nginx Webserver service. If you want to perform this operation from the command prompt screen, you can use the following commands:

    • To Stop: sc stop nginx

    • To Start: sc start nginx

 

7. Testing webapi


After the installation is successfully completed, you can test the webapi service with the access key you created in step 4. You can perform these tests through a web browser or by using Postman.

An example API endpoint is as follows: https://{{3CXFQDN}}:{{3CXHTTPSPORT}}/webapi/{{AccessKey}}/pbx.callsinfo

Enter your 3CX server's FQDN address into the "3CXFQDN" field, enter the access key you created into the "AccessKey" field and enter the 3CX https port to "3CXHTTPSPORT" field.

Unless changed during the installation, the default HTTPS port for 3CX is 5001.

You can access the documentation on how APIs are used here.