Introduction
What can this API do for you?
SarvCRM API is designed as a REST/SOAP API for multiple clients: web (the web app, used on computers), iOS, and Android. A client is a program that will consume our API, that will use its endpoints and returned data.
You can do pretty much anything our web client can.
This will be most useful to:
Integrate SarvCRM capabilities into your own website, mobile application, portal and etc. with your own layout and your own way of managing rights
How do I access the SarvCRM API?
The REST service in SarvCRM can be found by navigating to:
http://app.sarvcrm.com/service2/{version}/rest.php?utype=TEST
The SOAP service in SarvCRM can be found by navigating to:
http://app.sarvcrm.com/service2/{version}/soap.php?utype=TEST
Versioning
Languages
SarvCRM differentiates languages with unique language keys.
The following table displays the list of current languages and their corresponding keys:
Language | Language key |
---|---|
Persian (فارسی) | fa_IR |
English (US) | en_US |
Module List
Below you will find a list of all the modules that the SarvCRM provides.
Module Key | Persian Label | English Label |
---|---|---|
Accounts | حساب ها | Accounts |
AOS_Contracts | قراردادهای فروش | Sales Contract |
AOS_Invoices | فاکتورها | Invoices |
AOS_PDF_Templates | قالب های PDF | PDF Templates |
AOS_Product_Categories | دسته های محصول | Product Categories |
AOS_Products | محصولات | Products |
AOS_Quotes | پیش فاکتورها | Quotes |
Appointments | بازدیدها | Appointments |
Approval | تاییدیه | Approval |
asol_Project | پروژه | Project |
Branches | شعب | Branches |
Bugs | پیگیری ایرادهای محصول | Bug Tracker |
Calls | تماس ها | Calls |
Cases | سرویس ها | Cases |
Communications | ارتباطات | Communications |
Communications_Target | هدف ارتباطات | Communications Target |
Communications_Template | قالب ارتباطات | Communications Template |
Campaigns | کمپین ها | Campaigns |
Contacts | افراد | Contacts |
Deposits | ودیعه | Deposits |
Documents | اسناد | Documents |
Emails | ایمیل ها | Emails |
Knowledge_Base | پایگاه دانش | Knowledge Base |
Knowledge_Base_Categories | دسته پایگاه دانش | Knowledge Base Categories |
Leads | سرنخ | Leads |
Meetings | جلسات | Meetings |
Notes | یادداشت ها | Notes |
OBJ_Conditions | شرایط شاخص | Conditions |
OBJ_Indicators | شاخص | Indicators |
OBJ_Objectives | اهداف | Objectives |
Opportunities | فرصت ها | Opportunities |
Payments | پرداخت ها | Payments |
Purchase_Order | سفارش خرید | Purchase Order |
sc_competitor | رقبا | Competitor |
sc_Contract | قراردادهای پشتیبانی | Support Contracts |
sc_contract_management | خدمات | Services |
Service_Centers | مراکز سرویس | Service Centers |
Tasks | وظایف | Tasks |
Timesheet | تایم شیت | Timesheet |
Vendors | تامین کنندگان | Vendors |
Data Types
Input / Output Data Types
The default input / output datatype for REST is JSON.
Date Handling
Date and date time inputs should be formatted following the ISO 8601 format.
There are generally 3 types of date or time output formats :
Type | Format |
---|---|
Date | "2018-04-22" |
Datetime | "2018-04-22T14:40:00+03:30" |
Time | "14:40:00" |
Request
The default input / output datatype for REST is JSON.
We accept these values of Content-Type header when using POST methods:
- application/json
- multipart/form-data
- application/x-www-form-urlencoded
HTTP Methods
verb | Description |
---|---|
GET | Obtain information. Query path parameters are allowed. |
POST | Add new information or obtain existing information. Body is allowed. |
Response
API response is JSON formatted and it has Content-Type: application/json header.
Response Status
Code | name | Meaning |
---|---|---|
200 | OK | The request execution has been succeeded. |
400 | Request Error | The request execution has been encountered an error. The appropriate error code will be returned in response message. See the error types |
401 | Unauthorized | The request requires user authentication. See the error types |
403 | Forbidden | The server understood the request, but is refusing to fulfill it. See the error types |
404 | Not Found | The server has not found anything matching the Request-URI. See the error types |
500 | Internal Server Error | The server encountered an unexpected condition which prevented it from fulfilling the request. |
Errors
{
"server_response_status":401,
"name":"Invalid Login",
"number":"10",
"description":"Login attempt failed please check the username and password"
}
The SarvCRM API uses the following error codes:
HTTP Status Code | Code | name | Meaning |
---|---|---|---|
401 | 10 | Invalid login | Login attempt failed please check the username and password. |
401 | 11 | Invalid Session ID | The session ID is invalid. |
401 | 12 | User Not Configured | Please log into your instance of SarvCRM to configure your user. |
400 | 12 | Invalid Portal Client | Portal Client does not have authorized access. |
400 | 14 | Required Fields | Please fill out the required fields and try again. |
400 | 15 | Type Mismatch | Type mismatch Error. |
400 | 16 | File is Too Large | Uploaded file is too large and exceeded the file size limit. |
404 | 20 | Module Does Not Exist | This module is not available on this server. |
404 | 21 | File Does Not Exist | The desired file does not exist on the server. |
400 | 22 | Deleted Record | Access to this object is denied since it has been deleted or does not exist. |
400 | 30 | Module Not Supported | This module does not support this feature. |
400 | 31 | Relationship Not Supported | This module does not support this relationship. |
403 | 40 | Access Denied | You do not have access. |
400 | 50 | Duplicate Records | Duplicate records have been found. Please be more specific. |
404 | 51 | No Records | No records were found. |
401 | 60 | Sessions Exceeded | Number of sessions exceeded. |
401 | 70 | Admin credentials are required | The logged-in user is not an administrator. |
400 | 90 | Resource Management Error | The resource query limit specified in config.php has been exceeded during execution of the SOAP method. |
400 | 1000 | Invalid call for this module | This is an invalid call for this module. Please look at WSDL file for details. |
400 | 1001 | Invalid data sent | The data sent for this function is invalid. Please look at WSDL file for details. |
400 | 1005 | Invalid set_campaign_merge data | set_campaign_merge: Merge action status will not be updated, because, campaign_id is null or no targets were selected. |
401 | 1008 | Password Expired | Your password has expired. Please provide a new password. |
401 | 1009 | lockout reached | You have been locked out of the SarvCRM application and cannot log in using existing password. Please contact your Administrator. |
Authentication
login
$login_parameters = array(
"user_auth" => array(
"user_name" => $username,
"password" => md5($password),
),
"name_value_list" => array(
"language" => array(
"name" => "language",
"value" => "fa_IR"
),
"meta_data" => true,
),
);
$result = call("login", $login_parameters, $url);
var dataToSend = {
"method" : "login",
"input_type" : "JSON",
"response_type" : "JSON"
};
var restData = {
user_auth : {
user_name : "DemoUser",
password : "b57014dd3a80639cc4390294a0218401"
},
application : "TEST",
name_value_list : {
"name" : "language",
"value" : "fa_IR"
}
"meta_data":true,
};
"input_type":"JSON",
"response_type":"JSON",
"method":"login",
"rest_data":
{
"user_auth":{
"user_name":"DemoUser",
"password":"b57014dd3a80639cc4390294a0218401",
},
"utype":"TEST",
"name_value_list":
{
"language":
{
"name":"language",
"value":"fa_IR"
}
}
"meta_data":true,
}
# if "meta_data" has not been set or has been set with true value
{
"server_response_status":200,
"id":"gjfhkshmelq4kduhqopdj2qev2",
"module_name":"Users",
"name_value_list":
{
"user_id":
{
"name":"user_id",
"value":"11132136-d009-9d59-12d7-575502d6cda3"
},
"user_name":
{
"name":"user_name",
"value":"DemoUser"
},
"user_language":
{
"name":"user_language",
"value":"en_US"
},
"user_currency_id":
{
"name":"user_currency_id",
"value":"-99"
},
"user_currency_name":
{
"name":"user_currency_name",
"value":"Rials"
}
}
}
if "meta_data" has been set with false value
{
"server_response_status":200,
"id": "gjfhkshmelq4kduhqopdj2qev2",
"module_name": "Users",
"name_value_list": {
"user_id": "11132136-d009-9d59-12d7-575502d6cda3",
"user_name": "DemoUser",
"user_language": "en_US",
"user_currency_id": "-99",
"user_currency_name": "Rials"
}
}
Logs a user into the SarvCRM application and get session id
Parameters
-
user_auth | Array
Set user_name and password (password needs to be in the right encoding for the type of authentication the user is setup for. For Base SarvCRM validation, password is the MD5 sum of the plain text password) and utype (Account name).
-
name_value_list | Array
Array of name value pair of extra parameters. As of today only 'language' and 'notifyonsave' is supported
-
meta_data | Boolean
Values: true, false [The default value is true, even if this parameter was not set]
true, the response will include metadata
flase, the response will not include metadata
Returns
-
server_response_status | integer
The status read-only property of the Response interface contains the status code of the response (e.g., 200 for a success).
-
id | id
String id is the session_id of the session that was created.
-
module_name | String
module name of user
-
name_value_list | array
The name value pair of user_id, user_name, user_language, user_currency_id, user_currency_name
logout
$logout_parameters = array(
"session" => $session_id,
);
$result = call("logout", $logout_parameters, $url);
var dataToSend = {
"method" : "logout",
"input_type" : "JSON",
"response_type" : "JSON"
};
var restData = {
session : "63nmk21qbon2do9j0chtihu414",
};
"input_type":"JSON",
"response_type":"JSON",
"method":"logout",
"rest_data":
{
"session":"63nmk21qbon2do9j0chtihu414"
}
NULL
Logs a user out of the SarvCRM application.
Parameters
-
session | String
Session ID returned by a previous call to login
Returns
-
server_response_status | integer
The status read-only property of the Response interface contains the status code of the response (e.g., 200 for a success).
-
NULL | void
No return value.
Get Methods
get_entry
$get_entry_parameters = array(
"session" => $session_id,
"module_name" => "Contacts",
"id" => "18df70e4-1422-8bff-6f5f-50aa571fe4e5",
"select_fields" => array(
"id",
"salutation",
"first_name",
"last_name",
"primary_number_raw",
"numbers",
),
"meta_data" => true,
);
$result = call("get_entry", $get_entry_parameters, $url);
var dataToSend = {
"method" : "get_entry",
"input_type" : "JSON",
"response_type" : "JSON"
};
var restData = {
"session":"tt1d4nouksbcubb6mnps0p9752",
"module_name":"Contacts",
"id":"3996386c-d5e3-f92d-5fc7-585118769e3e",
"select_fields":{"id","salutation","first_name","last_name","primary_number_raw","numbers"},
"meta_data":true,
};
"input_type":"JSON",
"response_type":"JSON",
"method":"get_entry",
"rest_data":
{
"session":"63nmk21qbon2do9j4fhtihu414",
"module_name":"Contacts",
"id":"3996386c-d5e3-f92d-5fc7-585118769e3e",
"select_fields" : ["id","salutation","first_name","last_name","primary_number_raw","numbers"]
"meta_data":true,
}
# if "meta_data" has not been set or has been set with true value
{
"server_response_status":200,
"entry_list":
[{
"id":"61e6fcb2-29ae-1694-f815-58f45a907d87",
"module_name":"Contacts",
"name_value_list":{
"id":
{
"name":"id",
"value":"61e6fcb2-29ae-1694-f815-58f45a907d87"
},
"salutation":
{
"name":"salutation",
"value":"Mr."
},
"first_name":
{
"name":"first_name",
"value":"John"
},
"last_name":
{
"name":"last_name",
"value":"Doe"
},
{
"name":"primary_number_raw",
"value":"+989121000000"
},
{
"name":"numbers",
"value": [{
"number": "1255555555",
"extension": "22",
"type": "Fax",
"country_code": "+98",
"country_flag": "IR",
"primary_number": "0",
"fax_number": "1",
"sms_number": "0"
},
{
"number": "2144226268",
"extension": "22",
"type": "Fax",
"country_code": "+98",
"country_flag": "IR",
"primary_number": "0",
"fax_number": "0",
"sms_number": "1"
}]
}
}
}],
"relationship_list":[]
}
if "meta_data" has been set with false value
{
"server_response_status":200,
"entry_list": [{
"id": "61e6fcb2-29ae-1694-f815-58f45a907d87",
"salutation": "Mr.",
"first_name": "John",
"last_name": "Doe"
"primary_number_raw": "+982144100000",
"numbers": [{
"number": "1255555555",
"extension": "22",
"type": "Fax",
"country_code": "+98",
"country_flag": "IR",
"primary_number": "0",
"fax_number": "1",
"sms_number": "0"
},
{
"number": "2144226268",
"extension": "22",
"type": "Fax",
"country_code": "+98",
"country_flag": "IR",
"primary_number": "0",
"fax_number": "0",
"sms_number": "1"
}]
}],
"relationship_list": []
}
Retrieve a single Record based on ID.
Parameters
-
session | String
Session ID returned by a previous call to login
-
module_name | String
The name of the module to return records from. This name should be the name the module was developed under (changing a tab name is studio does not affect the name that should be passed into this method).
-
id | String
The record's ID value.
-
select_fields | Array
A list of the fields to be included in the results. This optional parameter allows for only needed fields to be retrieved.
-
link_name_to_fields_array | Array
A list of link_names and for each link_name, what fields value to be returned.
-
meta_data | Boolean
Values: true, false [The default value is true, even if this parameter was not set]
true, the response will include metadata
flase, the response will not include metadata
Returns
-
server_response_status | integer
The status read-only property of the Response interface contains the status code of the response (e.g., 200 for a success).
-
entry_list | Array
The records name value pair for the simple data types excluding link field data.
-
relationship_list | Array
The records link field data.
get_entry_list
$get_entry_list_parameters = array(
"session" => $session_id,
"module_name" => "Leads",
"query" => "",
"order_by" => "",
"offset" => 0,
"select_fields" => array(
"id",
"name",
"title",
),
"max_results" => 5,
"deleted" => 0,
"favorites" => false,
"meta_data" => true,
);
$result = call("get_entry_list", $get_entry_list_parameters, $url);
var dataToSend = {
"method" : "get_entry_list",
"input_type" : "JSON",
"response_type" : "JSON"
};
var restData = {
"session":"tt1d4nouksbcubb6mnps0p9752",
"module_name":"Leads",
"query":"",
"order_by":"title asc",
"offset": 0,
"select_fields":{"id","salutation","first_name","last_name"},
"max_results": 5,
"deleted": 0,
"favorites": false,
"meta_data":true,
};
"input_type":"JSON",
"response_type":"JSON",
"method":"get_entry_list",
"rest_data":
{
"session":"tt1d4nouksbcubb6mnps0p9752",
"module_name":"Leads",
"query":"",
"order_by":"title asc",
"offset":0,
"select_fields":["id","salutation","first_name","last_name"],
"max_results":5,
"deleted":0,
"favorites":false
"meta_data":true,
}
# if "meta_data" has not been set or has been set with true value
{
"server_response_status":200,
"result_count": 2,
"total_count": "177",
"next_offset": 2,
"entry_list": [{
"id": "10b60ebc-9d2f-bba9-398b-52bedcbb5283",
"module_name": "Leads",
"name_value_list": {
"id": {
"name": "id",
"value": "10b60ebc-9d2f-bba9-398b-52bedcbb5283"
},
"salutation": {
"name": "salutation",
"value": "Ms.",
"options": {
"_empty_": "",
"Mr.": "Mr.",
"Ms.": "Ms.",
"Eng.": "Eng.",
"Dr.": "Dr.",
"Prof.": "Prof.",
"Mr.Dr.": "Mr. Dr.",
"Ms.Dr.": "Ms. Dr.",
"Mr.Eng.": "Mr. Eng.",
"Ms.Eng.": "Ms. Eng."
}
}
}
}, {
"id": "184d0f35-c871-eb11-c409-55583b07bbd7",
"module_name": "Leads",
"name_value_list": {
"id": {
"name": "id",
"value": "184d0f35-c871-eb11-c409-55583b07bbd7"
},
"salutation": {
"name": "salutation",
"value": "Mr.",
"options": {
"_empty_": "",
"Mr.": "Mr.",
"Ms.": "Ms.",
"Eng.": "Eng.",
"Dr.": "Dr.",
"Prof.": "Prof.",
"Mr.Dr.": "Mr. Dr.",
"Ms.Dr.": "Ms. Dr.",
"Mr.Eng.": "Mr. Eng.",
"Ms.Eng.": "Ms. Eng."
}
},
}
}],
"relationship_list": []
}
if "meta_data" has been set with false value
{
"server_response_status":200,
"result_count": 2,
"total_count": "177",
"next_offset": 2,
"entry_list": [{
"id": "10b60ebc-9d2f-bba9-398b-52bedcbb5283",
"salutation": "Ms."
}, {
"id": "184d0f35-c871-eb11-c409-55583b07bbd7",
"salutation": "Mr."
}],
"relationship_list": []
}
Retrieve a list of records. This is the primary method for getting list of records from SarvCRM using the SOAP API.
Parameters
-
session | String
Session ID returned by a previous call to login
-
module_name | String
The name of the module to return records from. This name should be the name the module was developed under (changing a tab name is studio does not affect the name that should be passed into this method).
-
query | String
SQL where clause without the word 'where'
-
order_by | String
SQL order by clause without the phrase 'order by'
-
offset | integer
The record offset to start from.
-
select_fields | Array
A list of the fields to be included in the results. This optional parameter allows for only needed fields to be retrieved.
-
link_name_to_fields_array | Array
A list of link_names and for each link_name, what fields value to be returned.
-
max_results | integer
The maximum number of records to return. The default is the SarvCRM configuration value for 'list_max_entries_per_page'
-
deleted | integer
false if deleted records should not be include, true if deleted records should be included.
-
favorites | Boolean
If only records marked as favorites should be returned.
-
meta_data | Boolean
Values: true, false [The default value is true, even if this parameter was not set]
true, the response will include metadata
flase, the response will not include metadata
Returns
-
server_response_status | integer
The status read-only property of the Response interface contains the status code of the response (e.g., 200 for a success).
-
result_count | integer
The number of records returned.
-
total_count | integer
The total number of records.
-
next_offset | integer
The start of the next page (This will always be the previous offset plus the number of rows returned. It does not indicate if there is additional data unless you calculate that the next_offset happens to be closer than it should be.
-
entry_list | Array
The records that were retrieved.
-
relationship_list | Array
The records link field data.
get_relationships
$get_relationships_parameters = array(
"session" => $session_id,
"module_name" => "Accounts",
"module_id" => "9f0c0ceb-c512-7103-9456-50aa5787c3f6",
"link_field_name" => "opportunities",
"related_module_query" => " opportunities.name IS NOT NULL ",
"related_fields" => array(
"id",
"name"
),
"related_module_link_name_to_fields_array" => "",
"deleted"=> 0,
"order_by" => " opportunities.name ",
"offset" => 0,
"limit" => 200,
"meta_data" => true,
);
$result = call("get_relationships", $get_relationships_parameters, $url);
var dataToSend = {
"method" : "get_relationships",
"input_type" : "JSON",
"response_type" : "JSON"
};
var restData = {
"session":"tt1d4nouksbcubb6mnps0p9752",
"module_name":"Contacts",
"module_id":"3996346c-d0e3-f92d-5fc7-585118759e3e",
"link_field_name":"opportunities",
"related_module_query":"opportunities.name IS NOT NULL",
"related_fields":{"id","name"},
"link_name_to_fields_array":"",
"deleted": false
"offset": 0,
"limit": 200,
"meta_data":true,
};
"input_type":"JSON",
"response_type":"JSON",
"method":"get_relationships",
"rest_data":
{
"session":"tt1d4nouksbcubb6mnps0p9752",
"module_name":"Contacts",
"module_id":"3996346c-d0e3-f92d-5fc7-585118759e3e",
"link_field_name":"opportunities",
"related_module_query":"opportunities.name IS NOT NULL",
"select_fields":["id","name"],
"link_name_to_fields_array":"",
"deleted":0,
"offset":0,
"limit":200
"meta_data":true,
}
# if "meta_data" has not been set or has been set with true value
{
"server_response_status":200,
"entry_list": [{
"id": "1dae5bd3-60e1-b758-55d0-56bf1ac9f56e",
"module_name": "Opportunities",
"name_value_list": {
"id": {
"name": "id",
"value": "1dae5bd3-60e1-b758-55d0-56bf1ac9f56e"
},
"name": {
"name": "name",
"value": "Relation_name1"
}
}
}, {
"id": "3712ae11-9875-a054-5a2a-5993f5e19b5a",
"module_name": "Opportunities",
"name_value_list": {
"id": {
"name": "id",
"value": "3712ae11-9875-a054-5a2a-5993f5e19b5a"
},
"name": {
"name": "name",
"value": "Relation_name2"
}
}
}, {
"id": "8f382277-6e29-0d29-a1f2-594ba379537b",
"module_name": "Opportunities",
"name_value_list": {
"id": {
"name": "id",
"value": "8f382277-6e29-0d29-a1f2-594ba379537b"
},
"name": {
"name": "name",
"value": "Relation_name3"
}
}
}],
"relationship_list": []
}
if "meta_data" has been set with false value
{
"server_response_status":200,
"entry_list": [{
"id": "1dae5bd3-60e1-b758-55d0-56bf1ac9f56e",
"name": "Relation_name1"
}, {
"id": "3712ae11-9875-a054-5a2a-5993f5e19b5a",
"name": "Relation_name2"
}, {
"id": "8f382277-6e29-0d29-a1f2-594ba379537b",
"name": "Relation_name3"
}],
"relationship_list": []
}
Retrieve a collection of Records that are related to the specified record and optionally return relationship data for those related records. So in this API you can get contacts info for an account and also return all those contact's email address or an opportunity info also.
Parameters
-
session | String
Session ID returned by a previous call to login
-
module_name | String
The name of the module to return records from. This name should be the name the module was developed under (changing a tab name is studio does not affect the name that should be passed into this method).
-
module_id | String
The ID of the record in the specified module.
-
link_field_name | String
The name of the lnk field to return records from. This name should be the name the relationship.
-
related_module_query | String
A portion of the where clause of the SQL statement to find the related items. The SQL query will already be filtered to only include the records that are related to the specified record.
-
related_fields | Array
Array of related record fields to be returned.
-
related_module_link_name_to_fields_array | Array
For every related record returned, specify link fields name to fields info for that record to be returned.
-
deleted | integer
false if deleted records should not be include, true if deleted records should be included.
-
order_by | String
The SQL ORDER BY clause without the phrase "order by".
-
offset | integer
The record offset from which to start.
-
limit | integer
The maximum number of results to return.
-
meta_data | Boolean
Values: true, false [The default value is true, even if this parameter was not set]
true, the response will include metadata
flase, the response will not include metadata
Returns
-
server_response_status | integer
The status read-only property of the Response interface contains the status code of the response (e.g., 200 for a success).
-
entry_list | Array
The records that were retrieved.
-
relationship_list | Array
The records link field data.
get_user_id
$get_user_id_parameters = array(
"session" => $session_id,
);
$result = call("get_user_id", $get_user_id_parameters, $url);
var dataToSend = {
"method" : "get_user_id",
"input_type" : "JSON",
"response_type" : "JSON"
};
var restData = {
"session":"tt1d4nouksbcubb6mnps0p9752",
};
"input_type":"JSON",
"response_type":"JSON",
"method":"get_user_id",
"rest_data":
{
"session":"tt1d4nouksbcubb6mnps0p9752"
}
{
"server_response_status":200,
"user_id":"3ffcedbd-db37-72ca-4e92-5a812a7d0426"
}
Return the user_id of the user that is logged into the current session.
Parameters
-
session | String
Session ID returned by a previous call to login
Returns
-
server_response_status | integer
The status read-only property of the Response interface contains the status code of the response (e.g., 200 for a success).
-
user_id | String
the User ID of the current session.
get_module_fields
$get_module_fields_parameters = array(
"session" => $session_id,
"module_name" => "Calls",
"fields" => array(),
);
$result = call("get_module_fields", $get_module_fields_parameters, $url);
var dataToSend = {
"method" : "get_module_fields",
"input_type" : "JSON",
"response_type" : "JSON"
};
var restData = {
"session":"tt1d4nouksbcubb6mnps0p9752",
"module_name":"Calls",
"fields":"",
};
"input_type":"JSON",
"response_type":"JSON",
"method":"get_module_fields",
"rest_data":
{
"session":"lvkkfdif6e7me1oqrq0r40i5t2",
"module_name":"Calls",
"fields":""
}
{
"server_response_status":200,
"module_name":"Calls",
"module_fields":
{
"id":
{
"name":"id",
"type":"id",
"label":"ID:",
"required":0,
"options":[]
},
"name":
{
"name":"name",
"type":"name",
"label":"Subject:",
"required":0,
"options":[]
},
"server_response_status":
{
"name":"accept_status_name",
"type":"enum",
"label":"Accept Status:",
"required":0,
"options":[
"Planned":
{
"name":"Planned",
"value":"Planned"
},
"Not Held":
{
"name":"Not Held",
"value":"Not Held"
},
"Held":
{
"name":"Held",
"value":"Held"
}
]
}
}
}
Retrieve vardef information on the fields of the specified record.
Parameters
-
session | String
Session ID returned by a previous call to login
-
module_name | String
The name of the module to return records from. This name should be the name the module was developed under (changing a tab name is studio does not affect the name that should be passed into this method).
-
fields | Array
Optional, if passed then retrieve vardef information on these fields only.
Returns
-
server_response_status | integer
The status read-only property of the Response interface contains the status code of the response (e.g., 200 for a success).
-
module_fields | Array
The vardef information on the selected fields.
-
link_fields | Array
The vardef information on the link fields.
get_document_revision
$get_document_revision_parameters = array(
"session" => $session_id,
"id" => "da0b107d-cfbc-cb08-4f90-50b7b9cb9ad7",
"select_fields" => array(
"id",
"document_name",
"revision",
"filename",
"file",
),
);
$result = call("get_document_revision", $get_document_revision_parameters, $url);
var dataToSend = {
"method" : "get_document_revision",
"input_type" : "JSON",
"response_type" : "JSON"
};
var restData = {
"session":"tt1d4nouksbcubb6mnps0p9752",
"id":"da0b107d-cfbc-cb08-4f90-50b7b9cb9ad7",
"select_fields":{"id","document_name","revision","filename","file"},
};
"input_type":"JSON",
"response_type":"JSON",
"method":"get_document_revision",
"rest_data":
{
"session":"lvkkfdif6e7me1oqrq0r40i5t2",
"id":"da0b107d-cfbc-cb08-4f90-50b7b9cb9ad7"
"select_fields" : ["id","document_name","revision","filename","file"]
}
{
"server_response_status":200,
"document_revision":
[{
"id":"6310a1d5-1d2b-31a7-9d8d-58bd5559f374",
"document_name":"Web Service Documentation",
"revision":"2",
"filename":"api.pdf",
"file":"JVBERi0xLjQKJeLjz9MKMyAwIG9iago8PC9UeXBlIC9QYWdlCi9QYXJlbnQgMSAwIFIK",
"download_link":"http://app.sarvcrm.com/download/api.pdf"
}]
}
Retrieves a specific document revision.
Parameters
-
session | String
Session ID returned by a previous call to login
-
i | String
The ID of the document revision.
Returns
-
server_response_status | integer
The status read-only property of the Response interface contains the status code of the response (e.g., 200 for a success).
-
document_revision | Array
The details of the document revision.
-
id | String
The document ID.
-
document_name | String
The document name.
-
revision | String
The document revision number.
-
filename | String
The filename of the file.
-
file | String
The binary contents of the file.
-
download_link | String
it only allows logged-in users to download that file. Users who are not logged in are sent to the login page instead to the file download page.
get_note_attachment
$get_note_attachment_parameters = array(
"session" => $session_id,
"id" => "da0b107d-cfbc-cb08-4f90-50b7b9cb9ad7",
);
$result = call("get_note_attachment", $get_note_attachment_parameters, $url);
var dataToSend = {
"method" : "get_note_attachment",
"input_type" : "JSON",
"response_type" : "JSON"
};
var restData = {
"session":"tt1d4nouksbcubb6mnps0p9752",
"id":"da0b107d-cfbc-cb08-4f90-50b7b9cb9ad7",
};
"input_type":"JSON",
"response_type":"JSON",
"method":"get_note_attachment",
"rest_data":
{
"session":"lvkkfdif6e7me1oqrq0r40i5t2",
"id":"da0b107d-cfbc-cb08-4f90-50b7b9cb9ad7"
}
{
"server_response_status":200,
"note_attachment":
[{
"id":"6310a1d5-1d2b-31a7-9d8d-58bd5559f374",
"filename":"test.pdf",
"file":"JVBERi0xLjQKJeLjz9MKMyAwIG9iago8PC9UeXBlIC9QYWdlCi9QYXJlbnQgMSAwIFIK",
"related_module_id":"4fa52h3b-03bb-a821-73a0-5379cb8ead19",
"related_module_name":"Opportunities",
}]
}
Retrieves an attachment associated with a specific note record.
Parameters
-
session | String
Session ID returned by a previous call to login
-
id | String
The ID of the note record to associate the attachment to.
Returns
-
server_response_status | integer
The status read-only property of the Response interface contains the status code of the response (e.g., 200 for a success).
-
note_attachment | Array
The details of the file attachment.
-
id | String
The ID of the note record/attachment.
-
filename | String
The filename of the attachment.
-
file | String
The binary contents of the file.
-
related_module_id | String
The related parent ID.
-
related_module_name | String
The related parent module.
get_last_viewed
$get_last_viewed_parameters = array(
"session" => $session_id,
"module_names" => array(
"Contacts",
"Accounts",
"Calls"
),
);
$result = call("get_last_viewed", $get_last_viewed_parameters, $url);
var dataToSend = {
"method" : "get_last_viewed",
"input_type" : "JSON",
"response_type" : "JSON"
};
var restData = {
"session":"tt1d4nouksbcubb6mnps0p9752",
"module_names":{"Contacts","Accounts","Calls"}
};
"input_type":"JSON",
"response_type":"JSON",
"method":"get_last_viewed",
"rest_data":
{
"session":"lvkkfdif6e7me1oqrq0r40i5t2",
"module_names":["Contacts","Accounts","Calls"]
}
{
"server_response_status":200,
"0":
[{
"item_id":"b6ebb291-780d-d4d0-ccdb-5a7aa47befe5",
"id":"23427",
"item_summary":"test summery 1",
"module_name":"Contacts",
"monitor_id":"4fa52h3b-03bb-a821-73a0-5379cb8ead19",
"date_modified":"2018-01-14 07:02:51",
}],
"1":
[{
"item_id":"1eb07f60-327b-bc95-ddb5-5a38e941f9cc",
"id":"22909",
"item_summary":"test summery 2",
"module_name":"Contacts",
"monitor_id":"c76cb7a2-95af-20b9-2f97-5a38bc9b2e59",
"date_modified":"2017-12-27 08:06:10",
}]
"2":
[{
"item_id":"89b107a3-c5ef-3ae3-a88d-5379cbd31f7b",
"id":"25401",
"item_summary":"test summery 3",
"module_name":"Accounts",
"monitor_id":"9d28545e-eec0-1c73-ea0b-5a378119936e",
"date_modified":"2017-12-19 07:14:08",
}]
}
Retrieves a list of recently viewed records by module for the current user.
Parameters
-
session | String
Session ID returned by a previous call to login
-
module_names | String
The list of modules to retrieve last viewed records for.
Returns
-
server_response_status | integer
The status read-only property of the Response interface contains the status code of the response (e.g., 200 for a success).
-
id | integer
The result ID.
-
item_id | String
The reciently viewed record ID.
-
item_summary | String
The name of the reciently viewed record.
-
module_names | String
The name of the module.
-
monitor_id | String
The monitor ID from the tracker table.
-
date_modified | String
The date the record was viewed.
get_appointment_interval_list
$get_appointment_interval_list = array(
"session" => $session_id,
"query" => "",
"order_by" => "",
"select_fields" => array(),
"max_results" => 5,
"deleted" => 0,
);
$result = call("get_appointment_interval_list", $get_appointment_interval_list, $url);
var dataToSend = {
"method" : "get_appointment_interval_list",
"input_type" : "JSON",
"response_type" : "JSON"
};
var restData = {
"session":"tt1d4nouksbcubb6mnps0p9752",
"query":"",
"order_by":"",
"select_fields":{},
"max_results": 5,
"deleted": 0,
};
"input_type":"JSON",
"response_type":"JSON",
"method":"get_appointment_interval_list",
"rest_data":
{
"session":"tt1d4nouksbcubb6mnps0p9752",
"query":"",
"order_by":"",
"select_fields":[],
"max_results":5,
"deleted":0,
}
{
"server_response_status": "200",
"result_count": 1,
"total_count": 1,
"entry_list": [{
"id": "ada64f54-a488-494e-b740-0b026d6ccdb9",
"name": "Test",
"type": "meeting",
"interval": {
"Saturday": [
"9:00-10:10",
"10:10-11:20",
"16:00-17:10"
],
"Sunday": [
"9:00-10:10",
"10:10-11:20",
"16:00-17:10"
],
"Monday": [
"9:00-10:10",
"10:10-11:20",
"16:00-17:10"
],
"Tuesday": [
"9:00-10:10"
],
"Thursday": [
"9:00-10:10",
"11:20-12:30"
]
},
"unlimit": "1"
}]
}
Retrieves a list of recently viewed records by module for the current user.
Parameters
-
session | String
Session ID returned by a previous call to login
-
query | String
SQL where clause without the word 'where'
-
order_by | String
SQL order by clause without the phrase 'order by'
-
select_fields | Array
A list of the fields to be included in the results. This optional parameter allows for only needed fields to be retrieved.
-
max_results | integer
The maximum number of records to return. The default is the SarvCRM configuration value for 'list_max_entries_per_page'
-
deleted | integer
false if deleted records should not be include, true if deleted records should be included.
Returns
-
server_response_status | integer
The status read-only property of the Response interface contains the status code of the response (e.g., 200 for a success).
-
result_count | integer
The number of records returned.
-
total_count | integer
The total number of records.
-
entry_list | Array
The details that were retrieved.
get_resources_list
$get_resources_list_params = array(
"session" => $session_id,
"query" => "",
"order_by" => "",
"select_fields" => array(),
"max_results" => 5,
"deleted" => 0,
"appointment_id" =>"56df5ead-f617-4ba2-9748-86f395011bfb",
);
$result = call("get_resources_list", $get_resources_list_params, $url);
var dataToSend = {
"method" : "get_resources_list",
"input_type" : "JSON",
"response_type" : "JSON"
};
var restData = {
"session":"tt1d4nouksbcubb6mnps0p9752",
"query":"",
"order_by":"",
"select_fields":{},
"max_results": 5,
"deleted": 0,
"appointment_id":"56df5ead-f617-4ba2-9748-86f395011bfb",
};
"input_type":"JSON",
"response_type":"JSON",
"method":"get_resources_list",
"rest_data":
{
"session":"tt1d4nouksbcubb6mnps0p9752",
"query":"",
"order_by":"",
"select_fields":[],
"max_results":5,
"deleted":0,
"appointment_id":"56df5ead-f617-4ba2-9748-86f395011bfb",
}
{
"server_response_status": "200",
"entry_list": {
"name": "KYC visit",
"type": "meeting",
"interval": {
"2018-03-18": [
{
"start_time": "8:00",
"end_time": "10:00",
"capacity": 0
},
{
"start_time": "10:00",
"end_time": "12:00",
"capacity": 0
}
],
"2018-03-19": [
{
"start_time": "10:00",
"end_time": "12:00",
"capacity": 0
},
{
"start_time": "12:00",
"end_time": "14:00",
"capacity": 0
},
],
}
}
}
Retrieves a list of recently viewed records by module for the current user.
Parameters
-
session | String
Session ID returned by a previous call to login
-
query | String
SQL where clause without the word 'where'
-
order_by | String
SQL order by clause without the phrase 'order by'
-
select_fields | Array
A list of the fields to be included in the results. This optional parameter allows for only needed fields to be retrieved.
-
max_results | integer
The maximum number of records to return. The default is the SarvCRM configuration value for 'list_max_entries_per_page'
-
deleted | integer
false if deleted records should not be include, true if deleted records should be included.
-
appointment_id | String
The ID of appointment.
Returns
-
server_response_status | integer
The status read-only property of the Response interface contains the status code of the response (e.g., 200 for a success).
-
entry_list | Array
The details that were retrieved.
get_survey_questions
$parameters = array(
"session" => $session_id,
"survey_id" =>"56df5ead-f617-4ba2-9748-86f395011bfb",
);
$result = call("get_survey_questions", $parameters, $url);
var dataToSend = {
"method" : "get_survey_questions",
"input_type" : "JSON",
"response_type" : "JSON"
};
var restData = {
"session":"tt1d4nouksbcubb6mnps0p9752",
"survey_id":"56df5ead-f617-4ba2-9748-86f395011bfb",
};
"input_type":"JSON",
"response_type":"JSON",
"method":"get_survey_questions",
"rest_data":
{
"session":"tt1d4nouksbcubb6mnps0p9752",
"survey_id":"56df5ead-f617-4ba2-9748-86f395011bfb",
}
{
"server_response_status": "200",
"entry_list": {
"1": {
"label_text": "LABEL TEXT",
"type": "rating",
"options": "",
"question_id": 1
},
"2": {
"label_text": "LABEL TEXT",
"type": "textarea",
"options": "",
"question_id": 2
},
"3": {
"label_text": "LABEL TEXT",
"type": "rating",
"options": "",
"question_id": 3
},
"4": {
"label_text": "LABEL TEXT",
"type": "radio",
"options": [
"option 1",
"option 2",
"option 3"
],
"question_id": 4
},
}
}
Retrieves a list of recently viewed records by module for the current user.
Parameters
-
session | String
Session ID returned by a previous call to login
-
survey_id | String
The ID of the survey.
Returns
-
server_response_status | integer
The status read-only property of the Response interface contains the status code of the response (e.g., 200 for a success).
-
entry_list | Array
The details that were retrieved.
Set Methods
set_entry
$set_entry_parameters = array(
"session" => $session_id,
"module_name" => "Accounts",
"name_value_list" => array(
//to create a new record with a specific ID
array(
"name" => "name",
"value" => "Test Account"
),
array(
"name" => "website",
"value" => "www.Sarvcrm.com"
),
array(
"name" => "numbers",
"value" => array(
0 => array(
"id" => "",
"type" => "Fax",
"number" => "2144226268",
"phoneCode" => "+98",
"phoneFlag" => "IR",
"extension" => "22",
"primary" => "0",
"fax" => "0",
"sms" => "1"
),
),
),
),
"meta_data" => true,
);
$result = call("set_entry", $set_entry_parameters, $url);
# You can also use this code / This code is the same as the above code
$set_entry_parameters = array(
"session" => $session_id,
"module_name" => "Accounts",
"name_value_list" => array(
// to create a new record with a specific ID
"name" => "Test Account",
"website" => "www.Sarvcrm.com",
"numbers" => array(
0 => array(
"id" => "",
"type" => "Fax",
"number" => "2144226268",
"phoneCode" => "+98",
"phoneFlag" => "IR",
"extension" => "22",
"primary" => "0",
"fax" => "0",
"sms" => "1"
),
),
),
"meta_data" => true,
);
$result = call("set_entry", $set_entry_parameters, $url);
var dataToSend = {
"method" : "set_entry",
"input_type" : "JSON",
"response_type" : "JSON"
};
var restData = {
"session":"tt1d4nouksbcubb6mnps0p9752",
"module_name":"Accounts",
"name_value_list":{
"name":"DemoUser",
"website":"www.Sarvcrm.com",
"numbers":{
"id":"",
"type":"Fax",
"number":"2144226268",
"phoneCode":"+98",
"phoneFlag":"IR",
"extension":"22",
"primary":"0",
"fax":"0",
"sms":"1",
},
},
"meta_data":true,
};
"input_type":"JSON",
"response_type":"JSON",
"method":"set_entry",
"rest_data":
{
"session":"63nmk21qbon2do9j0chtihu414",
"module_name":"Accounts",
"name_value_list":
[
{"name":"name","value":"Test_account"},
{"name":"website","value":"www.Sarvcrm.com"},
{"name":"numbers","value":[{
"id":"",
"type":"Fax",
"number":"2144440000"
"id":"+98",
"type":"IR",
"number":"22"
"id":"1",
"type":"0",
"number":"0"
}]}
]
"meta_data":true,
}
# You can also use this code / This code is the same as the above code
"input_type":"JSON",
"response_type":"JSON",
"method":"set_entry",
"rest_data":
{
"session": "4mi8q81tt3id8q0ajk79ngj7u6",
"module_name": "Accounts",
"name_value_list": {
"name": "Test Account",
"website": "www.Sarvcrm.com",
"numbers":[{
"id":"",
"type":"Fax",
"number":"2144440000"
"id":"+98",
"type":"IR",
"number":"22"
"id":"1",
"type":"0",
"number":"0"
}]
},
"meta_data": true
}
# if "meta_data" has not been set or has been set with true value
{
"server_response_status":200,
"id": "940c5fad-9eac-f170-3c7e-5a9e30f53e95",
"entry_list": {
"name": {
"name": "name",
"value": "Test Account"
},
"website": {
"name": "website",
"value": "www.Sarvcrm.com"
},
"numbers": {
"name": "phone_office",
"value": [{
"number": "1255555555",
"extension": "22",
"type": "Fax",
"country_code": "+98",
"country_flag": "IR",
"primary_number": "0",
"fax_number": "1",
"sms_number": "0"
},
{
"number": "2144226268",
"extension": "22",
"type": "Fax",
"country_code": "+98",
"country_flag": "IR",
"primary_number": "0",
"fax_number": "0",
"sms_number": "1"
}]
}
}
}
if "meta_data" has been set with false value
{
"server_response_status":200,
"id": "940c5fad-9eac-f170-3c7e-5a9e30f53e95",
"entry_list": {
"name": "Test Account",
"website": "www.Sarvcrm.com",
"numbers": [{
"number": "1255555555",
"extension": "22",
"type": "Fax",
"country_code": "+98",
"country_flag": "IR",
"primary_number": "0",
"fax_number": "1",
"sms_number": "0"
},
{
"number": "2144226268",
"extension": "22",
"type": "Fax",
"country_code": "+98",
"country_flag": "IR",
"primary_number": "0",
"fax_number": "0",
"sms_number": "1"
}]
}
}
Update or create a single Record.
Parameters
-
session | String
Session ID returned by a previous call to login
-
module_name | String
The name of the module to return records from. This name should be the name the module was developed under (changing a tab name is studio does not affect the name that should be passed into this method).
-
name_value_list | Array
The keys of the array are the Record attributes, the values of the array are the values the attributes should have.
-
meta_data | Boolean
Values: true, false [The default value is true, even if this parameter was not set]
true, the response will include metadata
flase, the response will not include metadata
Returns
-
server_response_status | integer
The status read-only property of the Response interface contains the status code of the response (e.g., 200 for a success).
-
id | string
the ID of the record that was written to (-1 on error).
-
entry_list | Array
The record that were retrieved.
set_relationship
$set_relationship_parameters = array(
"session" => $session_id,
"module_name" => "Opportunities",
"module_id" => "b8920013-425b-79b7-7dc1-58401a3fdc43",
"link_field_name" => "contacts",
"related_ids" => array(
"bcf703cc-545f-2885-91a9-583594648a20"
),
"name_value_list" => array(
array(
"name" => "contact_role",
"value" => "Other"
),
),
"delete"=> 0
);
$result = call("set_relationship", $set_relationship_parameters, $url);
var dataToSend = {
"method" : "set_relationship",
"input_type" : "JSON",
"response_type" : "JSON"
};
var restData = {
session: "n77336qa64ccmlld71fb3ev726",
module_name: "Opportunities",
module_id: "b8920013-425b-79b7-7dc1-58401a3fdc43",
link_field_name: "contacts",
related_ids: [
"bcf703cc-545f-2885-91a9-583594648a20"
],
name_value_lists: [
{
name: "contact_role",
value: "Other"
},
],
delete: 0
}
"input_type":"JSON",
"response_type":"JSON",
"method":"set_relationship",
"rest_data":
{
"session": "n77336qa64ccmlld71fb3ev726",
"module_name": "Opportunities",
"module_id": "b8920013-425b-79b7-7dc1-58401a3fdc43",
"link_field_name": "contacts",
"related_ids": [
"bcf703cc-545f-2885-91a9-583594648a20"
],
"name_value_list": [
{
"name": "contact_role",
"value": "Other"
}
],
"delete": 0,
}
{
"server_response_status":200,
"created": 1,
"failed": 0,
"deleted": 0
}
Sets relationships between two records. You can relate multiple records to a single record using this.
Parameters
-
session | String
Session ID returned by a previous call to login
-
module_name | String
The name of the module from which to retrieve records. Note: This is the modules key which may not be the same as the modules display name.
-
module_id | String
The ID of the specified module record.
-
link_field_name | String
The name of the link field for the related module.
-
related_ids | Array
The list of related record IDs you are relating.
-
name_value_list | Array
An array specifying relationship fields to populate. An example of this is contact_role between Opportunities and Contacts.
-
delete | Integer
Determines whether the relationship is being created or deleted. 0:create, 1:delete
Returns
-
server_response_status | integer
The status read-only property of the Response interface contains the status code of the response (e.g., 200 for a success).
-
created | integer
The number of relationships created.
-
failed | integer
Determines whether or not the relationship failed. This is normally thrown when the parameters module_name or link_field_name are incorrect.
-
deleted | integer
The number of relationships deleted.
set_relationships
$set_relationships_parameters = array(
"session" => $session_id,
"module_names" => array(
"Opportunities",
"Accounts",
),
"module_ids" => array(
"b8920013-425b-79b7-7dc1-58401a3fdc43", //Opportunity ID
"33450e34-45f0-659e-3d7b-579f2bb813de" //Account ID
),
"link_field_names" => array(
"contacts",
"leads"
),
"related_ids" => array(
//Contact IDs
array(
"bcf703cc-545f-2885-91a9-583594648a20"
),
//Lead IDs
array(
"87b0cff1-cb1c-7862-9ad7-522861c70bed",
"8ae00b20-2c7d-ce64-30cc-547c219ed166"
),
),
"name_value_lists" => array(
array(
array(
"name" => "contact_role",
"value" => "Other"
),
),
array(
),
),
"delete_array"=> array(
0, //Opportunity-Contact
0 //Account-Lead
),
);
$result = call("set_relationships", $set_relationships_parameters, $url);
var dataToSend = {
"method" : "set_relationships",
"input_type" : "JSON",
"response_type" : "JSON"
};
var restData = {
session: "n77336qa64ccmlld71fb3ev726",
module_names: ["Opportunities","Accounts"],
module_ids: ["b8920013-425b-79b7-7dc1-58401a3fdc43","33450e34-45f0-659e-3d7b-579f2bb813de"],
link_field_names: ["contacts","leads"],
related_ids: [
["bcf703cc-545f-2885-91a9-583594648a20"],
["87b0cff1-cb1c-7862-9ad7-522861c70bed","8ae00b20-2c7d-ce64-30cc-547c219ed166"]
],
name_value_lists: [
[{
name: "contact_role",
value: "Other"
}],
[]
],
delete_array: [0,0]
}
"input_type":"JSON",
"response_type":"JSON",
"method":"set_relationships",
"rest_data":
{
"session": "n77336qa64ccmlld71fb3ev726",
"module_names": [
"Opportunities",
"Accounts"
],
"module_ids": [
"b8920013-425b-79b7-7dc1-58401a3fdc43",
"33450e34-45f0-659e-3d7b-579f2bb813de"
],
"link_field_names": [
"contacts",
"leads"
],
"related_ids": [
[
"bcf703cc-545f-2885-91a9-583594648a20"
],
[
"87b0cff1-cb1c-7862-9ad7-522861c70bed",
"8ae00b20-2c7d-ce64-30cc-547c219ed166"
]
],
"name_value_lists": [
[
{
"name": "contact_role",
"value": "Other"
}
],
[]
],
"delete_array": [
0,
0
]
}
{
"server_response_status":200,
"created": 2,
"failed": 0,
"deleted": 0
}
Sets multiple relationships between multiple record sets.
Parameters
-
session | String
Session ID returned by a previous call to login
-
module_names | Array
The list of modules from which to retrieve records. Note: This is the modules key which may not be the same as the modules display name.
-
module_ids | Array
The list of IDs for the specified module records.
-
link_field_names | Array
The list of link names for the related modules.
-
related_ids | Array
The list of related record IDs you are relating.
-
name_value_lists | Array
An array of arrays specifying relationship fields to populate. An example of this is contact_role between Opportunities and Contacts.
-
delete_array | Array
An array determining whether the relationships are being created or deleted. 0:create, 1:delete
Returns
-
server_response_status | integer
The status read-only property of the Response interface contains the status code of the response (e.g., 200 for a success).
-
created | integer
The number of relationships created.
-
failed | integer
Determines whether or not the relationship failed. This is normally thrown when the parameters module_name or link_field_name are incorrect.
-
deleted | integer
The number of relationships deleted.
set_document_revision
$file_contents = file_get_contents("/path/to/example_document.txt");
$set_document_revision_parameters = array(
"session" => $session_id,
"document_revision" => array(
"id" => $document_id,
"file" => base64_encode($file_contents),
"filename" => "example_document.pdf",
"revision" => "2",
"upload_type" => "base64"
),
);
$result = call("set_document_revision", $set_document_revision_parameters, $url);
var dataToSend = {
"method" : "set_document_revision",
"input_type" : "JSON",
"response_type" : "JSON"
};
var restData = {
"session":"tt1d4nouksbcubb6mnps0p9752",
"document_revision":{
"id":"11132136-d009-9d59-12d7-575502d6cda3",
"file":"JVBERi0xLjQKJeLjz9MKMyAwIG9iago8PC9UeXBlIC9QYWdlCi9QYXJlbnQgM",
"filename":"example_file.pdf",
"revision":"2",
"upload_type":"base64"
},
};
"input_type":"JSON",
"response_type":"JSON",
"method":"set_document_revision",
"rest_data":
{
"session":"tt1d4nouksbcubb6mnps0p9752",
"document_revision":
{
"id":"11132136-d009-9d59-12d7-575502d6cda3",
"file":"JVBERi0xLjQKJeLjz9MKMyAwIG9iago8PC9UeXBlIC9QYWdlCi9QYXJlbnQgM"
"filename":"example_file.pdf",
"revision":"2",
"upload_type":"base64"
}
}
{
"server_response_status":200,
"id":"5e51e8ca-9531-f191-83f0-58f45c2a253d"
}
Creates a new document revision for a specific document record.
Parameters
-
session | String
Session ID returned by a previous call to login
-
document_revision | Array
The file attachment details
-
id | String
The ID of the document record to associate the attachment to.
-
file | String
The binary contents of the file.
-
filename | String
The file name of the file attachment.
-
revision | String
The revision number.
-
upload_type | String
Values: base64, multipart [The default value is base64, even if this parameter was not set]
base64, when set the API expects the base64 encoded content of the file on 'file' parameter
multipart, when set the API expects the file as part of the form data and the 'file' parameter will be ignored
Returns
-
server_response_status | integer
The status read-only property of the Response interface contains the status code of the response (e.g., 200 for a success).
-
id | string
The ID of the document revision (-1 on error).
set_note_attachment
$file_contents = file_get_contents("/path/to/example_file.php");
$set_note_attachment_parameters = array(
"session" => $session_id,
"note" => array(
"id" => $note_id,
"filename" => "example_file.php",
"file" => file_get_contents($file_contents),
),
);
$result = call("set_note_attachment", $set_note_attachment_parameters, $url);
var dataToSend = {
"method" : "set_note_attachment",
"input_type" : "JSON",
"response_type" : "JSON"
};
var restData = {
"session":"tt1d4nouksbcubb6mnps0p9752",
"note":{
"id":"11132136-d009-9d59-12d7-575502d6cda3",
"filename":"example_file.pdf",
"file":"JVBERi0xLjQKJeLjz9MKMyAwIG9iago8PC9UeXBlIC9QYWdlCi9QYXJlbnQgM",
},
};
"input_type":"JSON",
"response_type":"JSON",
"method":"set_note_attachment",
"rest_data":
{
"session":"tt1d4nouksbcubb6mnps0p9752",
"note":
{
"id":"11132136-d009-9d59-12d7-575502d6cda3",
"filename":"example_file.pdf",
"file":"JVBERi0xLjQKJeLjz9MKMyAwIG9iago8PC9UeXBlIC9QYWdlCi9QYXJlbnQgM"
}
}
{
"server_response_status":200,
"id":"5e51e8ca-9531-f191-83f0-58f45c2a253d"
}
Creates an attachment and associated it to a specific note record.
Parameters
-
session | String
Session ID returned by a previous call to login
-
note | Array
The file attachment details
-
note_id | String
The ID of the note record to associate the attachment to.
-
filename | String
The file name of the file attachment.
-
file | String
The binary contents of the file.
Returns
-
server_response_status | integer
The status read-only property of the Response interface contains the status code of the response (e.g., 200 for a success).
-
id | string
The ID of the note record/attachment (-1 on error).
set_survey_response
$parameters = array(
"session" => $session_id,
"survey_id" => "b8920013-425b-79b7-7dc1-58401a3fdc43",
"parent_type" => "Accounts",
"parent_id" => "33450e34-45f0-659e-3d7b-579f2bb813de",
"response" => array(
"1" => "2",
"2" => "text",
"3" => "5",
"4" => "key",
),
);
$result = call("set_survey_response", $parameters, $url);
var dataToSend = {
"method" : "set_survey_response",
"input_type" : "JSON",
"response_type" : "JSON"
};
var restData = {
"session":"tt1d4nouksbcubb6mnps0p9752",
"survey_id":"b8920013-425b-79b7-7dc1-58401a3fdc43",
"parent_type":"Accounts",
"parent_id":"33450e34-45f0-659e-3d7b-579f2bb813de",
"response":{
"1":"2",
"2":"text",
"3":"5",
"4":"key"
},
};
"input_type":"JSON",
"response_type":"JSON",
"method":"set_survey_response",
"rest_data":
{
"session":"tt1d4nouksbcubb6mnps0p9752",
"survey_id":"b8920013-425b-79b7-7dc1-58401a3fdc43",
"parent_type":"Accounts",
"parent_id":"33450e34-45f0-659e-3d7b-579f2bb813de",
"response":
{
"1":"2",
"2":"text",
"3":"5",
"4":"key"
}
}
{
"server_response_status":200,
"id":"5e51e8ca-9531-f191-83f0-58f45c2a253d"
}
Creates an attachment and associated it to a specific note record.
Parameters
-
session | String
Session ID returned by a previous call to login
-
survey_id | String
The ID of the survey record to associate the response to.
-
response | Array
The array of the response
-
parent_type | String
The name of the module to return records from. This name should be the name the module was developed under (changing a tab name is studio does not affect the name that should be passed into this method).
-
parent_id | String
The ID of the record in the specified module.
Returns
-
server_response_status | integer
The status read-only property of the Response interface contains the status code of the response (e.g., 200 for a success).
-
id | string
The ID of the survey response.
Examples
Main function
//FUNCTION TO MAKE CURL REQUEST
function call($method, $parameters, $url)
{
ob_start();
$curl_request = curl_init();
curl_setopt($curl_request, CURLOPT_URL, $url);
curl_setopt($curl_request, CURLOPT_POST, 1);
curl_setopt($curl_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
curl_setopt($curl_request, CURLOPT_HEADER, 1);
curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_request, CURLOPT_FOLLOWLOCATION, 0);
// ADD THESE LINES TO SUBMIT A FILE
$upload_data = array(
"name" => "uploadfile"
"file" => "@".realpath("path/to/example.pdf"));
curl_setopt($curl_request, CURLOPT_SAFE_UPLOAD, 0); // required as of PHP 5.6.0
curl_setopt($curl_request, CURLOPT_POSTFIELDS, $upload_data);
$jsonEncodedData = json_encode($parameters);
$post = array(
"method" => $method,
"input_type" => "JSON",
"response_type" => "JSON",
"rest_data" => $jsonEncodedData,);
curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post);
$result = curl_exec($curl_request);
$err = curl_error($curl_request);
curl_close($curl_request);
$result = explode("\r\n\r\n", $result, 2);
$response = json_decode($result[1]);
ob_end_flush();
return $response;
}
// Include jQuery librery
<script src="jquery.min.js"></script>
</script>
var URL = "http://app.sarvcrm.com/service2/v4_1/rest.php?&utype=TEST";
var formData = new FormData();
formData.append("method", dataToSend.method);
formData.append("input_type", dataToSend.input_type);
formData.append("response_type", dataToSend.response_type);
formData.append("rest_data", JSON.stringify(restData));
/* ADD THIS LINE TO SUBMIT A FILE*/
formData.append('file', $('input[type=file]')[0].files[0]);
$.post(URL, formData, function(data) {
var response = $.parseJSON(data);
console.log(response);
});
</script>
Main function to send and receive request.
Authentication
// AUTHENTICATION
header("Content-Type: text/html; charset=utf-8");
$url = "http://app.sarvcrm.com/service2/v4_1/rest.php?&utype=TEST";
$username = "username";
$password = "password";
// LOGIN
$login_parameters = array(
"user_auth" => array(
"user_name" => $username,
"password" => md5($password),
),
"utype" => "TEST",);
$result = call("login", $login_parameters, $url);
$session_id = $result->id;
echo (print_r(json_decode(json_encode($result), true),1));
var dataToSend = {
"method" : "login",
"input_type" : "JSON",
"response_type" : "JSON"
};
var restData = {
user_auth : {
user_name : "DemoUser",
password : "b57014dd3a80639cc4390294a0218401"
},
application : "TEST",
name_value_list : {
"name" : "language",
"value" : "fa_IR"
}
};
https://app.sarvcrm.com/service2/v4_1/rest.php?utype=TEST&method=login&input_type=JSON&response_type=JSON&rest_data={
"user_auth":{
"user_name":"DemoUser",
"password":"b57014dd3a80639cc4390294a0218401",
},
"utype":"TEST",
"name_value_list":
{
"language":
{
"name":"language",
"value":"fa_IR"
}
}
}
{
"server_response_status":200,
"id":"gjfhkshmelq4kduhqopdj2qev2",
"module_name":"Users",
"name_value_list":
{
"user_id":
{
"name":"user_id",
"value":"11132136-d009-9d59-12d7-575502d6cda3"
},
"user_name":
{
"name":"user_name",
"value":"DemoUser"
},
"user_language":
{
"name":"user_language",
"value":"en_US"
},
"user_currency_id":
{
"name":"user_currency_id",
"value":"-99"
},
"user_currency_name":
{
"name":"user_currency_name",
"value":"Rials"
}
}
}
Authentication
Set entry
// INSERT RECORD TO DOCUMENTS
$params = array(
"session" => $session_id,
"module" => "Documents",
"name_value_list" => array(
array(
"name" => "document_name",
"value" => "Test Doc2",),
array(
"name" => "status_id",
"value" => "active"),
array(
"name" => "active_date",
"value" => "2018-02-12"),),);
$result = call("set_entry", $params, $url);
$doc_id = $result->id;
echo (print_r(json_decode(json_encode($result), true),1));
var dataToSend = {
"method" : "set_entry",
"input_type" : "JSON",
"response_type" : "JSON"
};
var restData = {
"session":"63nmk21qbon2do9j0chtihu414",
"module_name":"Documents",
"name_value_list":{
"name":"Test Doc2",
"status_id":"active",
"active_date":"2018-02-12",
},
};
https://app.sarvcrm.com/service2/v4_1/rest.php?utype=TEST&method=login&input_type=JSON&response_type=JSON&rest_data={
"session":'63nmk21qbon2do9j0chtihu414',
"module_name":"Accounts",
"name_value_list":
[
{"name":"name","value":"Test Doc2"},
{"name":"status_id","value":"active"},
{"name":"active_date","value":"2018-02-12"},
]
}
{
"server_response_status":200,
"id":"123e8ca-9531-f191-83f0-76245c2a25xs"
}
Insert record to documents
Set document revision
// SET REVISION TO DOCUMENTS
$file_contents = file_get_contents("/path/test.pdf");
$params = array(
"session" => $session_id,
"document_revision" => array(
"id" => $doc_id,
"revision" => "1",
"filename" => "test.pdf",
"file" => base64_encode($file_contents),),);
$result = call("set_document_revision", $params, $url);
echo (print_r(json_decode(json_encode($result), true),1));
var dataToSend = {
"method" : "set_document_revision",
"input_type" : "JSON",
"response_type" : "JSON"
};
var restData = {
"session":"63nmk21qbon2do9j0chtihu414",
"document_revision":{
"id":"11132136-d009-9d59-12d7-575502d6cda3",
"filename":"test.pdf",
"file":"JVBERi0xLjQKJeLjz9MKMyAwIG9iago8PC9UeXBlIC9QYWdlCi9QYXJlbnQgM",
"revision":"1"
},
};
https://app.sarvcrm.com/service2/v4_1/rest.php?utype=TEST&method=login&input_type=JSON&response_type=JSON&rest_data={
"session":"63nmk21qbon2do9j0chtihu414",
"document_revision":
[
"id":"11132136-d009-9d59-12d7-575502d6cda3",
"file":"JVBERi0xLjQKJeLjz9MKMyAwIG9iago8PC9UeXBlIC9QYWdlCi9QYXJlbnQgM",
"filename":"test.pdf",
"revision":"1",
]
}
{
"server_response_status":200,
"id":"123e8ca-9531-f191-83f0-76245c2a25xs"
}
Set revision to document
Get entry
$get_entry_parameters = array(
"session" => $session_id,
"module_name" => "Documents",
"id" => "18df70e4-1422-8bff-6f5f-50aa571fe4e5",
"select_fields" => array(),
"meta_data" => false,
);
$result = call("get_entry", $get_entry_parameters, $url);
var dataToSend = {
"method" : "get_entry",
"input_type" : "JSON",
"response_type" : "JSON"
};
var restData = {
"session":"tt1d4nouksbcubb6mnps0p9752",
"module_name":"Documents",
"id":"3996386c-d5e3-f92d-5fc7-585118769e3e",
"select_fields":{},
"meta_data":false,
};
https://app.sarvcrm.com/service2/v4_1/rest.php?utype=TEST&method=login&input_type=JSON&response_type=JSON&rest_data={
"session":"tt1d4nouksbcubb6mnps0p9752",
"module_name":"Documents",
"id":"3996386c-d5e3-f92d-5fc7-585118769e3e",
"select_fields" : [],
"meta_data":false
}
{
"server_response_status":200,
"entry_list": [
{
"name":"test document"
"filename":"demo.pdf"
"document_revision_id":"c9e8159f-43ff-11ce-d8cd-5ae17c9ad231"
"revision":"2"
}
}
Get entry (Document)
Get document revision
$get_document_revision_parameters = array(
"session" => $session_id,
"id" => "c9e8159f-43ff-11ce-d8cd-5ae17c9ad231",
"select_fields" => array(),
);
$result = call("get_document_revision", $get_document_revision_parameters, $url);
var dataToSend = {
"method" : "get_document_revision",
"input_type" : "JSON",
"response_type" : "JSON"
};
var restData = {
"session":"tt1d4nouksbcubb6mnps0p9752",
"id":"c9e8159f-43ff-11ce-d8cd-5ae17c9ad231",
"select_fields":{},
};
https://app.sarvcrm.com/service2/v4_1/rest.php?utype=TEST&method=login&input_type=JSON&response_type=JSON&rest_data={
"session":"tt1d4nouksbcubb6mnps0p9752",
"id":"c9e8159f-43ff-11ce-d8cd-5ae17c9ad231"
"select_fields" : []
}
{
"server_response_status":200,
"document_revision": [
{
"id":"c9e8159f-43ff-11ce-d8cd-5ae17c9ad231"
"document_name":"Test document"
"revision":"2"
"filename":"demo.pdf"
"file":"JVBERi0xLjQKJeLjz9MKMyAwIG9iago8PC9UeXBlIC9QYWdlCi9QYXJlbnQgMSAwIFIK"
"download_link":"http://app.sarvcrm.com/download/demo.pdf"
}
}
Get last document revision
Postman Collection
Here you can download a Postman collection file which includes a few examples:
- Login
- Create an Account
- Create a Case
- Create a Lead
- Create an Opportunity
- Create a Quote
- Create a Payment
- Retrieve an Account
- Retrieve a List of Leads (Without any Filter)
- Retrieve a List of Leads (With Custom Filter)