//native
type Ultravox = {
apiKey: string;
};
/**
* Webhooks partial update
*
*/
export async function main(
auth: Ultravox,
webhook_id: string,
body: {
webhookId?: string;
created?: string;
url?: string;
secrets?: string[];
events?: "call.started" | "call.ended"[];
},
) {
const url = new URL(`https://api.ultravox.ai/api/webhooks/${webhook_id}`);
const response = await fetch(url, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
"X-API-Key": auth.apiKey,
},
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 428 days ago