0

Update Knowledge Base

by
Published Oct 17, 2025

Update a Knowledge Base resource by 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 Knowledge Base
7
 * Update a Knowledge Base resource by ID
8
 */
9
export async function main(
10
  auth: Kustomer,
11
  id: string,
12
  body: {
13
    name?: string;
14
    noIndex?: false | true;
15
    logo?: string;
16
    favicon?: string;
17
    theme?: string;
18
    baseUrl?: string;
19
    homepageTitle?: string;
20
    includeAllData?: false | true;
21
    defaultLanguage?: string;
22
    languages?: {};
23
    metaTags?: string[];
24
  },
25
) {
26
  const url = new URL(
27
    `https://api.kustomerapp.com/v1/kb/knowledge-bases/${id}`,
28
  );
29

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