0

SearchTeamMembers

by
Published Oct 17, 2025

Returns a paginated list of `TeamMember` objects for a business. The list can be filtered by location IDs, `ACTIVE` or `INACTIVE` status, or whether the team member is the Square account owner.

Script square Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Square = {
3
  token: string;
4
};
5
/**
6
 * SearchTeamMembers
7
 * Returns a paginated list of `TeamMember` objects for a business. 
8
The list can be filtered by location IDs, `ACTIVE` or `INACTIVE` status, or whether
9
the team member is the Square account owner.
10
 */
11
export async function main(
12
  auth: Square,
13
  body: {
14
    query?: {
15
      filter?: {
16
        location_ids?: string[];
17
        status?: "ACTIVE" | "INACTIVE";
18
        is_owner?: false | true;
19
      };
20
    };
21
    limit?: number;
22
    cursor?: string;
23
  },
24
) {
25
  const url = new URL(`https://connect.squareup.com/v2/team-members/search`);
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