Webhooks are an easy way to get notifications on events happening asynchronously within Lob's architecture. Some common use cases for integrating webhooks are:
- Sending end users notifications about mail traveling through the postal stream
- Receiving notifications about erroneous scan events, such as "Re-Routed" or "Returned to Sender"
- Downloading PDF previews or thumbnails automatically once they are rendered
- Internal logging and reconciliation
Real-time progress of mail pieces can be accessed through our webhooks feature, an easy way to get notifications on events happening asynchronously on Lob's side. Once webhooks are successfully set up on the dashboard, Lob will "push" you notifications when mail pieces are created, when they receive USPS scans such as "In Local Area" or "Processed for Delivery", or any other event you subscribe to.
Setting up webhooks
To receive webhooks from Lob, you need to create another endpoint on your web server that will accept a POST request with a content type of application/json. There are many ways to go about creating this endpoint, endless ways to implement it, and countless guides that exist already to help get you started with creating one. Here is one such resource.
Keep in mind that it will need to be accessible by us so if there's anything that could prevent Lob from accessing it should be disabled for this endpoint.
Once you have a receiver that’s been set up and at a publicly reachable URL, copy that URL, navigate back to your Lob Dashboard, click the tab for “Webhooks”, then the button for “Create” to create a new webhook.
Next, give your webhook a description, paste the URL into the “URL” field, and select which events you would like to receive.
Lastly, click “Create” at the bottom and you’re done!
Receive webhooks with Zapier
While there is no direct integration for outgoing webhooks to Zapier, there is a way to catch events using a generic webhook configuration if you have a premium subscription with them.
- Start by clicking “Create Zap” from the home page.
- Next, select the option for “Webhooks by Zapier”.
- Then select the Trigger Event for “Catch Hook”.
- Copy the webhook URL.
- Log into Lob and in the Webhooks page, click “Create a new webhook” and paste the url into the “URL” field. Due to the inherent limitations of Zapier, we advise selecting from one form factor (postcards, letters, etc) per Zapier integration. Now click the “Debugger” button.
- Select one of the events you checked and click “Send”, you should see “200 OK” at the bottom.
- Back in Zapier, click “Test Trigger” and you should see your event.
- Now click Continue. At this point, you should select which integration you want to “action” on. Fill required fields, and for ones you would like to map the Lob webhook events to, click the field, select “More Options” and select the option of your choice. In the below image, we have the recipient’s name highlighted for a “name” field.
- Fill out the rest of the fields and you’re almost done! You can then “Test & Review” to go over the parameters of your integration, or “Test & Continue” to proceed. The last thing needed is to “Turn on Zap”, and you’re finished.