0

Update media by ID

by
Published Oct 17, 2025

Updates a media object based on the unique media ID. Any one of the following roles is required for this endpoint: |Legacy Role|Equivalent Permission Set Role| |-----|--------| |org.user.media.write|org.permission.kb.update|

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 media by ID
7
 * Updates a media object based on the unique media ID.
8

9
Any one of the following roles is required for this endpoint:
10

11
|Legacy Role|Equivalent Permission Set Role|
12
|-----|--------|
13
|org.user.media.write|org.permission.kb.update|
14
 */
15
export async function main(
16
  auth: Kustomer,
17
  id: string,
18
  body: { name?: string; redacted?: false | true },
19
) {
20
  const url = new URL(`https://api.kustomerapp.com/v1/media/${id}`);
21

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