0

Update Revision Theme File

by
Published Oct 17, 2025

Updates theme files based on the revision 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 Revision Theme File
7
 * Updates theme files based on the revision ID.
8
 */
9
export async function main(
10
  auth: Kustomer,
11
  themeId: string,
12
  revisionId: string,
13
  id: string,
14
  body: {
15
    name: string;
16
    type: "page" | "component" | "asset";
17
    content?: string;
18
    snippets?: string[];
19
  },
20
) {
21
  const url = new URL(
22
    `https://api.kustomerapp.com/v3/kb/themes/${themeId}/revisions/${revisionId}/files/${id}`,
23
  );
24

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