June 28, 2022
October 18, 2024
Developers
2 Minutes, 34 Seconds

What are webhooks and how do they work?

Webhooks provide developers with updates about requests made to the Stitch API. Stitch Senior Support Specialist Tobi Fasipe and Head of Customer Solutions Priyen Pillay ...

Tobi Fasipe, Senior Support Specialist
Share this article
What are webhooks and how do they work?

Webhooks provide developers with updates about requests made to the Stitch API. Stitch Senior Support Specialist Tobi Fasipe and Head of Customer Solutions Priyen Pillay walk us through the importance of integrating webhooks to streamline your Stitch experience.

Webhooks offer a way for different applications to speak to one another and provide updates when something new happens or when there has been an update to a request you’ve made. For example, if you get an update from Google Drive via Slack when one of your teammates comments on a Google Doc you created, that’s thanks to webhooks.

There are several requests you can make to the Stitch API, including paymentInitiation, createDisbursement and createRefund, among others. We recommend all developers use webhooks to track their requests as this is the most reliable, scalable and automated means for your servers to be notified about an update to an action that you made. Unlike infinitely polling for updates, webhooks enable you to receive real-time updates and allow you to get notified automatically when a specific event occurs. In practice, webhooks are automated messages sent to your application when there’s a status update to your request.

There are several advantages of using webhooks. For example, webhooks are not impacted by poor connection on your customer’s device or if your customer’s device switches off after a request is sent. In cases where there’s temporary downtime with your server, we have an exponential back-off and retry policy at Stitch that will continue to send you updates until we get a 200 response code, which means that Stitch’s update was received successfully.

In the graphic above, you’ll notice polling involves multiple requests made from your server to the Stitch API, while webhooks only require your server to listen for updates from Stitch. This means that webhooks make it possible for you to get proactive updates as your request goes through different stages. For example, when processing a batch of disbursements, webhooks provide you with updates when instructions are submitted to the bank, when the disbursements are processed by the bank and when funds are cleared by the bank.

Why it’s important to integrate webhooks

We see five major benefits of integrating webhooks:

  1. Webhook updates are automatic and do not require you to make an ad-hoc request. You simply need to listen for a notification from Stitch, which you’ll receive at a URL that you’ve specified
  2. Webhooks provide you with updates as your request goes through different stages, until it reaches its final stage
  3. Webhooks are not rate limited
  4. Webhooks perform efficiently with scale, unlike polling
  5. Webhooks do not rely on browser navigation or constant server availability

How to integrate Stitch webhooks: five steps

  1. Set up your own webhook server (where Stitch will be pinging)
  2. Whitelist Stitch’s IP address (if required)
  3. Get your Stitch Client Token
  4. Use the Stitch API to subscribe to webhooks
  5. Initiate events to test the webhooks (this can be a test payment or refund, for example)

For more information on integrating webhooks, please check out our Developer Docs.