List Spend Limits

Retrieves a list of Spend Limits

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 Spend Limits
8

9
 * 
10
Retrieves a list of Spend Limits
11

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