0

Create a support ticket attachment

by
Published Oct 17, 2025

Adds a file attachment to an open support ticket on your account. Use an attachment to help customer support resolve your ticket. The file attachment is submitted in the request as `multipart/form-data` type. Accepted file extensions include: `.gif`, `.jpg`, `.jpeg`, `.pjpg`, `.pjpeg`, `.tif`, `.tiff`, `.png`, `.pdf`, or `.txt`. > --- - __OAuth scopes__. ``` account:read_write ``` [Learn more...](https://techdocs.akamai.com/linode-api/reference/get-started#oauth)

Script linode Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Linode = {
3
  token: string;
4
};
5
/**
6
 * Create a support ticket attachment
7
 * Adds a file attachment to an open support ticket on your account. Use an attachment to help customer support resolve your ticket. The file attachment is submitted in the request as `multipart/form-data` type. Accepted file extensions include: `.gif`, `.jpg`, `.jpeg`, `.pjpg`, `.pjpeg`, `.tif`, `.tiff`, `.png`, `.pdf`, or `.txt`.
8

9

10
>
11

12
---
13

14

15
- __OAuth scopes__.
16

17
    ```
18
    account:read_write
19
    ```
20

21
    [Learn more...](https://techdocs.akamai.com/linode-api/reference/get-started#oauth)
22
 */
23
export async function main(
24
  auth: Linode,
25
  apiVersion: "v4" | "v4beta",
26
  ticketId: string,
27
  body: { file: string },
28
) {
29
  const url = new URL(
30
    `https://api.linode.com/${apiVersion}/support/tickets/${ticketId}/attachments`,
31
  );
32

33
  const formData = new FormData();
34
  for (const [k, v] of Object.entries(body)) {
35
    if (v !== undefined && v !== "") {
36
      formData.append(k, String(v));
37
    }
38
  }
39
  const response = await fetch(url, {
40
    method: "POST",
41
    headers: {
42
      Authorization: "Bearer " + auth.token,
43
    },
44
    body: formData,
45
  });
46
  if (!response.ok) {
47
    const text = await response.text();
48
    throw new Error(`${response.status} ${text}`);
49
  }
50
  return await response.json();
51
}
52