0

Create Warehouse

by
Published Oct 17, 2025
Script holded Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Holded = {
3
  apiKey: string;
4
};
5
/**
6
 * Create Warehouse
7
 *
8
 */
9
export async function main(
10
  auth: Holded,
11
  body: {
12
    name?: string;
13
    email?: string;
14
    phone?: string;
15
    mobile?: string;
16
    address?: {
17
      address?: string;
18
      city?: string;
19
      postalCode?: string;
20
      province?: string;
21
      country?: string;
22
      countryCode?: string;
23
    };
24
    default?: false | true;
25
  },
26
) {
27
  const url = new URL(`https://api.holded.com/api/invoicing/v1/warehouses`);
28

29
  const response = await fetch(url, {
30
    method: "POST",
31
    headers: {
32
      "Content-Type": "application/json",
33
      key: auth.apiKey,
34
    },
35
    body: JSON.stringify(body),
36
  });
37
  if (!response.ok) {
38
    const text = await response.text();
39
    throw new Error(`${response.status} ${text}`);
40
  }
41
  return await response.json();
42
}
43