There's a newer version of SarvCRM API! Navbar
php JavaScript json request json response
  • Introduction
  • What can this API do for you?
  • How do I access the SarvCRM API?
  • Versioning
  • Languages
  • Module List
  • Data Types
  • Request
  • Response
  • Authentication
  • Login
  • Logout
  • Get Methods
  • Get Entry
  • Get Entry List
  • Get Relationships
  • Get User ID
  • Get Module Fields
  • Get Document Attachment
  • Get Note Attachment
  • Get Last Viewed
  • Get Appointment Interval List
  • Get Resources List
  • Get Survey Questions
  • Set Methods
  • Set Entry
  • Set Relationship
  • Set Relationships
  • Set Document Attachment
  • Set Note Attachment
  • Set Survey Response
  • Examples
  • Postman Collection
  • 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

    Version REST URL SOAP URL
    v1 Not Available Not Available ---
    v2 http://app.sarvcrm.com/service2/v2/rest.php?utype=TEST http://app.sarvcrm.com/service2/v2/soap.php?utype=TEST ---
    v3_1 http://app.sarvcrm.com/service2/v3_1/rest.php?utype=TEST http://app.sarvcrm.com/service2/v3_1/soap.php?utype=TEST ---
    v4 http://app.sarvcrm.com/service2/v4/rest.php?utype=TEST http://app.sarvcrm.com/service2/v4/soap.php?utype=TEST ---
    v4_1 http://app.sarvcrm.com/service2/v4_1/rest.php?utype=TEST http://app.sarvcrm.com/service2/v4_1/soap.php?utype=TEST ---
    v5 http://app.sarvcrm.com/API.php http://app.sarvcrm.com/API.php

    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:

    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

    Returns

    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

    Returns

    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

    Returns

    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

    Returns

    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

    Returns

    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

    Returns

    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

    Returns

    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

    Returns

    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

    Returns

    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

    Returns

    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

    Returns

    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

    Returns

    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

    Returns

    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

    Returns

    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

    Returns

    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

    Returns

    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

    Returns

    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

    Returns

    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

    Returns

    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: