0

Update instance organization settings

by
Published Apr 8, 2025

Updates the organization settings of the instance

Script clerk Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Clerk = {
3
  apiKey: string;
4
};
5
/**
6
 * Update instance organization settings
7
 * Updates the organization settings of the instance
8
 */
9
export async function main(
10
  auth: Clerk,
11
  body: {
12
    enabled?: false | true;
13
    max_allowed_memberships?: number;
14
    admin_delete_enabled?: false | true;
15
    domains_enabled?: false | true;
16
    domains_enrollment_modes?: string[];
17
    creator_role_id?: string;
18
    domains_default_role_id?: string;
19
  },
20
) {
21
  const url = new URL(
22
    `https://api.clerk.com/v1/instance/organization_settings`,
23
  );
24

25
  const response = await fetch(url, {
26
    method: "PATCH",
27
    headers: {
28
      "Content-Type": "application/json",
29
      Authorization: "Bearer " + auth.apiKey,
30
    },
31
    body: JSON.stringify(body),
32
  });
33
  if (!response.ok) {
34
    const text = await response.text();
35
    throw new Error(`${response.status} ${text}`);
36
  }
37
  return await response.json();
38
}
39