Example
Here’s an example that cleans up a webhook handler.TypeScript
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
The legacy app.ts layout is deprecated. New apps use the folder-based layout under src/app/; convert existing apps with the migration guide.
Fires when a connection is removed from an app
// src/app/events/connection-removed.event.ts
import {listWebhookHandlers, deleteWebhookHandler} from "attio/server"
import type {Connection} from "attio/server"
export default async function connectionRemoved({connection}: {connection: Connection}) {
const webhookHandlers = await listWebhookHandlers()
for (const webhookHandler of webhookHandlers) {
const acmeResponse = await fetch(
`https://api.acmeinc.com/api/v1/webhooks${webhookHandler.externalWebhookId}`,
{
method: "DELETE",
headers: {
Authorization: `Bearer ${connection.value}`,
},
},
)
if (!acmeResponse.ok) {
throw new Error("Failed to register webhook")
}
await deleteWebhookHandler(webhookHandler.id)
}
}
Was this page helpful?