Edits history of script submission #16758 for ' Update Web Hook (kustomer)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Kustomer = {
      apiKey: string;
    };
    /**
     * Update Web Hook
     * Updates a web hook based on the ID.
    
    ### Debugging
    Set the debug param to true to enable web hook debugging.  Setting debug to true will enable monitoring of inbound hook transactions for 24 hours.  See Get Web Hook Transactions for more details.
     */
    export async function main(
      auth: Kustomer,
      id: string,
      body: { debug?: false | true; description?: string; title?: string },
    ) {
      const url = new URL(`https://api.kustomerapp.com/v1/hooks/web/${id}`);
    
      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 235 days ago