0

Update business schedule by ID

by
Published Oct 17, 2025

Modifies a business schedule based on the schedule ID. Any one of the following roles is required for this endpoint: |Legacy Role|Equivalent Permission Set Role| |-----|--------| |org.admin.schedule.write|org.permission.schedule.update|

Script kustomer Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Kustomer = {
3
  apiKey: string;
4
};
5
/**
6
 * Update business schedule by ID
7
 * Modifies a business schedule based on the schedule ID.
8

9
Any one of the following roles is required for this endpoint:
10

11
|Legacy Role|Equivalent Permission Set Role|
12
|-----|--------|
13
|org.admin.schedule.write|org.permission.schedule.update|
14
 */
15
export async function main(
16
  auth: Kustomer,
17
  id: string,
18
  body: {
19
    name: string;
20
    hours: {
21
      "0": number[][];
22
      "1": number[][];
23
      "2": number[][];
24
      "3": number[][];
25
      "4": number[][];
26
      "5": number[][];
27
      "6": number[][];
28
    };
29
    timezone: string;
30
    default: false | true;
31
  },
32
) {
33
  const url = new URL(`https://api.kustomerapp.com/v1/schedules/${id}`);
34

35
  const response = await fetch(url, {
36
    method: "PUT",
37
    headers: {
38
      "Content-Type": "application/json",
39
      Authorization: "Bearer " + auth.apiKey,
40
    },
41
    body: JSON.stringify(body),
42
  });
43
  if (!response.ok) {
44
    const text = await response.text();
45
    throw new Error(`${response.status} ${text}`);
46
  }
47
  return await response.json();
48
}
49