//native
type Pandadoc = {
apiKey: string
}
export async function main(
auth: Pandadoc,
body: {
name: string
url: string
payload?: 'metadata' | 'fields' | 'products' | 'tokens' | 'pricing'[]
triggers:
| 'recipient_completed'
| 'document_updated'
| 'document_deleted'
| 'document_state_changed'
| 'document_creation_failed'
| 'quote_updated'[]
}
) {
const url = new URL(`https://api.pandadoc.com/public/v1/webhook-subscriptions`)
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `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 581 days ago