0

Create a business schedule

by
Published Oct 17, 2025

Creates a new business schedule. Any one of the following roles is required for this endpoint: |Legacy Role|Equivalent Permission Set Role| |-----|--------| |org.admin.schedule.write|org.permission.schedule.create|

Script kustomer Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Kustomer = {
3
  apiKey: string;
4
};
5
/**
6
 * Create a business schedule
7
 * Creates a new business schedule.
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.create|
14
 */
15
export async function main(
16
  auth: Kustomer,
17
  body: {
18
    name: string;
19
    hours: {
20
      "0": number[][];
21
      "1": number[][];
22
      "2": number[][];
23
      "3": number[][];
24
      "4": number[][];
25
      "5": number[][];
26
      "6": number[][];
27
    };
28
    timezone: string;
29
    default: false | true;
30
  },
31
) {
32
  const url = new URL(`https://api.kustomerapp.com/v1/schedules`);
33

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