List the design manager templates (pages, emails, blogs).
1
//native
2
3
/**
4
* List Templates
5
* List the design manager templates (pages, emails, blogs). Their `path` is what `templatePath` expects when creating pages and emails. Requires the content scope.
6
*/
7
export async function main(
8
auth: RT.Hubspot,
9
limit: number | undefined,
10
offset: number | undefined
11
) {
12
const url = new URL(`https://api.hubapi.com/content/api/v2/templates`)
13
if (limit != null) url.searchParams.append("limit", String(limit))
14
if (offset != null) url.searchParams.append("offset", String(offset))
15
16
const response = await fetch(url, {
17
headers: {
18
Authorization: `Bearer ${auth.token}`,
19
Accept: "application/json",
20
},
21
})
22
23
if (!response.ok) {
24
throw new Error(`${response.status} ${await response.text()}`)
25
}
26
27
return await response.json()
28
29