//native
type Segment = {
token: string;
baseUrl: string;
};
/**
* Create Destination
* Creates a new Destination.
• When called, this endpoint may generate the `Integration Created` event in the audit trail.
*/
export async function main(
auth: Segment,
body: {
sourceId: string;
metadataId: string;
enabled?: false | true;
name?: string;
settings: {};
},
) {
const url = new URL(`${auth.baseUrl}/destinations`);
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