0

Update notifications

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 notifications
7
 *
8
 */
9
export async function main(
10
  auth: Zoho,
11
  body: {
12
    watch?: {
13
      channel_id: string;
14
      notify_url: string;
15
      events: string[];
16
      token?: string;
17
      fields?: {};
18
      notify_on_related_action?: false | true;
19
      return_affected_field_values?: false | true;
20
      _delete_events?: true;
21
      resource_name?: string;
22
      channel_expiry?: string;
23
      resource_id?: string;
24
      resource_uri?: string;
25
      notification_condition?: {
26
        type?: string;
27
        module: { api_name?: string; id?: string };
28
        field_selection: {
29
          comparator: string;
30
          field: { api_name: string; id: string };
31
          value: {};
32
          group_operator: string;
33
          group: {}[];
34
        };
35
      }[];
36
    }[];
37
  },
38
) {
39
  const url = new URL(`https://zohoapis.com/crm/v8/actions/watch`);
40

41
  const response = await fetch(url, {
42
    method: "PUT",
43
    headers: {
44
      "Content-Type": "application/json",
45
      Authorization: "Zoho-oauthtoken " + auth.token,
46
    },
47
    body: JSON.stringify(body),
48
  });
49
  if (!response.ok) {
50
    const text = await response.text();
51
    throw new Error(`${response.status} ${text}`);
52
  }
53
  return await response.json();
54
}
55