0

Delete Filter By Id

by
Published Oct 17, 2025

Deletes a filter by id. • This endpoint is in **Beta** testing. Please submit any feedback by sending an email to [email protected]. • 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.

Script segment Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Segment = {
3
  token: string;
4
  baseUrl: string;
5
};
6
/**
7
 * Delete Filter By Id
8
 * Deletes a filter by id.
9

10

11

12
• This endpoint is in **Beta** testing.  Please submit any feedback by sending an email to friends@segment.com.
13

14

15

16
• 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.
17

18

19
• When called, this endpoint may generate the `Filter Deleted` event in the audit trail.
20
      
21
 */
22
export async function main(auth: Segment, id: string) {
23
  const url = new URL(`${auth.baseUrl}/filters/${id}`);
24

25
  const response = await fetch(url, {
26
    method: "DELETE",
27
    headers: {
28
      Authorization: "Bearer " + auth.token,
29
    },
30
    body: undefined,
31
  });
32
  if (!response.ok) {
33
    const text = await response.text();
34
    throw new Error(`${response.status} ${text}`);
35
  }
36
  return await response.text();
37
}
38