Edits history of script submission #20014 for ' Delete Filter By Id (segment)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Segment = {
      token: string;
      baseUrl: string;
    };
    /**
     * Delete Filter By Id
     * Deletes a filter by id.
    
    
    
    • This endpoint is in **Beta** testing.  Please submit any feedback by sending an email to friends@segment.com.
    
    
    
    • In order to successfully call this endpoint, the specified Workspace needs to have the Space Filters feature enabled. Please reach out to your customer success manager for more information.
    
    
    • When called, this endpoint may generate the `Filter Deleted` event in the audit trail.
          
     */
    export async function main(auth: Segment, id: string) {
      const url = new URL(`${auth.baseUrl}/filters/${id}`);
    
      const response = await fetch(url, {
        method: "DELETE",
        headers: {
          Authorization: "Bearer " + auth.token,
        },
        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