0

Create users

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
 * Create users
7
 *
8
 */
9
export async function main(
10
  auth: Zoho,
11
  body: {
12
    users: {
13
      country?: string;
14
      language?: string;
15
      microsoft?: false | true;
16
      $shift_effective_from?: {};
17
      id?: string;
18
      state?: string;
19
      fax?: string;
20
      country_locale?: string;
21
      zip?: string;
22
      created_time?: string;
23
      time_format?: "HH:mm" | "hh:mm a";
24
      offset?: number;
25
      imap_status?: false | true;
26
      image_link?: string;
27
      ezuid?: string;
28
      profile?: { name: string; id: string };
29
      role?: { name: string; id: string };
30
      created_by?: { name: string; id: string; email?: string };
31
      full_name?: string;
32
      zuid?: string;
33
      phone?: string;
34
      dob?: string;
35
      status?: string;
36
      customize_info?: {
37
        notes_desc: {};
38
        show_right_panel: {};
39
        bc_view: {};
40
        unpin_recent_item: {};
41
        show_home: false | true;
42
        show_detail_view: false | true;
43
      };
44
      city?: string;
45
      signature?: string;
46
      sort_order_preference__s?: string;
47
      category?: string;
48
      date_format?: "MMM d, yyyy";
49
      confirm?: false | true;
50
      decimal_separator?: "Comma" | "Period";
51
      number_separator?: "Space";
52
      time_zone?: {};
53
      last_name?: string;
54
      mobile?: string;
55
      $current_shift?: { name: string; id: string };
56
      Reporting_To?: { name: string; id: string; email?: string };
57
      Currency?: string;
58
      $next_shift?: { name: string; id: string };
59
      Modified_Time?: string;
60
      website?: string;
61
      status_reason__s?: string;
62
      email?: string;
63
      first_name?: string;
64
      sandboxDeveloper?: false | true;
65
      alias?: string;
66
      street?: string;
67
      Modified_By?: {
68
        name: string;
69
        id: string;
70
        last_name: string;
71
        first_name: string;
72
      };
73
      Isonline?: false | true;
74
      locale?: string;
75
      name_format__s?:
76
        | "Salutation,First Name,Last Name"
77
        | "Saluation,Last Name,First Name"
78
        | "First Name,Last Name,Saluation";
79
      personal_account?: false | true;
80
      default_tab_group?: string;
81
      theme?: {
82
        normal_tab: { font_color: "#FFFFFF"; background: "#222222" };
83
        selected_tab: { font_color: "#FFFFFF"; background: "#222222" };
84
        new_background: string;
85
        background: "#F3F0EB";
86
        screen: "fixed";
87
        type: string;
88
      };
89
      ntc_notification_type?: number[];
90
      ntc_enabled?: false | true;
91
      rtl_enabled?: false | true;
92
      telephony_enabled?: false | true;
93
      sort_order_preference?: string;
94
    }[];
95
  },
96
) {
97
  const url = new URL(`https://zohoapis.com/crm/v8/users`);
98

99
  const response = await fetch(url, {
100
    method: "POST",
101
    headers: {
102
      "Content-Type": "application/json",
103
      Authorization: "Zoho-oauthtoken " + auth.token,
104
    },
105
    body: JSON.stringify(body),
106
  });
107
  if (!response.ok) {
108
    const text = await response.text();
109
    throw new Error(`${response.status} ${text}`);
110
  }
111
  return await response.json();
112
}
113