0

Update queue rule

by
Published Oct 17, 2025

Updates a queue rule based on its unique ID.

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 queue rule
7
 * Updates a queue rule based on its unique ID.
8
 */
9
export async function main(
10
  auth: Kustomer,
11
  id: string,
12
  body: {} & {
13
    name?: string;
14
    description?: string;
15
    queueKey?: string;
16
    queue?: string;
17
    criteria?: { and?: {}[]; or?: {}[] };
18
    enabled?: false | true;
19
  },
20
) {
21
  const url = new URL(
22
    `https://api.kustomerapp.com/v1/routing/queue-rules/${id}`,
23
  );
24

25
  const response = await fetch(url, {
26
    method: "PUT",
27
    headers: {
28
      "Content-Type": "application/json",
29
      Authorization: "Bearer " + auth.apiKey,
30
    },
31
    body: JSON.stringify(body),
32
  });
33
  if (!response.ok) {
34
    const text = await response.text();
35
    throw new Error(`${response.status} ${text}`);
36
  }
37
  return await response.json();
38
}
39