0

Update search positions

by
Published Oct 17, 2025

Updates the order in which searches and folders display for the entire organization. Note that folders cannot be placed into other folders. Folders and searches cannot be removed or added from this endpoint, only reordered. #### NOTE > Requires **org.admin** privileges

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 search positions
7
 * Updates the order in which searches and folders display for the entire organization.
8

9
Note that folders cannot be placed into other folders. Folders and searches cannot be removed or added from this endpoint, only reordered.
10

11
#### NOTE
12
> Requires **org.admin** privileges
13
 */
14
export async function main(
15
  auth: Kustomer,
16
  body: {
17
    positions:
18
      | { type: "search"; id: string }
19
      | {
20
          type: "folder";
21
          id: string;
22
          children?: { type: "search"; id: string }[];
23
        }[];
24
    rev?: number;
25
  },
26
) {
27
  const url = new URL(
28
    `https://api.kustomerapp.com/v1/customers/searches/positions`,
29
  );
30

31
  const response = await fetch(url, {
32
    method: "PUT",
33
    headers: {
34
      "Content-Type": "application/json",
35
      Authorization: "Bearer " + auth.apiKey,
36
    },
37
    body: JSON.stringify(body),
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