Create a new receipt match
One script reply has been approved by the moderators Verified

The uri will be a pre-signed S3 URL allowing you to upload the receipt securely.

Created by hugo697 170 days ago
Submitted by hugo697 Bun
Verified 170 days ago
1
//native
2
type Brex = {
3
  token: string;
4
};
5
/**
6
 * Create a new receipt match
7
 * 
8
The `uri` will be a pre-signed S3 URL allowing you to upload the receipt securely.
9
 */
10
export async function main(auth: Brex, body: { receipt_name: string }) {
11
  const url = new URL(
12
    `https://platform.brexapis.com/v1/expenses/card/receipt_match`,
13
  );
14

15
  const response = await fetch(url, {
16
    method: "POST",
17
    headers: {
18
      "Content-Type": "application/json",
19
      Authorization: "Bearer " + auth.token,
20
    },
21
    body: JSON.stringify(body),
22
  });
23
  if (!response.ok) {
24
    const text = await response.text();
25
    throw new Error(`${response.status} ${text}`);
26
  }
27
  return await response.json();
28
}
29