Get an attribute
One script reply has been approved by the moderators Verified

Gets information about a single attribute on either an object or a list.

Required scopes: object_configuration:read.

Created by hugo697 51 days ago
Submitted by hugo697 Bun
Verified 51 days ago
1
//native
2
type Attio = {
3
  token: string;
4
};
5
/**
6
 * Get an attribute
7
 * Gets information about a single attribute on either an object or a list.
8

9
Required scopes: `object_configuration:read`.
10
 */
11
export async function main(
12
  auth: Attio,
13
  target: "objects" | "lists",
14
  identifier: string,
15
  attribute: string,
16
) {
17
  const url = new URL(
18
    `https://api.attio.com/v2/${target}/${identifier}/attributes/${attribute}`,
19
  );
20

21
  const response = await fetch(url, {
22
    method: "GET",
23
    headers: {
24
      Authorization: "Bearer " + auth.token,
25
    },
26
    body: undefined,
27
  });
28
  if (!response.ok) {
29
    const text = await response.text();
30
    throw new Error(`${response.status} ${text}`);
31
  }
32
  return await response.json();
33
}
34