0

Get attachments by ID [Outbound Only]

by
Published Oct 17, 2025

Retrieves attachments using the unique ID of the attachment or an array of unique attachment IDs, if given. Any one of the following roles is required for this endpoint: |Legacy Role|Equivalent Permission Set Role| |-----|--------| |org.user.attachment.read|org.permission.attachment.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 attachments by ID [Outbound Only]
7
 * Retrieves attachments using the unique ID of the attachment or an array of unique attachment IDs, if 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.attachment.read|org.permission.attachment.read|
14
 */
15
export async function main(auth: Kustomer, id: string) {
16
  const url = new URL(`https://api.kustomerapp.com/v1/attachments/${id}`);
17

18
  const response = await fetch(url, {
19
    method: "GET",
20
    headers: {
21
      Authorization: "Bearer " + auth.apiKey,
22
    },
23
    body: undefined,
24
  });
25
  if (!response.ok) {
26
    const text = await response.text();
27
    throw new Error(`${response.status} ${text}`);
28
  }
29
  return await response.json();
30
}
31