0

Get quote email content

by
Published Oct 17, 2025

Get the email content of a Quote.

Script zoho Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Zoho = {
3
  token: string;
4
};
5
/**
6
 * Get quote email content
7
 * Get the email content of a Quote.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  estimate_id: string,
12
  email_template_id: string | undefined,
13
  X_com_zoho_subscriptions_organizationid: string,
14
) {
15
  const url = new URL(
16
    `https://www.zohoapis.com/billing/v1/estimates/${estimate_id}/email`,
17
  );
18
  for (const [k, v] of [["email_template_id", email_template_id]]) {
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