Create a website page or landing page draft.
1
//native
2
3
/**
4
* Create Page
5
* Create a website page or landing page draft. `body` is a HubSpot page object; common fields are name, templatePath, slug, htmlTitle, metaDescription, domain, layoutSections. Requires the content scope.
6
*/
7
export async function main(
8
auth: RT.Hubspot,
9
page_type: "site-pages" | "landing-pages",
10
body: { [key: string]: any }
11
) {
12
const url = new URL(`https://api.hubapi.com/cms/v3/pages/${page_type}`)
13
14
const response = await fetch(url, {
15
method: "POST",
16
headers: {
17
Authorization: `Bearer ${auth.token}`,
18
"Content-Type": "application/json",
19
Accept: "application/json",
20
},
21
body: JSON.stringify(body),
22
})
23
24
if (!response.ok) {
25
throw new Error(`${response.status} ${await response.text()}`)
26
}
27
28
return await response.json()
29
30