0

Create routing user status

by
Published Oct 17, 2025

Creates a new routing user status. Any one of the following roles is required for this endpoint: |Legacy Role|Equivalent Permission Set Role| |-----|--------| |org.admin.routing.write|org.permission.routing_status.create| ||org.permission.routing.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 routing user status
7
 * Creates a new routing user status.
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.routing.write|org.permission.routing_status.create|
14
||org.permission.routing.create|
15
 */
16
export async function main(
17
  auth: Kustomer,
18
  body: {
19
    name: string;
20
    description?: string;
21
    externalId?: string;
22
    enabled?: false | true;
23
    statusType: "unavailable" | "available" | "busy";
24
    selectable?: false | true;
25
  },
26
) {
27
  const url = new URL(`https://api.kustomerapp.com/v1/routing/statuses`);
28

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