0

List Custom Object Schemas

by
Published today

List the account's custom object schemas (name, objectTypeId, properties, associations).

Script hubspot Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 4 hours ago
1
//native
2

3
/**
4
 * List Custom Object Schemas
5
 * List the account's custom object schemas (name, objectTypeId, properties, associations). Requires crm.schemas.custom.read.
6
 */
7
export async function main(auth: RT.Hubspot, archived: boolean | undefined) {
8
  const url = new URL(`https://api.hubapi.com/crm/v3/schemas`)
9
  if (archived) url.searchParams.append("archived", String(archived))
10

11
  const response = await fetch(url, {
12
    headers: {
13
      Authorization: `Bearer ${auth.token}`,
14
      Accept: "application/json",
15
    },
16
  })
17

18
  if (!response.ok) {
19
    throw new Error(`${response.status} ${await response.text()}`)
20
  }
21

22
  return await response.json()
23
}
24