0

Update tracking info from specific document.

by
Published Oct 17, 2025

Update tracking info from specific document.

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 tracking info from specific document.
7
 * Update tracking info from specific document.
8
 */
9
export async function main(
10
  auth: Holded,
11
  documentId: string,
12
  docType: string,
13
  body: {
14
    key?: string;
15
    name?: string;
16
    num?: string;
17
    pickUpDate?: string;
18
    deliveryDate?: string;
19
    notes?: string;
20
  },
21
) {
22
  const url = new URL(
23
    `https://api.holded.com/api/invoicing/v1/documents/${docType}/${documentId}/updatetracking`,
24
  );
25

26
  const response = await fetch(url, {
27
    method: "POST",
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