<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: David Multer</title>
    <description>The latest articles on DEV Community by David Multer (@dmulter).</description>
    <link>https://dev.to/dmulter</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F36082%2Fd4990cc3-8e93-4f0f-bfb0-4652c31d7402.jpeg</url>
      <title>DEV Community: David Multer</title>
      <link>https://dev.to/dmulter</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dmulter"/>
    <language>en</language>
    <item>
      <title>What's in a webhook request?</title>
      <dc:creator>David Multer</dc:creator>
      <pubDate>Fri, 29 Mar 2019 00:53:10 +0000</pubDate>
      <link>https://dev.to/dmulter/what-s-in-a-webhook-request-36bh</link>
      <guid>https://dev.to/dmulter/what-s-in-a-webhook-request-36bh</guid>
      <description>&lt;p&gt;Webhooks are a simple, yet powerful approach for delivering event notifications to your application. In this article, I will focus on the aspect of webhooks that is most meaningful to you as an application developer, the &lt;strong&gt;payload&lt;/strong&gt;. The payload contains data fields that convey the meaning of an event. These fields are typically sent in the body of a webhook HTTP request.&lt;/p&gt;

&lt;p&gt;The exact format of this payload is entirely up to the source that sends you the webhook request. The most important data field describes the &lt;em&gt;type&lt;/em&gt; of event that occurred. A service that handles mailing lists might include event types like &lt;em&gt;subscribed&lt;/em&gt;, &lt;em&gt;unsubscribed&lt;/em&gt;, and &lt;em&gt;sent email&lt;/em&gt;. Each of these events would then include additional fields to identify a subscriber, delivery details, and so on. The type of event can be indicated in many ways, but is most clearly described when it follows a &lt;em&gt;noun.verb&lt;/em&gt; format.&lt;/p&gt;

&lt;p&gt;Here's an example from the Stripe API documentation. Note the &lt;code&gt;type&lt;/code&gt; field with a value of &lt;code&gt;invoice.created&lt;/code&gt;. The event name follows the &lt;em&gt;noun.verb&lt;/em&gt; format, making the intent of the event crystal clear.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"evt_1CiPtv2eZvKYlo2CcUZsDcO6"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"created"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1530291411&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"invoice.created"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Events often include fields that are shared across multiple event types. The event type I just described is one example of a common field. Another common field you often find is used to represent the date and time that the event was generated. This &lt;em&gt;timestamp&lt;/em&gt; can be represented in a variety of formats, timezones, and different levels of precision. The timestamp can be used to help identify duplicate events and ensure the correct ordering of events. Some events also include an &lt;em&gt;identifier (ID)&lt;/em&gt; field to uniquely identify every event. This can be used as a more precise way to eliminate duplicate events.&lt;/p&gt;

&lt;p&gt;Looking again at the Stripe example, you'll find the &lt;code&gt;id&lt;/code&gt; and &lt;code&gt;created&lt;/code&gt; fields provide both ID and timestamp values. The timestamp is in &lt;a href="https://en.wikipedia.org/wiki/Unix_time"&gt;UNIX Epoch time&lt;/a&gt; seconds format. Often you'll find the time specified as a string in &lt;a href="https://en.wikipedia.org/wiki/ISO_8601"&gt;ISO-8601&lt;/a&gt; format as well.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"evt_1CiPtv2eZvKYlo2CcUZsDcO6"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"created"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1530291411&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"invoice.created"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In a few cases, you can control the fields that are sent in the payload. Datadog allows full configuration of custom payloads with whatever fields and values you like. Zendesk and Leanplum have standard event types that also let you configure additional custom fields.&lt;/p&gt;

&lt;p&gt;The content type used in the HTTP request will affect the structure of the payload. The most common format you'll find is &lt;a href="https://en.wikipedia.org/wiki/JSON"&gt;JSON&lt;/a&gt;, which is very simple to process in a variety of application programming languages. A less common format is &lt;a href="https://en.wikipedia.org/wiki/Percent-encoding#The_application/x-www-form-urlencoded_type"&gt;HTML form URL encoded&lt;/a&gt; data. You'll need to decode key/value pairs for each type of event in this case. You might find the content encoded using &lt;a href="https://en.wikipedia.org/wiki/XML"&gt;XML&lt;/a&gt; in rare cases. You'll need to use XML parsing libraries specific to your application programming language for these payloads.&lt;/p&gt;

