//native
type Codat = {
encodedKey: string
}
/**
* Create webhook consumer
* Use the *Create webhook consumer* endpoint to create a new webhook consumer that will listen to messages we send you.
*/
export async function main(
auth: Codat,
body: {
url?: string
disabled?: false | true
eventTypes?: string[]
companyTags?: string[]
}
) {
const url = new URL(`https://api.codat.io/webhooks`)
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