Count Organizations

Returns an approximate count of organizations. If the count exceeds 100,000, it is updated every 24 hours. The `refreshed_at` property of the `count` object is a timestamp that indicates when the count was last updated. When the count exceeds 100,000, the `refreshed_at` property may occasionally be null. This indicates that the count is being updated in the background and the `value` property of the `count` object is limited to 100,000 until the update is complete. #### Allowed For * Agents

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
 * Count Organizations
8
 * Returns an approximate count of organizations. If the count exceeds
9
100,000, it is updated every 24 hours.
10

11
The `refreshed_at` property of the `count` object is a timestamp that indicates
12
when the count was last updated.
13

14
When the count exceeds 100,000, the `refreshed_at` property may
15
occasionally be null. This indicates that the count is being
16
updated in the background and the `value` property of the `count` object is limited to
17
100,000 until the update is complete.
18

19
#### Allowed For
20

21
* Agents
22

23
 */
24
export async function main(auth: Zendesk) {
25
  const url = new URL(
26
    `https://${auth.subdomain}.zendesk.com/api/v2/organizations/count`
27
  );
28

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