0

Create client link

by
Published Apr 8, 2025

> 🚧 Open beta > > This feature is currently in open beta, and the final specification may still change.

Script mollie Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Mollie = {
3
  token: string;
4
};
5
/**
6
 * Create client link
7
 * > 🚧 Open beta
8
>
9
> This feature is currently in open beta, and the final specification may still change.
10
 */
11
export async function main(
12
  auth: Mollie,
13
  body: {
14
    resource?: string;
15
    id?: string;
16
    owner: {
17
      email: string;
18
      givenName: string;
19
      familyName: string;
20
      locale?: string;
21
    };
22
    name: string;
23
    address: {
24
      streetAndNumber?: string;
25
      postalCode?: string;
26
      city?: string;
27
      country: string;
28
    };
29
    registrationNumber?: string;
30
    vatNumber?: string;
31
    _links?: {
32
      self?: { href?: string; type?: string };
33
      clientLink?: { href?: string; type?: string };
34
      documentation?: { href?: string; type?: string };
35
    };
36
  },
37
) {
38
  const url = new URL(`https://api.mollie.com/v2/client-links`);
39

40
  const response = await fetch(url, {
41
    method: "POST",
42
    headers: {
43
      "Content-Type": "application/json",
44
      Authorization: "Bearer " + auth.token,
45
    },
46
    body: JSON.stringify(body),
47
  });
48
  if (!response.ok) {
49
    const text = await response.text();
50
    throw new Error(`${response.status} ${text}`);
51
  }
52
  return await response.text();
53
}
54