DEV Community

Nasrul Hazim Bin Mohamad
Nasrul Hazim Bin Mohamad

Posted on

Webhook - Part I

The Definition of Webhook

A webhook in web development is a method of augmenting or altering the behavior of a web page or web application with custom callbacks.

These callbacks may be maintained, modified, and managed by third-party users and developers who may not necessarily be affiliated with the originating website or application. The term "webhook" was coined by Jeff Lindsay in 2007 from the computer programming term hook.

The format is usually JSON. The request is done as a HTTP POST request. Reference as in Wikipedia

TLDR;

In this post, I will share how you can create your own Webhook and use it in your other application.

Assuming now, you have multiple application, each of it has responsibilities to share their own data via Webhook.

I will use the term Webhook Provider - as the application that provide data to other application and Webhook Consumer, which application that receive data from Webhook Provider.

Webhook Provider

The provider usually require to send data to an endpoint. But in webhook context, we need to make it data in consistent format and secure when sending them to an endpoint.

Following are some of the Webhook provider:

  1. Github
  2. Stripe
  3. ClickUp
  4. Facebook

Keywords:

  • data in consistent format: JSON
  • secure: HTTPS endpoint + Signature

Webhook Consumer

The consumer usually will provide an endpoint which the Webhook Provider will call the endpoint, using POST method.

Upon receiving the data, which usually called payload, the consumer require to validate the signature sent by the Webhook Provider.

The payload usually in JSON format.

This to ensure that only a valid payload received on the consumer side. To validate, usually the provider will send together in the header, the signature of the webhook.

Keywords:

  • data aka payload, in JSON format
  • validate the incoming Payload based on given signature.

On the next post, we will setup a simple Webhook Provider.

Top comments (0)