Edits history of script submission #12066 for ' Update instance organization settings (clerk)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Clerk = {
      apiKey: string;
    };
    /**
     * Update instance organization settings
     * Updates the organization settings of the instance
     */
    export async function main(
      auth: Clerk,
      body: {
        enabled?: false | true;
        max_allowed_memberships?: number;
        admin_delete_enabled?: false | true;
        domains_enabled?: false | true;
        domains_enrollment_modes?: string[];
        creator_role_id?: string;
        domains_default_role_id?: string;
      },
    ) {
      const url = new URL(
        `https://api.clerk.com/v1/instance/organization_settings`,
      );
    
      const response = await fetch(url, {
        method: "PATCH",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.apiKey,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 428 days ago