0

Retrieve a customer Using CRM Reference

by
Published Oct 17, 2025

Details of an existing customer using CRM Reference ID. reference_id can be CRM Contact ID (for Contacts only sync) or CRM Account ID (For accounts only and Accounts and its contacts sync). Query param value of reference_id_type must be given accoridngly.

Script zoho Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Zoho = {
3
  token: string;
4
};
5
/**
6
 * Retrieve a customer Using CRM Reference
7
 * Details of an existing customer using CRM Reference ID. reference_id can be  CRM Contact ID  (for Contacts only sync) or  CRM Account ID  (For accounts only and Accounts and its contacts sync). Query param value of  reference_id_type  must be given accoridngly.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  reference_id: string,
12
  reference_id_type: string | undefined,
13
  X_com_zoho_subscriptions_organizationid: string,
14
) {
15
  const url = new URL(
16
    `https://www.zohoapis.com/billing/v1/customers/reference/${reference_id}`,
17
  );
18
  for (const [k, v] of [["reference_id_type", reference_id_type]]) {
19
    if (v !== undefined && v !== "" && k !== undefined) {
20
      url.searchParams.append(k, v);
21
    }
22
  }
23
  const response = await fetch(url, {
24
    method: "GET",
25
    headers: {
26
      "X-com-zoho-subscriptions-organizationid":
27
        X_com_zoho_subscriptions_organizationid,
28
      Authorization: "Zoho-oauthtoken " + auth.token,
29
    },
30
    body: undefined,
31
  });
32
  if (!response.ok) {
33
    const text = await response.text();
34
    throw new Error(`${response.status} ${text}`);
35
  }
36
  return await response.json();
37
}
38