The majority of the CRM data is available via our API. Below you can see a list with data you can access.
The API is build to be intuitive and works with POST, GET, PUT and DELETE.
Location of API:
https://api.salesdesk.net/v1
The API is accessed via SSL
The API is accessed with an API key generated from your account.
An example of that could be:
https://api.salesdesk.net/v1/get/companies?key=API_KEY
Basically the API can be used for creating, updating, getting and deleting almost everything in the CRM. To a great extend the API is what we use to create the CRM. That way we ensure the consistency of the CRM's data accessability.
Let's get started with some API examples.
https://api.salesdesk.net/v1/get/companies?key=API_KEY
To get other lists just replace "get/companies" with one of the following.
/get/contacts
/get/deals
/get/invoices
/get/users
Single records can be accessed by any of the above with the id
of the record. The API will automatically find the record if it exist.
https://api.salesdesk.net/v1/get/{id}?key=API_KEY
By default the API returns data in JSON format. But the data is also available in XML. Below is an example of how to get XML encoded data.
https://api.salesdesk.net/v1/get/contacts/xml?key=API_KEY
Below is an example of how you can make a request to our API. The example class returns the API response as an array.
// Class to make request to salesdesk API class salesdeskClient { private $api_key; public function __construct($api_key) { $this->api_key = $api_key; } public function request($method, $url, $output = 'json', $body = null) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://api.salesdesk.net/v1/'.$method.'/'.$url.'/'.$output.'?key='.$this->api_key); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); if ($body) { curl_setopt($ch, CURLOPT_POSTFIELDS ,$body); } $result = curl_exec($ch); return $body = json_decode($result, true); } }
https://api.salesdesk.net/v1/get/companies?key=API_KEY
{ "companies": [ { "id": "123456", "sd_company_name": "All for the garden Corp.", ... }, { "id": "123457", "sd_company_name": "Electronic store", ... }, ... }
The output will only contain detailed data from each company and not related data such as invoices, deals or contacts. To get info about relations you will need to request each list item (company ID) indivually. See below.
https://api.salesdesk.net/v1/get/123456?key=API_KEY
{ "data": [ { "id": "123456", "owners": [ { "id": "123457", "email": "unreal@salesdesk.net", "sd_user_name": "Mike B. Jason", ... } ], "relations": [ { "contacts": [ { "id": "123458" ... }, ... ] }, { "deals": [ { "id": "123459", ... }, ... ] }, { "invoices": [ { "id": "123460", ... }, ... ] } ], "sd_company_name": "All for the garden Corp.", "sd_company_domain_name": "www.allforthegardencorp.com", ... } ] }
The single data output will only return the entire data inventory for list item requested and not it's relations and owners. To get full data from these you will have to request them directly. Their direct paths are given in "api_url".
$client = new salesdeskClient('API_KEY'); //Create a new record (we will create a company in this example) $result = $client->request("POST", "companies", 'json', array( 'sd_company_name' => 'New company', 'sd_company_city' => 'New York City' )); // Id of created company $companyId = $result['id'];
Output (json)
{ "id": [ { "123456" } }
$client = new salesdeskClient('API_KEY'); // Unique id from CRM $recordId = '123456'; // Update record $result = $client->request("PUT", $recordId, 'json', array( 'sd_company_name' => 'New company name', 'sd_company_city' => 'New city', ));
Output (json)
{ "status": [ { "Success" } }
$client = new salesdeskClient('API_KEY'); // Unique id from CRM $recordId = '123456'; // Update record $result = $client->request("DELETE", $recordId);
Output (json)
{ "status": [ { "Success" } }
Whenever an error occurs in a request the error message will be returned as a result of the request. Any error will prevent any part of your request from being completed until the error is resolved.
Output (json)
{ "error": [ { "Error message" } }
The amount of records listed at once is limited to 1000. If the list contains more than 1000 records, pagination data will automatically be added to the output.