0

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
 * Invite users
7
 *
8
 */
9
export async function main(
10
  auth: Zoho,
11
  _module: string,
12
  record: string,
13
  user_type_id: string | undefined,
14
  _type: "reinvite" | "invite" | undefined,
15
  language:
16
    | "it_IT"
17
    | "ru_RU"
18
    | "pl_PL"
19
    | "tr_TR"
20
    | "hi_IN"
21
    | "pt_BR"
22
    | "th_TH"
23
    | "fr_FR"
24
    | "ja_JP"
25
    | "in_ID"
26
    | "cs_CZ"
27
    | "de_DE"
28
    | "hu_HU"
29
    | "zh_TW"
30
    | "es_ES"
31
    | "nl_NL"
32
    | "sv_SE"
33
    | "da_DK"
34
    | "bg_BG"
35
    | "vi_VN"
36
    | "iw_IL"
37
    | "hr_HR"
38
    | "en_GB"
39
    | "ko_KR"
40
    | "en_US"
41
    | "zh_CN"
42
    | "ar_EG"
43
    | "pt_PT"
44
    | undefined,
45
) {
46
  const url = new URL(
47
    `https://zohoapis.com/crm/v8/${_module}/${record}/actions/portal_invite`,
48
  );
49
  for (const [k, v] of [
50
    ["user_type_id", user_type_id],
51
    ["type", _type],
52
    ["language", language],
53
  ]) {
54
    if (v !== undefined && v !== "" && k !== undefined) {
55
      url.searchParams.append(k, v);
56
    }
57
  }
58
  const response = await fetch(url, {
59
    method: "POST",
60
    headers: {
61
      Authorization: "Zoho-oauthtoken " + auth.token,
62
    },
63
    body: undefined,
64
  });
65
  if (!response.ok) {
66
    const text = await response.text();
67
    throw new Error(`${response.status} ${text}`);
68
  }
69
  return await response.json();
70
}
71