Update Function
Purpose
Use this API to update an existing function in your Zoho CRM account.
You can update the function name, description, code, and publish configuration. For Deluge functions, you can also update the function arguments by modifying the function declaration in the Deluge script. You cannot update the function API name, runtime, or category of a function.
Endpoints
- PUT /settings/functions/{function_identifier}
Here, {function_identifier} represents the unique ID or API name of the function. You can use the List Functions API to obtain the function ID or API name.
Request Details
Request URL
{api-domain}/crm/{version}/settings/functions/{function_identifier}
Here, {function_identifier} represents the unique ID or API name of the function. You can use the List Functions API to obtain the function ID or API name.
Header
Authorization: Zoho-oauthtoken d92d4xxxxxxxxxxxxx15f52
Scope
ZohoCRM.settings.functions.ALL
(or)
ZohoCRM.settings.functions.UPDATE
(or)
ZohoCRM.settings.UPDATE
Request Body
This API accepts a multipart/form-data request. Specify at least one of the metadata or code form-data parameters.
- metadatatext, optional if code file is uploaded
Specify the updated function metadata in JSON format. Refer to the Input JSON section for the complete schema.
- codefile, optional if metadata is specified
Upload the updated function implementation. For Deluge functions, upload a Deluge script (.ds) file. For Java, Node.js, and Python runtimes, upload the function package as a ZIP file. If a ZIP package is already associated with the function, the uploaded ZIP file must have the same filename.
For ZIP package requirements and runtime-specific package structure, refer to the ZIP Package Requirements and ZIP Package Structure sections.The maximum supported file size for the code form-data parameter is 25 MB.
Note
- For Deluge functions, you can specify the function implementation using the _code key or upload it as a Deluge script (.ds) file using the code form-data parameter.
- If both code and _code are specified, the code file takes precedence and the _code value is ignored.
- The function declaration in the updated script must use the function's existing name in lowercase, with spaces replaced by underscores, followed by the category name in lowercase, with spaces replaced by underscores. Otherwise, the API returns a COMPILATION_ERROR.
- For Java, Node.js, and Python functions, upload the updated function implementation as a ZIP file using the code form-data parameter.
Sample Request
Copiedcurl "https://www.zohoapis.com/crm/v8/settings/functions/4876876000021209022"
-X PUT
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
-F "metadata=@function.json;type=application/json"
-F "code=@restoredealbyname1.ds"Input JSON
The metadata form-data parameter accepts the following JSON object:
- functionsJSON array, mandatory
Specify the function to update. The functions array supports only one object. The object contains the following keys:
- namestring, optional
Specify the display name of the function. The name must start with a letter and can contain only letters, digits, spaces, hyphens (-), and underscores (_). The name must be between 3 and 100 characters long.
- descriptionstring, optional
Specify a description for the function. The description can be up to 3000 characters long.
- _codestring, optional
Specify the complete Deluge function definition as a JSON string. This key is applicable only when the runtime is Deluge 1.0. For Deluge functions, you can either specify the implementation using this key or upload a Deluge script (.ds) file using the code form-data parameter.
The maximum possible length of the _code key value is 2097152 characters.Paste your Deluge function below to convert it to a JSON string that you can use as the value of the _code key.
Note: This tool converts the code to a JSON string. Do not apply URL encoding or form URL encoding to the converted value.
- publishJSON object, optional
Specify the publish configuration for the function.
For Deluge functions, specifying this object records the changelog for the published revision. Deluge functions are published automatically regardless of whether this object is specified.
For Java, Node.js, and Python functions, specifying this object attempts to publish the updated function. If the function is not published through this request, you can use the Publish Function API to publish it later.- changelogstring, optional
Specify the changelog message to associate with the published version of the function.
ZIP Package Requirements
The following requirements apply when uploading a ZIP package using the code form-data parameter:
- The file must be in .zip format and must not exceed 25 MB.
- The ZIP file can contain a maximum of 10,000 entries, and the maximum possible size of an individual extracted file is 25 MB.
- The filename must be unique.
- For non-Deluge functions, when updating the function code using a ZIP file, the ZIP file must have the same filename as the ZIP file used when the function was created. Use the Download Function Code API to obtain the filename.
- The filename can contain only letters and numbers and must not exceed 255 characters.
- The function ZIP package must follow the runtime-specific folder structure described in the ZIP Package Structure section.
ZIP Package Structure
The Function ZIP package must follow the runtime-specific folder structure described below.
Java and Python
<function-folder>/
├── <function-name>.java
├── lib/
└── config.json
Node.js
<function-folder>/
├── <function-name>.js
├── node_modules/
└── config.json
Sample Input
Copied{
"functions": [
{
"name": "Restore Deal By Name Updated",
"description": "Restores a deleted Deal by name from the Recycle Bin. Updated using the Functions API."
}
],
"publish": {
"changelog": "Updated function metadata, arguments, and implementation."
}
}Note:
- For Java, Node.js, and Python functions, if the function is updated successfully but the publish operation fails due to compilation errors in the uploaded code package, the API returns an HTTP 207 (Partial Success) response. In this case, the updated function remains in the unpublished state.
- For COMPILATION_ERROR, the response contains the line number, character position, and compilation error message to help you identify and resolve the issue.
Possible Errors
- COMPILATION_ERRORHTTP 400
Function have compilation errors
Resolution: Resolve the compilation errors returned in the response, and then retry the request. - EXPECTED_PARAM_MISSINGHTTP 400
One of the expected parameter is missing
Resolution: Specify at least one of the metadata or code form-data parameters, and then retry the request. - API_NOT_SUPPORTEDHTTP 400
API not supported for client portal user
Resolution: This API is not supported for Client Portal users. Use a supported CRM user account to access this API. - DUPLICATE_DATAHTTP 400
- Duplicate name
Resolution: Specify a unique value for the name key and retry the request. - Code package with the same file name already exists
Resolution: Ensure that the uploaded ZIP file has a unique filename, and then retry the request.
- Duplicate name
- FEATURE_NOT_ENABLEDHTTP 400
Feature is not enabled yet
Resolution: Enable the required feature for your organization, and then retry the request. - NOT_ALLOWEDHTTP 400
- _code not allowed
Resolution: The _code key is supported only for Deluge functions. For Java, Node.js, and Python functions, upload the function package using the code form-data parameter. - Api name update is not allowed
Resolution: Remove the api_name key from the request body.
- _code not allowed
- CANNOT_PROCESSHTTP 400
- Unable to process your request
Resolution: Retry the request after some time. If the issue persists, contact Zoho Support.
- Unable to process your request
- INVALID_DATAHTTP 400
Invalid data
Resolution: Refer to the message in the response for details about the invalid data, and resolve the issue accordingly. Here are a few possible resolutions:- Verify that the metadata form-data parameter contains a valid JSON object, and then retry the request.
- Specify a valid value for the name key, and then retry the request.
- Ensure that the uploaded function implementation is valid and not corrupted, and then retry the request.
- Ensure that the uploaded file name is the same as the one that is already associated with the function. Use Download Function Code API to verify this.
- INVALID_REQUEST_METHODHTTP 400
The http request method type is not a valid one
Resolution: This API supports only the PUT method. Retry the request using the PUT method. - OAUTH_SCOPE_MISMATCHHTTP 401
Unauthorized
Resolution: Client does not have the required OAUTH SCOPE. Create a new token with valid scopes. Refer to the Scope section for more details. - NO_PERMISSIONHTTP 403
Permission denied
Resolution: Ensure that the user making the API call has the Manage Automation permission enabled in their CRM profile, and then retry the request. - 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 for more details. - FILE_SIZE_EXCEEDSHTTP 413
File size exceeds
Resolution: Ensure that the uploaded function implementation does not exceed the maximum supported file size of 25 MB, and then retry the request. - INTERNAL_ERRORHTTP 500
Internal Server Error
Resolution: Unexpected and unhandled exception in Server. Contact support team.
Sample Response
Copied{
"functions": [
{
"code": "SUCCESS",
"details": {
"id": "4876876000021209022"
},
"message": "function updated successfully",
"status": "success"
}
]
}