0

Remove Filter from Destination

by
Published Oct 17, 2025

Deletes a Destination filter. • When called, this endpoint may generate the `Destination 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
 * Remove Filter from Destination
8
 * Deletes a Destination filter.
9

10

11

12
• When called, this endpoint may generate the `Destination Filter Deleted` event in the audit trail.
13
      
14
 */
15
export async function main(
16
  auth: Segment,
17
  destinationId: string,
18
  filterId: string,
19
) {
20
  const url = new URL(
21
    `${auth.baseUrl}/destination/${destinationId}/filters/${filterId}`,
22
  );
23

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