//native
/**
* Clone Marketing Email
* Create a copy of an existing marketing email. Requires the content scope.
*/
export async function main(
auth: RT.Hubspot,
email_id: string,
clone_name: string | undefined,
language: string | undefined
) {
const url = new URL(`https://api.hubapi.com/marketing/v3/emails/clone`)
const body: { [key: string]: any } = {}
body.id = email_id
if (clone_name != null && clone_name !== "") body.cloneName = clone_name
if (language != null && language !== "") body.language = language
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: `Bearer ${auth.token}`,
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify(body),
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 5 hours ago