0

Get invoice

by
Published Apr 8, 2025

Retrieve a single invoice by its ID. If you want to retrieve the details of an invoice by its invoice number, call the [List invoices](list-invoices) endpoint with the `reference` parameter. > 🔑 Access with > > Access token with **invoices.read**

Script mollie Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Mollie = {
3
  token: string;
4
};
5
/**
6
 * Get invoice
7
 * Retrieve a single invoice by its ID.
8

9
If you want to retrieve the details of an invoice by its invoice number, call the [List invoices](list-invoices) endpoint with the `reference` parameter.
10

11
> 🔑 Access with
12
>
13
> Access token with **invoices.read**
14
 */
15
export async function main(auth: Mollie, id: string) {
16
  const url = new URL(`https://api.mollie.com/v2/invoices/${id}`);
17

18
  const response = await fetch(url, {
19
    method: "GET",
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