0

Get a list of SAML Connections for an instance

by
Published Apr 8, 2025

Returns the list of SAML Connections for an instance. Results can be paginated using the optional `limit` and `offset` query parameters. The SAML Connections are ordered by descending creation date and the most recent will be returned first.

Script clerk Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Clerk = {
3
  apiKey: string;
4
};
5
/**
6
 * Get a list of SAML Connections for an instance
7
 * Returns the list of SAML Connections for an instance.
8
Results can be paginated using the optional `limit` and `offset` query parameters.
9
The SAML Connections are ordered by descending creation date and the most recent will be returned first.
10
 */
11
export async function main(
12
  auth: Clerk,
13
  limit: string | undefined,
14
  offset: string | undefined,
15
  organization_id: string | undefined,
16
) {
17
  const url = new URL(`https://api.clerk.com/v1/saml_connections`);
18
  for (const [k, v] of [
19
    ["limit", limit],
20
    ["offset", offset],
21
    ["organization_id", organization_id],
22
  ]) {
23
    if (v !== undefined && v !== "" && k !== undefined) {
24
      url.searchParams.append(k, v);
25
    }
26
  }
27
  const response = await fetch(url, {
28
    method: "GET",
29
    headers: {
30
      Authorization: "Bearer " + auth.apiKey,
31
    },
32
    body: undefined,
33
  });
34
  if (!response.ok) {
35
    const text = await response.text();
36
    throw new Error(`${response.status} ${text}`);
37
  }
38
  return await response.json();
39
}
40