0

Delete related record using external id

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
 * Delete related record using external id
7
 *
8
 */
9
export async function main(
10
  auth: Zoho,
11
  module_api_name: string,
12
  external_value: string,
13
  related_list_api_name: string,
14
  external_field_value: string,
15
  X_EXTERNAL?: string,
16
) {
17
  const url = new URL(
18
    `https://zohoapis.com/crm/v8/${module_api_name}/${external_value}/${related_list_api_name}/${external_field_value}`,
19
  );
20

21
  const response = await fetch(url, {
22
    method: "DELETE",
23
    headers: {
24
      ...(X_EXTERNAL ? { "X-EXTERNAL": X_EXTERNAL } : {}),
25
      Authorization: "Zoho-oauthtoken " + auth.token,
26
    },
27
    body: undefined,
28
  });
29
  if (!response.ok) {
30
    const text = await response.text();
31
    throw new Error(`${response.status} ${text}`);
32
  }
33
  return await response.json();
34
}
35