Using webhooks #70569
Unanswered
jhosman
asked this question in
API and Webhooks
Using webhooks
#70569
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Have you been hearing a lot about webhooks, but you’re not sure how or when to use them? Are you wondering what the difference is between using webhooks or polling the API? Are you curious about how to set up and use GitHub’s webhooks most efficiently with your tools and systems?
You’re in the right place! Let’s take a closer look at what webhooks are, and how you can use them to build out your tools and streamline your processes.
A brief intro to webhooks
Webhooks are essentially a way to subscribe your server to receive notifications from GitHub whenever certain events occur. You can configure your server to listen for these events and take certain actions whenever it receives them.
You can integrate webhooks into your tools and systems in many different ways, depending on your needs. For example, you could use incoming webhook notifications to trigger other processes, like deploying to production or triggering CI (continuous integration) whenever code is pushed to a particular branch in a repository. Or you could use webhooks to log certain events as they happen on GitHub, or send information about events to other platforms, like Jira, Slack, or Discord.
Learn more about how to create webhooks, and how to write code to process incoming webhook deliveries on your server:
Webhooks or the API - What’s the difference?
In many scenarios, subscribing to a webhook event is much more efficient than using the API to retrieve the same information. You can subscribe to a webhook once, and then sit back and wait. Whenever the event occurs, GitHub will automatically send a notification to the URL you specified.
Using the API in this same scenario, your server would have to continuously poll an endpoint to check if any new data is available. So there would be a gap in time between when the event happens and when your server learns that it happened. Polling the API is also more resource intensive for your server, and if you poll too often you may exceed the API rate limit quota.
Use webhooks like a pro
To use webhooks safely and efficiently you should:
Follow best practices for webhooks. For example, you can use a webhook secret to verify that incoming webhooks are coming from GitHub. For more examples of best practices, see "Best practices for using webhooks."
Set up your server to handle failed webhook deliveries. GitHub doesn't automatically redeliver failed webhook deliveries. For more information, see "Handling failed webhook deliveries."
Learn how to test and troubleshoot webhooks. For more information, see "Testing and troubleshooting webhooks."
Want to learn even more about webhooks?
Check out the newly revised webhook documentation, to learn more about using webhooks on GitHub.
Share with the community
How are you using webhooks? Do you have an idea for how you’d like to use webhooks to accomplish a task or streamline your process? Did you set up an integration with GitHub’s webhooks that you’re particularly proud of? Share with the community in the comments!
Beta Was this translation helpful? Give feedback.
All reactions