0

Update profile

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
 * Update profile
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(`https://zohoapis.com/crm/v8/settings/profiles/${id}`);
57

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