Crafting a Great
Webhooks Experience
John Sheehan
CEO, @Runscope
Slide 2
Slide 2 text
No content
Slide 3
Slide 3 text
No content
Slide 4
Slide 4 text
No content
Slide 5
Slide 5 text
No content
Slide 6
Slide 6 text
No content
Slide 7
Slide 7 text
"user defined
callbacks made
with HTTP POST"
Slide 8
Slide 8 text
"Webhooks are the
easiest way to remotely
execute code."
-- Jeff Lindsay once
when we were talking
Slide 9
Slide 9 text
HTTP Push
Notifications
Slide 10
Slide 10 text
A Reverse API
Slide 11
Slide 11 text
Provider makes request to
URL when an event happens.
Consumer sets up a server to
listen for callbacks.
Consumer registers callback
URL with provider.
Slide 12
Slide 12 text
Provider makes request to
URL when an event happens.
Consumer sets up a server to
listen for callbacks.
Consumer registers callback
URL with provider.
Slide 13
Slide 13 text
Provider makes request to
URL when an event happens.
Consumer sets up a server to
listen for callbacks.
Consumer registers callback
URL with provider.
Slide 14
Slide 14 text
No content
Slide 15
Slide 15 text
Implementing
Webhooks
Slide 16
Slide 16 text
url = get_callback_url()
data = get_webhook_payload_json()
try:
resp = requests.post(url, data=data)
if not resp.ok:
_logger.error(resp.content)
except Exception as e:
_logger.error(e)
Slide 17
Slide 17 text
Problem #1:
Error Handling
Slide 18
Slide 18 text
> POST /callback
< 400 Bad Request
Slide 19
Slide 19 text
> POST /callback
< 302 Found
< Location: http://
Slide 20
Slide 20 text
> POST /callback
< 200 OK
< Content-Type: text/plain
<
Slide 21
Slide 21 text
Error Handling
Suggestions
Slide 22
Slide 22 text
Be lenient in what you accept
back if you can reasonably guess.
Retry failed callbacks with
exponential back off.
Decide if redirects are to be
followed or not.
Slide 23
Slide 23 text
Be lenient in what you accept
back if you can reasonably guess.
Retry failed callbacks with
exponential back off.
Decide if redirects are to be
followed or not.
Slide 24
Slide 24 text
Be lenient in what you accept back
if you can reasonably guess.
Retry failed callbacks with
exponential back off.
Decide if redirects are to be
followed or not.
Validate your requests.
Document it well!
Resolve IPs before making
request. Consider proxying.
Consider subscription validation
for high-volume cases.
Slide 39
Slide 39 text
Validate your requests.
Document it well!
Resolve IPs before making
request. Consider proxying.
Consider subscription validation
for high-volume cases.
Slide 40
Slide 40 text
Validate your requests.
Document it well!
Resolve IPs before making
request. Consider proxying.
Consider subscription validation
for high-volume cases.