0

Get conversation events

by
Published Oct 17, 2025

Retrieves a paginated list of conversation events based on the unique ID of the conversation. You can use the `name` and/or `changed` query parameters to filter the results. Any one of the following roles is required for this endpoint: |Legacy Role|Equivalent Permission Set Role| |-----|--------| |org.user.event.read|org.permission.event.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 conversation events
7
 * Retrieves a paginated list of conversation events based on the unique ID of the conversation.
8

9
You can use the `name` and/or `changed` query parameters to filter the results.
10

11
Any one of the following roles is required for this endpoint:
12

13
|Legacy Role|Equivalent Permission Set Role|
14
|-----|--------|
15
|org.user.event.read|org.permission.event.read|
16
 */
17
export async function main(
18
  auth: Kustomer,
19
  id: string,
20
  page: string | undefined,
21
  pageSize: string | undefined,
22
  sort: string | undefined,
23
) {
24
  const url = new URL(
25
    `https://api.kustomerapp.com/v1/conversations/${id}/events`,
26
  );
27
  for (const [k, v] of [
28
    ["page", page],
29
    ["pageSize", pageSize],
30
    ["sort", sort],
31
  ]) {
32
    if (v !== undefined && v !== "" && k !== undefined) {
33
      url.searchParams.append(k, v);
34
    }
35
  }
36
  const response = await fetch(url, {
37
    method: "GET",
38
    headers: {
39
      Authorization: "Bearer " + auth.apiKey,
40
    },
41
    body: undefined,
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