Edits history of script submission #12025 for ' Remove a domain from an organization. (clerk)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Clerk = {
      apiKey: string;
    };
    /**
     * Remove a domain from an organization.
     * Removes the given domain from the organization.
     */
    export async function main(
      auth: Clerk,
      organization_id: string,
      domain_id: string,
    ) {
      const url = new URL(
        `https://api.clerk.com/v1/organizations/${organization_id}/domains/${domain_id}`,
      );
    
      const response = await fetch(url, {
        method: "DELETE",
        headers: {
          Authorization: "Bearer " + auth.apiKey,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 428 days ago