//native
type Codat = {
encodedKey: string
}
/**
* Create webhook
* Create a new webhook configuration
*/
export async function main(
auth: Codat,
body: {
type: string
companyId?: string
notifiers: { emails?: string[]; webhook?: string }
}
) {
const url = new URL(`https://api.codat.io/rules`)
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Basic ${auth.encodedKey}`
},
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