0

Get media by ID

by
Published Oct 17, 2025

Retrieves a media object that matches the unique ID or an array of media objects (if multiple IDs are given). Any one of the following roles is required for this endpoint: |Legacy Role|Equivalent Permission Set Role| |-----|--------| |org.user.media.read|org.permission.kb.read| |org.user.setting.read|| |org.user.content.kb.read|| |org.user.kb.read|| |org.admin.content.kb.read|| |org.admin.kb.read||

Script kustomer Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Kustomer = {
3
  apiKey: string;
4
};
5
/**
6
 * Get media by ID
7
 * Retrieves a media object that matches the unique ID or an array of media objects (if multiple IDs are given).
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.read|org.permission.kb.read|
14
|org.user.setting.read||
15
|org.user.content.kb.read||
16
|org.user.kb.read||
17
|org.admin.content.kb.read||
18
|org.admin.kb.read||
19
 */
20
export async function main(auth: Kustomer, id: string) {
21
  const url = new URL(`https://api.kustomerapp.com/v1/media/${id}`);
22

23
  const response = await fetch(url, {
24
    method: "GET",
25
    headers: {
26
      Authorization: "Bearer " + auth.apiKey,
27
    },
28
    body: undefined,
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