List users

This endpoint lists all users. To find a user id by email, you can filter using the `email` query parameter.

Script brex Verified

by hugo697 ยท 10/17/2025

The script

Submitted by hugo697 Bun
Verified 217 days ago
1
//native
2
type Brex = {
3
  token: string;
4
};
5
/**
6
 * 
7
List users
8

9
 * 
10
This endpoint lists all users. To find a user id by email, you can filter using the `email` query parameter.
11

12
 */
13
export async function main(
14
  auth: Brex,
15
  cursor: string | undefined,
16
  limit: string | undefined,
17
  email: string | undefined,
18
  remote_display_id: string | undefined,
19
  expand__: string | undefined,
20
) {
21
  const url = new URL(`https://platform.brexapis.com/v2/users`);
22
  for (const [k, v] of [
23
    ["cursor", cursor],
24
    ["limit", limit],
25
    ["email", email],
26
    ["remote_display_id", remote_display_id],
27
    ["expand[]", expand__],
28
  ]) {
29
    if (v !== undefined && v !== "" && k !== undefined) {
30
      url.searchParams.append(k, v);
31
    }
32
  }
33
  const response = await fetch(url, {
34
    method: "GET",
35
    headers: {
36
      Authorization: "Bearer " + auth.token,
37
    },
38
    body: undefined,
39
  });
40
  if (!response.ok) {
41
    const text = await response.text();
42
    throw new Error(`${response.status} ${text}`);
43
  }
44
  return await response.json();
45
}
46