PBX GUI - Sangoma CRM REST API
Table of Contents
- 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
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
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/listExample 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/1000Response
GET /users/extension/1000
{
"id":"1",
"auth":"freepbx",
"authid":null,
"username":"1000",
"description":"Autogenerated user on new device creation",
"password":"Hidden",
"default_extension":"1000",
"primary_group":null,
"permissions":null,
"fname":"John",
"lname":"Smith",
"displayname":"John Smith",
"title":"Sales Manager",
"company":"Acme",
"department":"Sales",
"email":"jsmith@acme.com",
"cell":"6025551212",
"work":"6025551213",
"home":"6025551214",
"fax":"6025551215"
}
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:
curl -X GET \
-s \
-H "Token: bda54107c89ae96e1daa821fa163149cd1cdbd9d2eb077398e2efa1e9c4489f8" \
-H "Content-Type: application/json" \
http://localhost//admin/api/sangomacrm/rest/calls/1551929887.12 | python -m json.tool
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:
curl -X GET \
-s \
-H "Token: bda54107c89ae96e1daa821fa163149cd1cdbd9d2eb077398e2efa1e9c4489f8" \
-H "Content-Type: application/json" \
http://localhost//admin/api/sangomacrm/rest/calls/list/both | python -m json.toolGET /admin/api/sangomacrm/rest/calls/list/inbound[/:since][/:limit][/:offset]
Description:
Gets a list of inbound calls.
Parameters:
See /sangomacrm/calls
Example:
curl -X GET \
-s \
-H "Token: bda54107c89ae96e1daa821fa163149cd1cdbd9d2eb077398e2efa1e9c4489f8" \
-H "Content-Type: application/json" \
http://localhost//admin/api/sangomacrm/rest/calls/list/inbound | python -m json.tool
GET /admin/api/sangomacrm/rest/calls/list/outbound[/:since][/:limit][/:offset]
Description:
Gets a list of outbound calls.
Parameters:
See /sangomacrm/calls
Example:
curl -X GET \
-s \
-H "Token: bda54107c89ae96e1daa821fa163149cd1cdbd9d2eb077398e2efa1e9c4489f8" \
-H "Content-Type: application/json" \
http://localhost//admin/api/sangomacrm/rest/calls/list/outbound | python -m json.tool
GET /admin/api/sangomacrm/rest/calls/recording/:uuid
Description:
Get octet stream by Asterisk's Channel UniqueID
Parameters:
uuid - call uuid.
Example:
curl -X GET \
-s \
-H "Token: bda54107c89ae96e1daa821fa163149cd1cdbd9d2eb077398e2efa1e9c4489f8" \
http://localhost//admin/api/sangomacrm/rest/calls/recording/1551929887.12you may want to use the curl -o options to store the fetched octet stream into a local file in your current directory
curl -X GET \
-s \
-H "Token: bda54107c89ae96e1daa821fa163149cd1cdbd9d2eb077398e2efa1e9c4489f8" \
-o 1551929887.12.wav \
http://localhost//admin/api/sangomacrm/rest/calls/recording/1551929887.12GET /admin/api/sangomacrm/rest/calls/voicemail/:uuid
Description:
Get octet stream by Asterisk's Channel UniqueID
Parameters:
uuid - call uuid.
Example:
curl -X GET \
-s \
-H "Token: bda54107c89ae96e1daa821fa163149cd1cdbd9d2eb077398e2efa1e9c4489f8" \
http://localhost//admin/api/sangomacrm/rest/calls/voicemail/1551929887.12 | python -m json.toolUsers
GET /admin/api/sangomacrm/rest/users/extension/:extension
Description:
Gets user by extension
Parameters:
extension: the users extension
Example:
curl -X GET \
-s \
-H "Token: bda54107c89ae96e1daa821fa163149cd1cdbd9d2eb077398e2efa1e9c4489f8" \
-H "Content-Type: application/json" \
http://localhost//admin/api/sangomacrm/rest/users/extension/1000 | python -m json.toolGET /admin/api/sangomacrm/rest/users/id/:id
Description:
Gets a user by their userman id.
Parameters:
id: Userman id.
Example:
curl -X GET \
-s \
-H "Token: bda54107c89ae96e1daa821fa163149cd1cdbd9d2eb077398e2efa1e9c4489f8" \
-H "Content-Type: application/json" \
http://localhost//admin/api/sangomacrm/rest/users/id/1 | python -m json.toolWebhooks
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:
curl -X GET \
-s \
-H "Token: bda54107c89ae96e1daa821fa163149cd1cdbd9d2eb077398e2efa1e9c4489f8" \
-H "Content-Type: application/json" \
http://localhost/admin/api/sangomacrm/rest/webhooks/both | python -m json.toolPOST /admin/api/sangomacrm/rest/webhooks/
Description:
Add a webhook
Parameters:
url: required. The url to post to.
direction: inbound, outbound or both
Example:
curl -X POST \
-s \
-H "Token: bda54107c89ae96e1daa821fa163149cd1cdbd9d2eb077398e2efa1e9c4489f8" \
-H "Content-Type: application/json" \
-d '{"url":"http://postb.in/<postbin_code>","direction":"both"}' \
http://localhost/admin/api/sangomacrm/rest/webhooks | python -m json.toolPATCH /admin/api/sangomacrm/rest/webhooks/:id
Description:
Update a webhook
Parameters:
url: required. The url to post to.
direction: inbound, outbound or both
Example:
curl -X PATCH \
-s \
-H "Token: bda54107c89ae96e1daa821fa163149cd1cdbd9d2eb077398e2efa1e9c4489f8" \
-H "Content-Type: application/json" \
-d '{"url":"http://postb.in/newurl","direction":"both"}' \
http://localhost/admin/api/sangomacrm/rest/webhooks/1 | python -m json.toolDELETE /admin/api/sangomacrm/rest/webhooks/:id
Description:
Delete webhook
Example:
curl -X DELETE \
-s \
-H "Token: bda54107c89ae96e1daa821fa163149cd1cdbd9d2eb077398e2efa1e9c4489f8" \
-H "Content-Type: application/json" \
http://localhost/admin/api/sangomacrm/rest/webhooks/2 | python -m json.tool
Return to Documentation Home | Sangoma Support