Edits history of script submission #16522 for ' Delete Custom Domain (kustomer)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Kustomer = {
      apiKey: string;
    };
    /**
     * Delete Custom Domain
     * Deletes a custom domain.
    
    
    **Note**: If the domain has been issued, this will disable the cloudfront distribution. Set the `domainStatus` to `pendingRemoval`, and create a job to delete the domain once the cloudfront distribution has been fully disabled.
     */
    export async function main(auth: Kustomer, id: string, domainId: string) {
      const url = new URL(
        `https://api.kustomerapp.com/v1/kb/knowledge-bases/${id}/domain/${domainId}`,
      );
    
      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.text();
    }
    

    Submitted by hugo697 235 days ago