Create webhooks with API

Evening,

I have done a quick search through the Docs, API Examples and the community forum here and I can’t find the answer to this one…

Is it possible to create a webhook through the API?

The API Docs mention webhooks and where they are in the UI but I want to make a community node for n8n so that we have a trigger node that can be installed and used. Normally the approach for this would be the user would enter their API token, select the events they want to register for then we would use an API call to check if it exists already or make a new webhook that points to an automatically generated URL for the workflow.

If possible I would prefer to use a webhook approach over time based polling as that can lead to missed events.

Let me know if I have missed anything or if anyone wants to chat about it.