Lists vendors

This endpoint lists all existing vendors for an account. Takes an optional parameter to match by vendor name.

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
Lists vendors 
8

9
 * 
10
This endpoint lists all existing vendors for an account.
11
Takes an optional parameter to match by vendor name.
12

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