0

Create Service

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 Service
7
 *
8
 */
9
export async function main(
10
  auth: Holded,
11
  body: {
12
    name?: string;
13
    desc?: string;
14
    tags?: string[];
15
    tax?: number;
16
    subtotal?: number;
17
    salesChannelId?: string;
18
    cost?: number;
19
  },
20
) {
21
  const url = new URL(`https://api.holded.com/api/invoicing/v1/services`);
22

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