How to use webhooks handlers to receive HTTP requests from external services
.webhook.ts
suffix.src/webhooks
directory, and it must export default
an async function.Request
argument
and must return an HTTP Response
.Response
object, the App SDK will respond with a 500 status code by default.
Defining a webhook handler isn’t enough to make it usable. You’ll need to enable it programmatically and register it with the third-party service.
You can do this from any server function, but most of the time you’ll want to do it inside the connection-added
event.
The connection-added
event runs whenever an Attio user connects to a third-party service through your app.
If your event handler completes without throwing an error, the connection will be saved.
If it throws, the user will be asked to authenticate again.
connection-added
events carefully. If something goes wrong, users won’t
be able to connect to third-party services.connection-added
event handler to our app.
src/events/connection-added.event.ts
export default
an async function that takes a { connection: Connection }
argument.prospect-updated
webhook handler will be called.
externalWebhookId
to delete the webhook from the third-party service when the
connection is removed inside the connection-removed
event.