0

Get organization

by
Published Apr 8, 2025

Retrieve a single organization by its ID. You can normally only retrieve the currently authenticated organization with this endpoint. This is primarily useful for OAuth apps. See also [Get current organization](get-current-organization). If you have a *partner account*', you can retrieve organization details of connected organizations. > 🔑 Access with > > Access token with **organizations.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 organization
7
 * Retrieve a single organization by its ID.
8

9
You can normally only retrieve the currently authenticated organization with this endpoint. This is primarily useful for OAuth apps. See also [Get current organization](get-current-organization).
10

11
If you have a *partner account*', you can retrieve organization details of connected organizations.
12

13
> 🔑 Access with
14
>
15
> Access token with **organizations.read**
16
 */
17
export async function main(
18
  auth: Mollie,
19
  id: string,
20
  testmode: string | undefined,
21
) {
22
  const url = new URL(`https://api.mollie.com/v2/organizations/${id}`);
23
  for (const [k, v] of [["testmode", testmode]]) {
24
    if (v !== undefined && v !== "" && k !== undefined) {
25
      url.searchParams.append(k, v);
26
    }
27
  }
28
  const response = await fetch(url, {
29
    method: "GET",
30
    headers: {
31
      Authorization: "Bearer " + auth.token,
32
    },
33
    body: undefined,
34
  });
35
  if (!response.ok) {
36
    const text = await response.text();
37
    throw new Error(`${response.status} ${text}`);
38
  }
39
  return await response.text();
40
}
41