0

Create zia org enrichment

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 zia org enrichment
7
 *
8
 */
9
export async function main(
10
  auth: Zoho,
11
  _module: string | undefined,
12
  record_id: string | undefined,
13
  body: {
14
    __zia_org_enrichment: {
15
      enriched_data?: {
16
        org_status?: string;
17
        description?: { title?: string; description?: string }[];
18
        ceo?: string;
19
        secondary_email?: string;
20
        revenue?: string;
21
        years_in_industry?: string;
22
        other_contacts?: string[];
23
        techno_graphic_data?: string;
24
        logo?: string;
25
        secondary_contact?: string;
26
        id?: string;
27
        other_emails?: string[];
28
        sign_in?: string;
29
        website?: string;
30
        address?: {
31
          country: string;
32
          city: string;
33
          pin_code: string;
34
          state: string;
35
          fill_address: string;
36
        }[];
37
        sign_up?: string;
38
        org_type?: string;
39
        head_quarters?: {
40
          country: string;
41
          city: string;
42
          pin_code: string;
43
          state: string;
44
          fill_address: string;
45
        }[];
46
        no_of_employees?: string;
47
        territory_list?: string[];
48
        founding_year?: string;
49
        industries?: { name?: string; description?: string }[];
50
        name?: string;
51
        primary_email?: string;
52
        business_model?: string[];
53
        primary_contact?: string;
54
        social_media?: { media_type: string; media_url: string[] }[];
55
      };
56
      created_time: string;
57
      id: string;
58
      created_by: { name: string; id: string };
59
      status: string;
60
      enrich_based_on: { name: string; email?: string; website?: string };
61
    }[];
62
  },
63
) {
64
  const url = new URL(`https://zohoapis.com/crm/v8/__zia_org_enrichment`);
65
  for (const [k, v] of [
66
    ["module", _module],
67
    ["record_id", record_id],
68
  ]) {
69
    if (v !== undefined && v !== "" && k !== undefined) {
70
      url.searchParams.append(k, v);
71
    }
72
  }
73
  const response = await fetch(url, {
74
    method: "POST",
75
    headers: {
76
      "Content-Type": "application/json",
77
      Authorization: "Zoho-oauthtoken " + auth.token,
78
    },
79
    body: JSON.stringify(body),
80
  });
81
  if (!response.ok) {
82
    const text = await response.text();
83
    throw new Error(`${response.status} ${text}`);
84
  }
85
  return await response.json();
86
}
87