0

List statuses

by
Published Oct 17, 2025

Lists all statuses for a particular status attribute on either an object or a list. Required scopes: `object_configuration:read`.

Script attio Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Attio = {
3
  token: string;
4
};
5
/**
6
 * List statuses
7
 * Lists all statuses for a particular status 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: "lists" | "objects",
14
  identifier: string,
15
  attribute: string,
16
  show_archived: string | undefined,
17
) {
18
  const url = new URL(
19
    `https://api.attio.com/v2/${target}/${identifier}/attributes/${attribute}/statuses`,
20
  );
21
  for (const [k, v] of [["show_archived", show_archived]]) {
22
    if (v !== undefined && v !== "" && k !== undefined) {
23
      url.searchParams.append(k, v);
24
    }
25
  }
26
  const response = await fetch(url, {
27
    method: "GET",
28
    headers: {
29
      Authorization: "Bearer " + auth.token,
30
    },
31
    body: undefined,
32
  });
33
  if (!response.ok) {
34
    const text = await response.text();
35
    throw new Error(`${response.status} ${text}`);
36
  }
37
  return await response.json();
38
}
39