Update Organization

#### Allowed For * Admins * Agents Agents with no permissions restrictions can only update "notes" on organizations. **Note:** Updating an organization's `domain_names` property overwrites all existing `domain_names` values. To prevent this, submit a complete list of `domain_names` for the organization in your request. #### Example Request ```js { "organization": { "notes": "Something interesting" } } ```

Script zendesk Verified

by hugo697 ยท 11/7/2023

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 377 days ago
1
type Zendesk = {
2
  username: string;
3
  password: string;
4
  subdomain: string;
5
};
6
/**
7
 * Update Organization
8
 * #### Allowed For
9

10
* Admins
11
* Agents
12

13
Agents with no permissions restrictions can only update "notes" on organizations.
14

15
**Note:** Updating an organization's `domain_names` property overwrites all existing `domain_names` values. To prevent this, submit a complete list of `domain_names` for the organization in your request.
16

17
#### Example Request
18

19
```js
20
{
21
  "organization": {
22
    "notes": "Something interesting"
23
  }
24
}
25
```
26

27
 */
28
export async function main(auth: Zendesk, organization_id: string) {
29
  const url = new URL(
30
    `https://${auth.subdomain}.zendesk.com/api/v2/organizations/${organization_id}`
31
  );
32

33
  const response = await fetch(url, {
34
    method: "PUT",
35
    headers: {
36
      Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
37
    },
38
    body: undefined,
39
  });
40
  if (!response.ok) {
41
    const text = await response.text();
42
    throw new Error(`${response.status} ${text}`);
43
  }
44
  return await response.json();
45
}
46