0

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

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