Insert Subform Data
Purpose
To insert a new record with subforms in a module.
Endpoints
- POST /{module_API_name}
Request Details
Request URL
{api-domain}/crm/{version}/{module_API_name}
Supported modules
Leads, Accounts, Contacts, Deals, Campaigns, Cases, Solutions, Products, Vendors, Quotes, Sales Orders, Purchase Orders, Invoices and Custom.
Header
Authorization: Zoho-oauthtoken d92d4xxxxxxxxxxxxx15f52
Scope
ZohoCRM.modules.{module_name}.{operation_type}
Possible module names
leads, accounts, contacts, deals, campaigns, cases, solutions, products, vendors, quotes, salesorders, purchaseorders, invoices and custom.
Possible operation types
ALL - Full access to a record
WRITE - Create, update, and delete records in a module
CREATE - Create records in a module
Sample Request
Copiedcurl "https://www.zohoapis.com/crm/v8/Leads"
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
-d "@newlead.json"
-X POSTCopiedLanguagesData = List();
	LanguagesData.add({"Proficiency": "Native","Languages_Known": "English"});
	LanguagesData.add({"Proficiency": "Professional","Languages_Known": "French"});
	
	LeadData = Map();
	LeadData.put("Last_Name", "Contact_test");
	LeadData.put("Email", "contact_test@xyz.com");
	LeadData.put("Company", "Test");
	LeadData.put("Languages", LanguagesData);
	LeadData.put("Availability", [{"Weekends":"false","Weekdays":"true"}]);
	
	LeadDataList = List();
	LeadDataList.add(LeadData);
	
	paramsMap = Map();
	paramsMap.put("data", LeadDataList);
	
	response = invokeurl
[
	url: "https://www.zohoapis.com/crm/v8/Leads"
	type: POST
	parameters: paramsMap.toString()
	connection:"crm_oauth_connection"
];
info response;In the request, @newlead.json contains the sample input data.
Note
- To add data to multiple subforms, enter the input in the following format. 
 - { “data”: [ { .... Subform_1_API_name: [ { sub_form_data }, ], ... }, { .... Subform_2_API_name: [ { sub_form_data }, ], ... } ] }
- You can use the Modules API and Fields Metadata API to get the API name of the subform module and its fields, respectively.
- A subform can have a maximum of five aggregate custom fields.
- Edition-wise Subform Support and Limits:- Enterprise and Zoho One - Two subforms per module. Each record's subform can have a maximum of 100 subform records.
- Utlimate and CRM Plus - Five subforms per module. Each record's subform can have a maximum of 100 subform records.
 
Sample Input
Copied{
    "data": [
        {
            "Last_Name": "Contact_test",
            "Email": "contact_test@xyz.com",
            "Languages": [
                {
                    "Proficiency": "Native",
                    "Languages_Known": "English"
                },
                {
                    "Proficiency": "Professional",
                    "Languages_Known": "French"
                }
            ],
            "Availability":[
            	{
            		"Weekends":false,
            		"Weekdays":true
            	}]
        }
    ]
}Here, "Languages" and "Availability" are two subforms in the Leads module. "Proficiency" and "Languages_Known" are custom picklists in Languages subform. "Weekends" and "Weekdays" are boolean fields in Availability subform.
Possible Errors
- INVALID_MODULEHTTP 400You have either specified an invalid module API name, there is no tab permission, or the module is removed from the list of available modules. 
 Resolution: Use the Modules API to get the API name of the module. If you have no tab permission or the module is removed, contact your system administrator.
- INVALID_MODULEHTTP 400The given module is not supported in API. 
 Resolution: The modules such as Documents and Projects are not supported in API, currently. This error will not be shown, once these modules are supported.
- INVALID_DATAHTTP 400You have given an incorrect input. 
 Resolution: Specify a valid input. Refer to the Sample Input section for an example.
- MANDATORY_NOT_FOUNDHTTP 400You have not included one or more mandatory fields in the input. 
 Resolution: Refer to the Fields Metadata API to know the mandatory fields in that module.
- AUTHORIZATION_FAILEDHTTP 400You do not have sufficient permission to add subform or module records. 
 Resolution: Contact your system administrator.
- INVALID_REQUEST_METHODHTTP 400The request method is incorrect. 
 Resolution: Use the HTTP POST method to make this API call. Any other request method will result in this error.
- AUTHENTICATION_FAILUREHTTP 401You have not authenticated the API call with valid access token. 
 Resolution: Include a valid access token in the request header to authenticate the API call.
- OAUTH_SCOPE_MISMATCHHTTP 401The access token you have used to make this API call does not have the required scope. 
 Resolution: Generate a new access token with the scope ZohoCRM.modules.{module_name}.{operation_type}. Refer to the Possible module names and Possible operation types sections for details.
- NO_PERMISSIONHTTP 403You do not have permission to add records to the subform. 
 Resolution: Contact your system administrator.
- INVALID_URL_PATTERNHTTP 404The request URL is incorrect. 
 Resolution: Specify a valid request URL. Refer to the Request URL section for the right URL.
- INTERNAL_ERRORHTTP 500Unexpected and unhandled exception in the server. 
 Resolution: Contact the support team at support@zohocrm.com.
Sample Response
Copied{
    "data": [
        {
            "code": "SUCCESS",
            "details": {
                "Modified_Time": "2019-04-23T16:57:01+05:30",
                "Modified_By": {
                    "name": "Patricia Boyle",
                    "id": "554023000000235011"
                },
                "Created_Time": "2019-04-23T16:57:01+05:30",
                "id": "554023000000480721",
                "Created_By": {
                    "name": "Patricia Boyle",
                    "id": "554023000000235011"
                }
            },
            "message": "record added",
            "status": "success"
        }
    ]
}