0

Bulk invite 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
 * Bulk invite users
7
 *
8
 */
9
export async function main(
10
  auth: Zoho,
11
  _module: string,
12
  body: {
13
    portal_invite?: {
14
      data?: {
15
        id?: string;
16
        user_type_id?: string;
17
        type?: "reinvite" | "invite";
18
        language?:
19
          | "it_IT"
20
          | "ru_RU"
21
          | "pl_PL"
22
          | "tr_TR"
23
          | "hi_IN"
24
          | "pt_BR"
25
          | "th_TH"
26
          | "fr_FR"
27
          | "ja_JP"
28
          | "in_ID"
29
          | "cs_CZ"
30
          | "de_DE"
31
          | "hu_HU"
32
          | "zh_TW"
33
          | "es_ES"
34
          | "nl_NL"
35
          | "sv_SE"
36
          | "da_DK"
37
          | "bg_BG"
38
          | "vi_VN"
39
          | "iw_IL"
40
          | "hr_HR"
41
          | "en_GB"
42
          | "ko_KR"
43
          | "en_US"
44
          | "zh_CN"
45
          | "ar_EG"
46
          | "pt_PT";
47
      }[];
48
    }[];
49
  },
50
) {
51
  const url = new URL(
52
    `https://zohoapis.com/crm/v8/${_module}/actions/portal_invite`,
53
  );
54

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