0

Create Knowledge Base

by
Published Oct 17, 2025

Create a new Knowledge Base resource

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