Archive a Spend Limit
One script reply has been approved by the moderators Verified

Archives a Spend Limit, making it unusable for future expenses and removing it from the UI

Created by hugo697 170 days ago Picked 1 time
Submitted by hugo697 Bun
Verified 170 days ago
1
//native
2
type Brex = {
3
  token: string;
4
};
5
/**
6
 * 
7
Archive a Spend Limit
8

9
 * 
10
Archives a Spend Limit, making it unusable for future expenses and removing it from the UI
11

12
 */
13
export async function main(auth: Brex, id: string) {
14
  const url = new URL(
15
    `https://platform.brexapis.com/v2/spend_limits/${id}/archive`,
16
  );
17

18
  const response = await fetch(url, {
19
    method: "POST",
20
    headers: {
21
      Authorization: "Bearer " + auth.token,
22
    },
23
    body: undefined,
24
  });
25
  if (!response.ok) {
26
    const text = await response.text();
27
    throw new Error(`${response.status} ${text}`);
28
  }
29
  return await response.text();
30
}
31