&lt;p&gt;Most payloads will be relatively small and convey the critical information you need to process a specific event. Other webhook sources expect you to make additional API requests to their service to collect more details related to the event. In a few rare cases, you'll want to take special care when the payload size becomes very large. A few of these webhook sources can include file attachments directly in the payload that can be many megabytes in size.&lt;/p&gt;

&lt;p&gt;The payload for most webhook requests contains a single event. A few webhook sources will batch these events into a single webhook payload. Batched events can help save you from a flood of HTTP requests when many events are sent at a time, but it then becomes your responsibility to handle processing for all events. Acknowledging a batched request lets the webhook source know that you have taken on this responsibility. Typically the payload will have a list of events in the webhook payload.&lt;/p&gt;

&lt;p&gt;Here's an example of batched events from Mailjet. The &lt;code&gt;event&lt;/code&gt; field is used to identify the event type, the &lt;code&gt;time&lt;/code&gt; field is in UNIX Epoch time format, and the &lt;code&gt;MessageID&lt;/code&gt; field is unique for every event.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"event"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"open"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"time"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1552244670&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"MessageID"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;456&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"event"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"open"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"time"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1552244731&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"MessageID"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;457&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You should find detailed developer documentation on the webhook source website explaining exactly how they handle all the payload topics I've covered in this article. Be aware that it can be challenging to track down and understand all these details for each webhook source and the events they support.&lt;/p&gt;

&lt;p&gt;Hookalu is here to help you tackle webhook complexity so you can focus on delivering business value to your customers.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Originally published at &lt;em&gt;&lt;a href="https://hookalu.com/blog/whats-in-a-webhook-request/"&gt;hookalu.com&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>webhooks</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>What are webhooks?</title>
      <dc:creator>David Multer</dc:creator>
      <pubDate>Sun, 17 Mar 2019 23:35:08 +0000</pubDate>
      <link>https://dev.to/dmulter/what-are-webhooks-4eip</link>
      <guid>https://dev.to/dmulter/what-are-webhooks-4eip</guid>
      <description>&lt;p&gt;Ever since Jack Lindsay originally coined the term &lt;strong&gt;webhook&lt;/strong&gt; in 2007, people have been writing articles trying to answer the question &lt;em&gt;What is a webhook?&lt;/em&gt; It may seem a complex question to answer, but understanding webhooks is actually much easier to grasp than you might think. Most great ideas in software come from simple and flexible ideas in real life. The same holds true for webhooks. So let me start with something we all can relate to.&lt;/p&gt;

&lt;p&gt;Everyone loves to eat out at a restaurant at least once in while. Restaurants provide a service where customers can enjoy a (hopefully) great meal. Every restaurant offers their own unique combination of food, setting, atmosphere, and service hoping to gain you as a customer. The great restaurants work hard to make the experience so good, you can't wait to come again. &lt;/p&gt;

&lt;p&gt;One experience that is common to nearly every restaurant is how you are seated at a table. You walk in the door and expect to leave your information including your name, number of people in your party, and maybe a phone number. In return, you immediately hear when your table is ready. Whether you are notified by simply hearing your name called out, a buzz from a paging coaster, or a text message on your phone, you expect fast notification regarding the status of your request for a table.&lt;/p&gt;

&lt;p&gt;Let's look at the steps that are essential to a great experience in such an exchange.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;First you need to register your intent to receive a notification from the restaurant when your table is ready. This registration must include some minimum information that lets the restaurant host know how to contact you.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Second you must receive the promised notification message from the restaurant that your table is ready.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Finally the restaurant expects you to return to the host and let them know you received the notification and are ready to eat!&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is basically all you need to know to understand webhooks. A web application or service is the same as the restaurant. Each one is trying to win you as a customer. Many of these web services offer methods for customers to register for event notifications that provide even more possibilities than letting you know your table is ready.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;You must first &lt;strong&gt;register&lt;/strong&gt; a public URL endpoint with the service to receive notifications. This is how the service knows how to contact you.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The service will send an HTTP request to your URL endpoint with a specific message containing details of the event. The specific details of the event are often referred to as the &lt;strong&gt;payload&lt;/strong&gt;. You must provide the business logic (code) that understands how to handle the event.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You acknowledge successful receipt of the event in your response to the HTTP event request. This is typically communicated via a &lt;strong&gt;status code&lt;/strong&gt; in your response.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;When we talk about webhooks, we are talking about the two parties (service and customer) along with the steps in this exchange. Webhooks are a simple and flexible idea built on the powerful foundation of the Web.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://hookalu.com/blog/what-are-webhooks/"&gt;hookalu.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>webhooks</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
