List Organization Subscriptions

#### Pagination * Cursor pagination (recommended) * Offset pagination See Pagination. Returns a maximum of 100 records per page. #### Allowed For: * Agents * End users For end users, the response will only list the subscriptions created by the requesting end user.

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
 * List Organization Subscriptions
8
 * #### Pagination
9

10
* Cursor pagination (recommended)
11
* Offset pagination
12

13
See Pagination.
14

15
Returns a maximum of 100 records per page.
16

17
#### Allowed For:
18

19
* Agents
20
* End users
21

22
For end users, the response will only list the subscriptions created by the requesting end user.
23
 */
24
export async function main(auth: Zendesk) {
25
  const url = new URL(
26
    `https://${auth.subdomain}.zendesk.com/api/v2/organization_subscriptions`
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