Update Account Settings
One script reply has been approved by the moderators Verified

Updates settings for the account. See JSON Format above for the settings you can update.

Allowed For

  • Admins
Created by hugo697 844 days ago
Submitted by hugo697 Typescript (fetch-only)
Verified 298 days ago
1
type Zendesk = {
2
  username: string;
3
  password: string;
4
  subdomain: string;
5
};
6
/**
7
 * Update Account Settings
8
 * Updates settings for the account. See [JSON Format](#json-format) above for the settings you can update.
9

10
#### Allowed For
11

12
* Admins
13

14
 */
15
export async function main(auth: Zendesk) {
16
  const url = new URL(
17
    `https://${auth.subdomain}.zendesk.com/api/v2/account/settings`
18
  );
19

20
  const response = await fetch(url, {
21
    method: "PUT",
22
    headers: {
23
      Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
24
    },
25
    body: undefined,
26
  });
27
  if (!response.ok) {
28
    const text = await response.text();
29
    throw new Error(`${response.status} ${text}`);
30
  }
31
  return await response.json();
32
}
33