//native
/**
* Clone Page
* Create a copy of a website page or landing page. Requires the content scope.
*/
export async function main(
auth: RT.Hubspot,
page_type: "site-pages" | "landing-pages",
page_id: string,
clone_name: string | undefined
) {
const url = new URL(`https://api.hubapi.com/cms/v3/pages/${page_type}/clone`)
const body: { [key: string]: any } = {}
body.id = page_id
if (clone_name != null && clone_name !== "") body.cloneName = clone_name
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 4 hours ago