Inventory Templates
Purpose
To fetch the details of inventory templates.
Request Details
Request URL
{api-domain}/crm/{version}/settings/inventory_templates
To fetch details of a specific template
{api-domain}/crm/{version}/settings/inventory_templates/{id}
Supported modules
Quotes, Invoices, Purchase Orders, and Sales Orders.
All modules whose value for the key "inventory_template_supported" is true in the Modules API are supported here.
Header
Authorization: Zoho-oauthtoken d92d4xxxxxxxxxxxxx15f52
Scope
scope=ZohoCRM.templates.inventory.READ
Parameters
- modulestring, optional
Specify the API name of the module you want to fetch the inventory templates from. Refer to the Supported modules section above.
- categorystring, optional
To filter the inventory templates based on their type. The possible values are favorite: templates marked as your favorite, created_by_me: templates that you created, shared_with_me: templates that other users shared with you, and draft: templates in your draft.
- sort_bystring, optional
Specify based on what you want to sort your templates. The possible values are modified_time: to sort based on the modified time, last_usage_time: to sort based on the latest time a template was used, and name: to sort based on the template's name. The default value is modified_time.
- sort_orderstring, optional
The order you want to sort the templates in. The possible values are asc: to sort in ascending order and desc: to sort in descending order, this is the default value.
The sort_order parameter applies to given sort_by parameter value.
The content key contains the HTML of the email template and is rendered in the response only when you fetch a specific email template.
Sample Request
Copiedcurl "https://www.zohoapis.com/crm/v2.1/settings/inventory_templates"
-X GET
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
Copied//Get instance of InventoryTemplatesOperations Class
$inventoryTemplatesOperations = new InventoryTemplatesOperations($module, $sortBy, $sortOrder, $category);
//Call getInventoryTemplates method
$response = $inventoryTemplatesOperations->getInventoryTemplates();
//Get instance of InventoryTemplatesOperations Class
$inventoryTemplatesOperations = new InventoryTemplatesOperations($module, $sortBy, $sortOrder, $category);
//Call getInventoryTemplateById method that takes Id as parameter
$response = $inventoryTemplatesOperations->getInventoryTemplateById($Id);
Copied<?php
class GetInventoryTemplates{
public function execute(){
$curl_pointer = curl_init();
$curl_options = array();
$url = "https://www.zohoapis.com/crm/v2/settings/inventory_templates?";
$parameters = array();
$parameters['module'] ='Quotes';
$parameters['category'] ='created_by_me';
$parameters['sort_order'] ='asc';
$parameters['sort_by']='modified_time';
foreach ($parameters as $key=>$value){
$url =$url.$key."=".$value."&";
}
$curl_options[CURLOPT_URL] = $url;
$curl_options[CURLOPT_RETURNTRANSFER] = true;
$curl_options[CURLOPT_HEADER] = 1;
$curl_options[CURLOPT_CUSTOMREQUEST] = "GET";
$headersArray = array();
$headersArray[] = "Authorization". ":" . "Zoho-oauthtoken " ."1000.30f3a589XXXXXXXXXXXXXXXXXXX4077.dc5XXXXXXXXXXXXXXXXXXXee9e7c171c";
$curl_options[CURLOPT_HTTPHEADER]=$headersArray;
curl_setopt_array($curl_pointer, $curl_options);
$result = curl_exec($curl_pointer);
$responseInfo = curl_getinfo($curl_pointer);
curl_close($curl_pointer);
list ($headers, $content) = explode("\r\n\r\n", $result, 2);
if(strpos($headers," 100 Continue")!==false){
list( $headers, $content) = explode( "\r\n\r\n", $content , 2);
}
$headerArray = (explode("\r\n", $headers, 50));
$headerMap = array();
foreach ($headerArray as $key) {
if (strpos($key, ":") != false) {
$firstHalf = substr($key, 0, strpos($key, ":"));
$secondHalf = substr($key, strpos($key, ":") + 1);
$headerMap[$firstHalf] = trim($secondHalf);
}
}
$jsonResponse = json_decode($content, true);
if ($jsonResponse == null && $responseInfo['http_code'] != 204) {
list ($headers, $content) = explode("\r\n\r\n", $content, 2);
$jsonResponse = json_decode($content, true);
}
var_dump($headerMap);
var_dump($jsonResponse);
var_dump($responseInfo['http_code']);
}
}
(new GetInventoryTemplates())->execute();
Response JSON Keys
- created_timestring
Represents the date and time at which the inventory template was created.
- modified_timestring
Represents the date and time at which the inventory template was last modified.
- folderJSON object
Represents the name and unique ID of the template folder.
- last_usage_timestring
Represents the date and time at which the inventory template was last used.
- moduleJSON object
Represents the API name and unique ID of the module with which the inventory template is associated.
- namestring
Represents the name of the template.
- modified_byJSON object
Represents the name and ID of the user who last modified the inventory template.
- idstring
Represents the unique ID of the inventory template.
- editor_modestring
Represents the mode in which the inventory template is created. The possible values are gallery: the template is chosen from the template gallery and is customized, rich_text: a pre-designed custom template, plain_text: the template is built from scratch.
To know more about the editor modes, refer to Creating Inventory Templates. - favoriteboolean
Represents if the inventory template is marked as favorite. The possible values are true: the inventory template is marked as favorite, false: the inventory template is not marked as favorite.
- typestring
Represents the type of the template. The possible values are custom_templates: the templates created by a user, system_templates: the templates present in the system by default, plugin_templates: the templates that are created and installed from the Zoho CRM extension, marketplace_templates: the templates that are created and installed from the published plugins.
- created_byJSON object
Represents the name and ID of the user who created the inventory template.
Possible Errors
- INVALID_MODULEHTTP 400
The module name specified is invalid.
Resolution: Specify the valid module API name. Refer to the Supported modules section above. - PATTERN_NOT_MATCHEDHTTP 400
You have specified incorrect values for the key specified in "api_name" of the response.
Resolution: Input correct values. - FEATURE_NOT_SUPPORTEDHTTP 403
This feature is not supported for your edition.
Resolution: Contact your administrator. - NO_PERMISSIONHTTP 403
You do not have permission to view the templates of this module.
Resolution: Contact your administrator. - INVALID_URL_PATTERNHTTP 404
Please check if the URL trying to access is a correct one.
Resolution: The request URL specified is incorrect. Specify a valid request URL. Refer to the Request URL section above. - OAUTH_SCOPE_MISMATCHHTTP 401
Unauthorized
Resolution: Client does not have ZohoCRM.templates.inventory.READ scope. Create a new client with valid scope. Refer to the Scope section above. - INTERNAL_ERRORHTTP 500
Internal Server Error
Resolution: Unexpected and unhandled exception in Server. Contact support team. - INVALID_REQUEST_METHODHTTP 400
The http request method type is not a valid one
Resolution: You have specified an invalid HTTP method to access the API URL. Specify a valid request method. Refer to the Endpoints section above. - AUTHORIZATION_FAILEDHTTP 400
User does not have sufficient privilege to read records data
Resolution: The user does not have the permission to retrieve records data. Contact your system administrator.
Sample Response
Copied{
"inventory_templates": [
{
"created_time": "2020-12-21T10:33:42+05:30",
"modified_time": "2020-12-21T10:33:42+05:30",
"folder": {
"name": "Quote Templates",
"id": "4150868000004027086"
},
"last_usage_time": null,
"module": {
"api_name": "Quotes",
"id": "4150868000000002219"
},
"name": "Quote Template1",
"modified_by": {
"name": "Patricia Boyle",
"id": "4150868000000225013"
},
"id": "4150868000004027091",
"editor_mode": "gallery",
"type": "custom_templates",
"favorite": false,
"created_by": {
"name": "Patricia Boyle",
"id": "4150868000000225013"
}
},
{
"created_time": "2019-08-20T11:21:30+05:30",
"modified_time": "2019-08-20T11:21:30+05:30",
"folder": {
"name": "Public Templates",
"id": "4150868000000226424"
},
"last_usage_time": null,
"module": {
"api_name": "Purchase_Orders",
"id": "4150868000000002223"
},
"name": "Purchase Order Template",
"modified_by": null,
"id": "4150868000000227007",
"editor_mode": "rich_text",
"type": "system_templates",
"favorite": false,
"created_by": null
},
{
"created_time": "2019-08-20T11:21:30+05:30",
"modified_time": "2019-08-20T11:21:30+05:30",
"folder": {
"name": "Public Templates",
"id": "4150868000000226424"
},
"last_usage_time": null,
"module": {
"api_name": "Sales_Orders",
"id": "4150868000000002221"
},
"name": "Sales Order Template",
"modified_by": null,
"id": "4150868000000227005",
"editor_mode": "rich_text",
"type": "system_templates",
"favorite": false,
"created_by": null
},
{
"created_time": "2019-08-20T11:21:30+05:30",
"modified_time": "2019-08-20T11:21:30+05:30",
"folder": {
"name": "Public Templates",
"id": "4150868000000226424"
},
"last_usage_time": null,
"module": {
"api_name": "Invoices",
"id": "4150868000000002225"
},
"name": "Invoice Template",
"modified_by": null,
"id": "4150868000000227003",
"editor_mode": "rich_text",
"type": "system_templates",
"favorite": false,
"created_by": null
},
{
"created_time": "2019-08-20T11:21:30+05:30",
"modified_time": "2019-08-20T11:21:30+05:30",
"folder": {
"name": "Public Templates",
"id": "4150868000000226424"
},
"last_usage_time": null,
"module": {
"api_name": "Quotes",
"id": "4150868000000002219"
},
"name": "Quote Template",
"modified_by": null,
"id": "4150868000000227001",
"editor_mode": "rich_text",
"type": "system_templates",
"favorite": false,
"created_by": null
}
],
"info": {
"per_page": 200,
"count": 5,
"page": 1,
"more_records": false
}
}