0

Create Theme Draft Revision

by
Published Oct 17, 2025

Creates a Knowledge Base theme revision draft.

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 Theme Draft Revision
7
 * Creates a Knowledge Base theme revision draft.
8
 */
9
export async function main(
10
  auth: Kustomer,
11
  themeId: string,
12
  body:
13
    | {
14
        name: string;
15
        manifest: {
16
          name: string;
17
          label?: string;
18
          description?: string;
19
          enabled?: false | true;
20
          link?: {
21
            label: string;
22
            learnMoreLink?: string;
23
            buttonText?: string;
24
            description?: string;
25
            value: string;
26
          };
27
          variables: {};
28
        }[];
29
        jsxSnippets?: string[];
30
      }
31
    | { duplicateRevisionId: string },
32
) {
33
  const url = new URL(
34
    `https://api.kustomerapp.com/v3/kb/themes/${themeId}/revisions/draft`,
35
  );
36

37
  const response = await fetch(url, {
38
    method: "POST",
39
    headers: {
40
      "Content-Type": "application/json",
41
      Authorization: "Bearer " + auth.apiKey,
42
    },
43
    body: JSON.stringify(body),
44
  });
45
  if (!response.ok) {
46
    const text = await response.text();
47
    throw new Error(`${response.status} ${text}`);
48
  }
49
  return await response.json();
50
}
51