//native
type Segment = {
token: string;
baseUrl: string;
};
/**
* Remove Write Key from Source
* Removes a Write Key from a Source.
• When called, this endpoint may generate the `Source Modified` event in the audit trail.
*/
export async function main(auth: Segment, sourceId: string, writeKey: string) {
const url = new URL(
`${auth.baseUrl}/sources/${sourceId}/writekey/${writeKey}`,
);
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