0

Get default business schedule

by
Published Oct 17, 2025

Retrieves default business schedules for a Kustomer organization. Any one of the following roles is required for this endpoint: |Legacy Role|Equivalent Permission Set Role| |-----|--------| |org.user.schedule.read|org.permission.schedule.read| |org.admin.schedule.read||

Script kustomer Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Kustomer = {
3
  apiKey: string;
4
};
5
/**
6
 * Get default business schedule
7
 * Retrieves default business schedules for a Kustomer organization.
8

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

11
|Legacy Role|Equivalent Permission Set Role|
12
|-----|--------|
13
|org.user.schedule.read|org.permission.schedule.read|
14
|org.admin.schedule.read||
15
 */
16
export async function main(auth: Kustomer, include: string | undefined) {
17
  const url = new URL(`https://api.kustomerapp.com/v1/schedules/default`);
18
  for (const [k, v] of [["include", include]]) {
19
    if (v !== undefined && v !== "" && k !== undefined) {
20
      url.searchParams.append(k, v);
21
    }
22
  }
23
  const response = await fetch(url, {
24
    method: "GET",
25
    headers: {
26
      Authorization: "Bearer " + auth.apiKey,
27
    },
28
    body: undefined,
29
  });
30
  if (!response.ok) {
31
    const text = await response.text();
32
    throw new Error(`${response.status} ${text}`);
33
  }
34
  return await response.json();
35
}
36