# Creates a copy of an existing dynamic custom group Clones an existing dynamic custom group by copying its criteria pattern to a new group with the specified name and description. Only computer-type dynamic groups can be cloned via this endpoint — static, static-unique, and user-type dynamic groups are not supported (dynamic custom groups only support computer-type; user-type dynamic groups do not exist). The source group must exist and be accessible to the caller. The new group name must not already exist. Members of the cloned group are populated by re-evaluating the copied criteria, not by copying members from the source. **Prerequisites:** Call [Retrieve All Custom Groups](https://www.manageengine.com/products/desktop-central/custom-groups-get-cglist.html) to look up the `sourceCGId` of the dynamic group you want to clone (filter for `group_category='Dynamic'` in the returned `cg_list`). ## Endpoint `POST /api/1.4/customgroup/dynamic/clone` ## Request URL ``` https://{serverurl}/api/1.4/customgroup/dynamic/clone ``` ## Scope ``` DesktopCentralCloud.Common.UPDATE ``` ## Header ``` Authorization: Zoho-oauthtoken d92d4xxxxxxxxxxxxx15f52 ``` ## Request Parameters ### Request Headers #### Content-Type (string) — Mandatory `application/json` Must be application/json. Request body must be valid JSON. #### Accept (string) — Mandatory `application/json` Must be application/json. Only JSON responses are supported. ### Request Body **Content-Type:** `application/json` **Type:** JSON object #### groupName (string) — Mandatory Name for the cloned group. Max 100 chars. Must be unique. #### description (string) — Optional Description. Max 250 chars. #### sourceCGId (long) — Mandatory Resource ID of the source dynamic group. Must exist, be dynamic, and be accessible. Fetch from [Retrieve All Custom Groups](https://www.manageengine.com/products/desktop-central/custom-groups-get-cglist.html). ## Sample Request ### Curl ```bash curl --request POST \ --url https://appdomain/api/1.4/customgroup/dynamic/clone \ --header 'Accept: application/json' \ --header 'Authorization: Zoho-oauthtoken d92d4xxxxxxxxxxxxx15f52' \ --header 'Content-Type: application/json' \ --data '{"groupName":"Windows 11 PCs - Copy","sourceCGId":302}' ``` ### Java ```java import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.io.IOException; import java.net.http.HttpTimeoutException; public class Main { public static void main(String[] args) { HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://appdomain/api/1.4/customgroup/dynamic/clone")) .header("Content-Type", "application/json") .header("Accept", "application/json") .header("Authorization", "Zoho-oauthtoken d92d4xxxxxxxxxxxxx15f52") .method("POST", HttpRequest.BodyPublishers.ofString("{\"groupName\":\"Windows 11 PCs - Copy\",\"sourceCGId\":302}")) .build(); HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString()); System.out.println(response.body()); } } ``` ### Python ```python import http.client conn = http.client.HTTPSConnection("appdomain") payload = "{\"groupName\":\"Windows 11 PCs - Copy\",\"sourceCGId\":302}" headers = { 'Content-Type': "application/json", 'Accept': "application/json", 'Authorization': "Zoho-oauthtoken d92d4xxxxxxxxxxxxx15f52" } conn.request("POST", "/api/1.4/customgroup/dynamic/clone", payload, headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) ``` ### Deluge ```javascript headersMap = Map(); headersMap.put("Content-Type", "application/json"); headersMap.put("Accept", "application/json"); data=Map(); data.put("groupName","value"); data.put("sourceCGId","1"); response = invokeUrl [ url: "https://appDomain/api/1.4/customgroup/dynamic/clone" type: POST headers: headersMap body: data connection: connection_name ] info response; ``` ### PowerShell ```powershell $headers=@{} $headers.Add("Content-Type", "application/json") $headers.Add("Accept", "application/json") $headers.Add("Authorization", "Zoho-oauthtoken d92d4xxxxxxxxxxxxx15f52") $response = Invoke-WebRequest -Uri 'https://appdomain/api/1.4/customgroup/dynamic/clone' -Method POST -Headers $headers -ContentType 'application/json' -Body '{"groupName":"Windows 11 PCs - Copy","sourceCGId":302}' ``` ## Sample Request Body Clone a dynamic group, copying all its criteria to a new group. ```json { "groupName": "Windows 11 PCs - Copy", "sourceCGId": 302, "description": "Cloned from Windows 11 PCs for testing" } ``` ## Response Parameters ### HTTP 200 **Response Body:** `application/json` **Type:** JSON object #### message_type (string) Always `dynamic` for this endpoint. #### message_response (JSON object) Response payload container. - **dynamic (JSON object)** — Response payload. - **cgResourceId (string)** Newly assigned resource ID for the cloned group (returned as string). Use as `cgId` in [Delete CG](https://www.manageengine.com/products/desktop-central/custom-groups-delete-cg.html), or as `groupId` in the request body of [Update Dynamic CG](https://www.manageengine.com/products/desktop-central/custom-groups-update-dynamic-cg.html). - **groupName (string)** Name of the cloned group (echoed from request). - **groupCategory (string)** Always 2 (Dynamic, returned as integer not string) — only dynamic groups can be cloned. Note: addCg returns this as string `'2'`. - **groupType (string)** Always `Computer` (display name, not numeric). Note: addCg returns this as numeric string `'1'`. Only computer-type dynamic groups can be cloned. #### message_version (string) API version: `1.4`. #### status (string) `success` when the request completed without errors. ### HTTP 404 **Response Body:** `application/json` - **message_type (string)** — Always `dynamic` - **message_version (string)** — `1.4` - **status (string)** — Always `error` - **error_code (string)** — `70506` (CG_INVALID_DETAILS_TO_UPDATE) - **error_description (string)** — `No such Custom Group found.` ### HTTP 412 **Response Body:** `application/json` - **message_type (string)** — Always `dynamic` - **message_version (string)** — `1.4` - **status (string)** — Always `error` - **error_code (string)** — `70502` (CG_DUPLICATE_NAME) - **error_description (string)** — `Custom group name is already in use.` ### HTTP 500 **Response Body:** `application/json` - **message_type (string)** — Always `dynamic` - **message_version (string)** — `1.4` - **status (string)** — Always `error` - **error_code (string)** — `1003` (INTERNAL_ERROR) - **error_description (string)** — An internal error occurred while processing the request. ## Sample Response: HTTP 200 New group created with same criteria as source. ```json { "message_type": "dynamic", "message_response": { "dynamic": { "groupName": "Windows 11 PCs - Copy", "groupType": "Computer", "groupCategory": 2, "cgResourceId": "305" } }, "message_version": "1.4", "status": "success" } ``` ## Sample Response: HTTP 404 sourceCGId does not exist, is not dynamic, or user lacks access. ```json { "error_description": "No such Custom Group found.", "message_type": "dynamic", "error_code": "70506", "message_version": "1.4", "status": "error" } ``` ## Sample Response: HTTP 412 A group with this name already exists. ```json { "error_description": "Custom group name is already in use.", "message_type": "dynamic", "error_code": "70502", "message_version": "1.4", "status": "error" } ``` ## Sample Response: HTTP 500 Unexpected server-side failure during clone. ```json { "error_description": "An internal error occurred while processing the request.", "message_type": "dynamic", "error_code": "1003", "message_version": "1.4", "status": "error" } ``` ## Possible Response Codes - **200** - **404** - **412** - **500** **Duration:** 1 minute **Threshold:** 30 **Lock period:** 5 minutes Duration - Time window for the threshold. Threshold - Number of API calls allowed within the specified duration. Lock Period - Wait time before consecutive API requests.