0

Get all business schedules

by
Published Oct 17, 2025

Retrieves 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| To learn more, see [Business Schedules](https://help.kustomer.com/business-schedules-SJj3ZxD1E) in the Kustomer Help Center.

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 all business schedules
7
 * Retrieves 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
To learn more, see [Business Schedules](https://help.kustomer.com/business-schedules-SJj3ZxD1E) in the Kustomer Help Center.
17
 */
18
export async function main(
19
  auth: Kustomer,
20
  page: string | undefined,
21
  pageSize: string | undefined,
22
) {
23
  const url = new URL(`https://api.kustomerapp.com/v1/schedules`);
24
  for (const [k, v] of [
25
    ["page", page],
26
    ["pageSize", pageSize],
27
  ]) {
28
    if (v !== undefined && v !== "" && k !== undefined) {
29
      url.searchParams.append(k, v);
30
    }
31
  }
32
  const response = await fetch(url, {
33
    method: "GET",
34
    headers: {
35
      Authorization: "Bearer " + auth.apiKey,
36
    },
37
    body: undefined,
38
  });
39
  if (!response.ok) {
40
    const text = await response.text();
41
    throw new Error(`${response.status} ${text}`);
42
  }
43
  return await response.json();
44
}
45