0

Download mail merge

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
 * Download mail merge
7
 *
8
 */
9
export async function main(
10
  auth: Zoho,
11
  id: string,
12
  _module: string,
13
  body: {
14
    download_mail_merge?: {
15
      mail_merge_template?: { id?: string; name?: string };
16
      output_format?: "pdf" | "html" | "docx";
17
      file_name?: string;
18
      password?: string;
19
    }[];
20
  },
21
) {
22
  const url = new URL(
23
    `https://zohoapis.com/crm/v8/${_module}/${id}/actions/download_mail_merge`,
24
  );
25

26
  const response = await fetch(url, {
27
    method: "POST",
28
    headers: {
29
      "Content-Type": "application/json",
30
      Authorization: "Zoho-oauthtoken " + auth.token,
31
    },
32
    body: JSON.stringify(body),
33
  });
34
  if (!response.ok) {
35
    const text = await response.text();
36
    throw new Error(`${response.status} ${text}`);
37
  }
38
  return await response.json();
39
}
40