0

Clone profiles

by
Published Oct 17, 2025
Script zoho Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Zoho = {
3
  token: string;
4
};
5
/**
6
 * Clone profiles
7
 *
8
 */
9
export async function main(
10
  auth: Zoho,
11
  id: string,
12
  body: {
13
    profiles: {
14
      _default_view?: { name?: string; id?: string; type?: string };
15
      name: string;
16
      description: string;
17
      id: string;
18
      default?: false | true;
19
      _delete?: false | true;
20
      permission_type?: string;
21
      custom?: false | true;
22
      display_label: string;
23
      type?: "normal_profile" | "lite_profile";
24
      permissions_details: {
25
        id: string;
26
        enabled: false | true;
27
        name: string;
28
        display_label: string;
29
        customizable?: false | true;
30
        parent_permissions?: string[];
31
        module: string;
32
      }[];
33
      sections: {
34
        name: string;
35
        categories:
36
          | {
37
              display_label: string;
38
              permissions_details: string[];
39
              name: string;
40
            }
41
          | {
42
              display_label: string;
43
              permissions_details: string[];
44
              name: string;
45
              module: string;
46
            }[];
47
      }[];
48
      created_time: string;
49
      modified_time: string;
50
      modified_by: { name: string; id: string; email?: string };
51
      category: false | true;
52
      created_by: { name: string; id: string; email?: string };
53
    }[];
54
  },
55
) {
56
  const url = new URL(
57
    `https://zohoapis.com/crm/v8/settings/profiles/${id}/actions/clone`,
58
  );
59

60
  const response = await fetch(url, {
61
    method: "POST",
62
    headers: {
63
      "Content-Type": "application/json",
64
      Authorization: "Zoho-oauthtoken " + auth.token,
65
    },
66
    body: JSON.stringify(body),
67
  });
68
  if (!response.ok) {
69
    const text = await response.text();
70
    throw new Error(`${response.status} ${text}`);
71
  }
72
  return await response.json();
73
}
74