Webhooks, REST and the Open Web
apiux.com
apiux.com
PuSH solves a couple annoyances with webhooks that comes to my mind:
- Lack of debuggability: the inability to subscribe to events forces me to explicitly set up callback URL(s) on service providers' dashboards or in query strings in requests. IF I managed to set them up correctly, data will come crashing in any day in the future, throwing exceptions, or bouncing on unspecified routes. And all these POST catchers and local tunnels developers play with to get this right in the first place.
- Ad-hoc verification schemes: Every service comes up with their own way of ensuring the data originated from their servers. Signature hashes as 'X-*'-headers, a number of extra fields inside the JSON body, etc.
There are more, but these two has annoyed me for quite some time.
The POST to /subscription line going from left to right is clear. What is the GET request below it, is that another HTTP GET requests or a the response to a POST. If it is a GET why is the arrow going from Server to Client.
Then the response to that GET has a 201 code but that is going from client to Server?
The GET request represents the "webhook request", where the API server makes GET requests to the webhook endpoint. These requests are on-going and regularly occurring as a result of service events.
The dotted arrow at the bottom is the webhook endpoint responding to the webhook request, and many API services treat responses with 2XX code as successful, whereas 4xx and 5xx response codes are unsuccessful. In the event of an unsuccessful webhook request then the API service will make multiple attempts at sending the webhook request.
For example:
* HN comment gets posted
* webhook endpoint receives GET request with related information (eg: user id, username, comment date, comment body)
* webhook endpoint responds with 2XX indicating success
"In addition to these operations, the subscription server may verify the intent of the subscriber by making an HTTP call to the provided callback with the same parameters requested before and an additional hub.challenge that must be echoed back by the subscriber."