0

Update Product

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 Product
7
 *
8
 */
9
export async function main(
10
  auth: Holded,
11
  productId: string,
12
  body: {
13
    kind?: string;
14
    name?: string;
15
    desc?: string;
16
    tax?: number;
17
    subtotal?: number;
18
    barcode?: string;
19
    sku?: string;
20
    cost?: number;
21
    purchasePrice?: number;
22
    weight?: number;
23
  },
24
) {
25
  const url = new URL(
26
    `https://api.holded.com/api/invoicing/v1/products/${productId}`,
27
  );
28

29
  const response = await fetch(url, {
30
    method: "PUT",
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