Edits history of script submission #12067 for ' Update instance restrictions (clerk)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Clerk = {
      apiKey: string;
    };
    /**
     * Update instance restrictions
     * Updates the restriction settings of an instance
     */
    export async function main(
      auth: Clerk,
      body: {
        allowlist?: false | true;
        blocklist?: false | true;
        block_email_subaddresses?: false | true;
        block_disposable_email_domains?: false | true;
        ignore_dots_for_gmail_addresses?: false | true;
      },
    ) {
      const url = new URL(`https://api.clerk.com/v1/instance/restrictions`);
    
      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