//native
type Segment = {
token: string;
baseUrl: string;
};
/**
* Create Filter for Destination
* Creates a filter in a Destination.
• When called, this endpoint may generate the `Destination Filter Created` event in the audit trail.
*/
export async function main(
auth: Segment,
destinationId: string,
body: {
sourceId: string;
if: string;
actions: {
type: "ALLOW_PROPERTIES" | "DROP" | "DROP_PROPERTIES" | "SAMPLE";
fields?: {};
percent?: number;
path?: string;
}[];
title: string;
description?: string;
enabled: false | true;
},
) {
const url = new URL(
`${auth.baseUrl}/destination/${destinationId}/filters`,
);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
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