0

List records

by
Published Oct 17, 2025

Lists people, company or other records, with the option to filter and sort results. Required scopes: `record_permission:read`, `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 records
7
 * Lists people, company or other records, with the option to filter and sort results.
8

9
Required scopes: `record_permission:read`, `object_configuration:read`.
10
 */
11
export async function main(
12
  auth: Attio,
13
  object: string,
14
  body: {
15
    filter?: {};
16
    sorts?:
17
      | { direction: "asc" | "desc"; attribute: string; field?: string }
18
      | { direction: "asc" | "desc"; path: string[][]; field?: string }[];
19
    limit?: number;
20
    offset?: number;
21
  },
22
) {
23
  const url = new URL(
24
    `https://api.attio.com/v2/objects/${object}/records/query`,
25
  );
26

27
  const response = await fetch(url, {
28
    method: "POST",
29
    headers: {
30
      "Content-Type": "application/json",
31
      Authorization: "Bearer " + auth.token,
32
    },
33
    body: JSON.stringify(body),
34
  });
35
  if (!response.ok) {
36
    const text = await response.text();
37
    throw new Error(`${response.status} ${text}`);
38
  }
39
  return await response.json();
40
}
41