Brekeke PBX Wiki

8. How to call PAL methods via REST API

Assumptions:

Initial Setup of Brekeke PAL is completed.

– Except on the login method, all parameters and returns used on the methods are same as the JSON RPC on the PAL WebSocket.

POST request method is always used on PAL REST API.

 

Syntax:
http(s)://<host>:<port>/pbx/api/pal/<method name>

 

 

Authentication:

Call login method to obtain the token at first. Then on subsequent methods, set the obtained token in the Authorization headers as follows;

Authorization: basic <token>

Note: On Brekeke PBX version 3.14.7.4 or later, as another option,  system supports the API key. Using API key, the procedure obtaining a token with the login method is not needed.

 

login method:
Parameters
Parameter Explanation
tenant Tenant name
login_user PBX user
login_password Login password
Return
token Token that will be used for calling subsequent methods

 

Using API Key: (Available on Brekeke PBX version 3.14.7.4 or later)

Step 1. Set the following properties into the [SIP SERVER] > [Configuration] > [Advanced].

Syntax:

apikey.<n>=<api key>
apikey.<n>.scope=pal
apikey.<n>.tenant=<tenant>apikey.<n>.user=<user>

Example:

apikey.1=asldjfjlsd
apikey.1.scope=pal
apikey.1.tenant=mytenantapikey.1.user=1002

In this example, the api key “asldjfjlsd” will be used as token for authentication.

 


Test 1. Login test with Postman.

Step 1. Open Postman. Then Create a POST request.

  • Enter appropriate URL of your PBX’s PAL.
  • Open the [Headers] tab and set “Content-Type” as “application/json“.

 

Step 2. Open the [Body] tab and select “JSON“. Then add parameters and values with JSON format.

Click [Send] button.

 

Step 3. If  the 200 OK response is receved and a token is obtained like the picture, the connection is succeeded.

 

 

 

Test 2. Test with a sample script.

Refer to the “PAL REST API – Sample program 1”>>

 

 

Yes No
Suggest Edit