0

List all waitlist entries

by
Published Apr 8, 2025

Retrieve a list of waitlist entries for the instance. Entries are ordered by creation date in descending order by default. Supports filtering by email address or status and pagination with limit and offset parameters.

Script clerk Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Clerk = {
3
  apiKey: string;
4
};
5
/**
6
 * List all waitlist entries
7
 * Retrieve a list of waitlist entries for the instance.
8
Entries are ordered by creation date in descending order by default.
9
Supports filtering by email address or status and pagination with limit and offset parameters.
10
 */
11
export async function main(
12
  auth: Clerk,
13
  limit: string | undefined,
14
  offset: string | undefined,
15
  query: string | undefined,
16
  status: "pending" | "invited" | "completed" | "rejected" | undefined,
17
  order_by: string | undefined,
18
) {
19
  const url = new URL(`https://api.clerk.com/v1/waitlist_entries`);
20
  for (const [k, v] of [
21
    ["limit", limit],
22
    ["offset", offset],
23
    ["query", query],
24
    ["status", status],
25
    ["order_by", order_by],
26
  ]) {
27
    if (v !== undefined && v !== "" && k !== undefined) {
28
      url.searchParams.append(k, v);
29
    }
30
  }
31
  const response = await fetch(url, {
32
    method: "GET",
33
    headers: {
34
      Authorization: "Bearer " + auth.apiKey,
35
    },
36
    body: undefined,
37
  });
38
  if (!response.ok) {
39
    const text = await response.text();
40
    throw new Error(`${response.status} ${text}`);
41
  }
42
  return await response.json();
43
}
44