Sangoma CRM REST API
The Sangoma CRM Rest API Component allows you as an end user to implement the Sangoma CRM module into other implementations that Sangoma does not currently support
- 1 Useful to know:
- 2 Configuration:
- 3 Usage:
- 4 Example output
- 5 API Endpoints
- 5.1 Calls
- 5.1.1 GET /admin/api/sangomacrm/rest/calls/:uuid
- 5.1.2 GET /admin/api/sangomacrm/rest/calls/list/both[/:since][/:limit][/:offset]
- 5.1.3 GET /admin/api/sangomacrm/rest/calls/list/inbound[/:since][/:limit][/:offset]
- 5.1.4 GET /admin/api/sangomacrm/rest/calls/list/outbound[/:since][/:limit][/:offset]
- 5.1.5 GET /admin/api/sangomacrm/rest/calls/recording/:uuid
- 5.1.6 GET /admin/api/sangomacrm/rest/calls/voicemail/:uuid
- 5.2 Users
- 5.3 Webhooks
- 5.1 Calls
Useful to know:
Sangoma CRM REST API can only use the token option for authentication requests: no authorization API is implemented.
External systems must send their requests to the same port configured for the Web GUI Admin under System Admin - Port Management. The correct link will be shown on the CRM API Settings page.
Configuration:
From the Modules menu, choose CRM Settings under Settings category:
Under Settings, CRM API Settings:
Usage:
In your CRM API Settings page:
RestAPI Base URL will tell you the URL where to send your API requests;
API Token. This will be passed in the http headers of the generated Request.
Example code using cURL
Example
curl -H "Token: deea523f59d507ca7a592320f92faf0132b777b85f032a016c016b124ce6d4c5" http://PBXURL/admin/api/sangomacrm/rest/calls/list |
Example 2 code using PHP
Example 2
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://PBXURL/admin/api/sangomacrm/rest/calls/list");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$headers = array(
'Token: deea523f59d507ca7a592320f92faf0132b777b85f032a016c016b124ce6d4c5'
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
echo $output ; |
Example output
Request
Example
curl -H "Token: deea523f59d507ca7a592320f92faf0132b777b85f032a016c016b124ce6d4c5" http://PBXURL/admin/api/sangomacrm/rest/users/extension/1000 |
Response
GET /users/extension/1000
API Endpoints
Calls
GET /admin/api/sangomacrm/rest/calls/:uuid
Description:
Gets a specific call by Asterisk's Channel UniqueID
Parameters:
uuid - The call id to grab.
Example:
GET /admin/api/sangomacrm/rest/calls/list/both[/:since][/:limit][/:offset]
Description:
Gets a list of calls.
Parameters:
since - Calls after unix timestamp in UTC (optional unless setting limit)
limit - The number of records to return. Default 999. (optional unless setting offset)
offset - Starting record. example if your last api call was limit 20 you can set this to 20 to get 21-40 (optional)
Example:
GET /admin/api/sangomacrm/rest/calls/list/inbound[/:since][/:limit][/:offset]
Description:
Gets a list of inbound calls.
Parameters:
See /sangomacrm/calls
Example:
GET /admin/api/sangomacrm/rest/calls/list/outbound[/:since][/:limit][/:offset]
Description:
Gets a list of outbound calls.
Parameters:
See /sangomacrm/calls
Example:
GET /admin/api/sangomacrm/rest/calls/recording/:uuid
Description:
Get octet stream by Asterisk's Channel UniqueID
Parameters:
uuid - call uuid.
Example:
you may want to use the curl -o options to store the fetched octet stream into a local file in your current directory
GET /admin/api/sangomacrm/rest/calls/voicemail/:uuid
Description:
Get octet stream by Asterisk's Channel UniqueID
Parameters:
uuid - call uuid.
Example:
Users
GET /admin/api/sangomacrm/rest/users/extension/:extension
Description:
Gets user by extension
Parameters:
extension: the users extension
Example:
GET /admin/api/sangomacrm/rest/users/id/:id
Description:
Gets a user by their userman id.
Parameters:
id: Userman id.
Example:
Webhooks
GET /admin/api/sangomacrm/rest/webhooks/:[inbound|outbound|id]
Description:
Get webhooks by type or id. If you don't pass a direction or all will be returned.
Example:
POST /admin/api/sangomacrm/rest/webhooks/
Description:
Add a webhook
Parameters:
url: required. The url to post to.
direction: inbound, outbound or both
Example:
PATCH /admin/api/sangomacrm/rest/webhooks/:id
Description:
Update a webhook
Parameters:
url: required. The url to post to.
direction: inbound, outbound or both
Example:
DELETE /admin/api/sangomacrm/rest/webhooks/:id
Description:
Delete webhook
Example: