0

Update booking

by
Published Oct 17, 2025

Update a specific booking. Only the params included in the operation will update the booking.

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 booking
7
 * Update a specific booking.
8

9
Only the params included in the operation will update the booking.
10
 */
11
export async function main(
12
  auth: Holded,
13
  bookingId: string,
14
  body: {
15
    dateTime?: number;
16
    customFields?: { key?: string; value?: string }[];
17
  },
18
) {
19
  const url = new URL(
20
    `https://api.holded.com/api/crm/v1/bookings/${bookingId}`,
21
  );
22

23
  const response = await fetch(url, {
24
    method: "PUT",
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.json();
36
}
37