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

Configuration:

Under Settings, CRM Settings:

Under Settings, CRM API Settings:

In your CRM API Settings page copy your API Token. This will be passed in the http headers. 

curl -H "Token: deea523f59d507ca7a592320f92faf0132b777b85f032a016c016b124ce6d4c5" http://PBXURL/admin/api/sangomacrm/rest/calls/list


$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

{  
   "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 calll 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.tool

GET /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.12 |  python -m json.tool

GET /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.tool

Users

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.tool

GET /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.tool

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:

curl -X GET \
  -s \
  -H "Token: bda54107c89ae96e1daa821fa163149cd1cdbd9d2eb077398e2efa1e9c4489f8" \
  -H "Content-Type: application/json" \
  http://localhost/admin/api/sangomacrm/rest/webhooks/both |  python -m json.tool

POST /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.tool

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:

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.tool

DELETE /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