Lob Direct Mail Automation

Lob.com is an online service which one can interact with through their API to send direct mail like letters, postcards, and checks through the mail.

You can access Lob’s services through Braze’s webhook feature and send mail to your users. To get started, sign up for an account on Lob.com and locate your API key in the settings section under your name in the dashboard.

Lob API Key


The HTTP URL to request in the webhook is different for each action you can make to Lob. In this example we will be sending a postcard so the URL is https://api.lob.com/v1/postcards, however, the list of all the HTTP URL endpoints can be found in the Lob documentation.

Lob Endpoints

Request Body

To specify an address in the webhook body requires nested objects, and as such it must be entered as “Raw Text” in JSON format. If you are unfamiliar with the JSON format, an easy way to generate a sample request body is to copy the example CURL requests given on the Lob.com documentation and run it in your terminal (replacing their test API key with yours). Once you run the code in the terminal, go to the Lob.com dashboard and check the “Logs” tab found under the “Requests” title. If the API request worked, you will be able to click on the request and copy the request body into the dashboard. You can then replace the data in the file to fit your desires.

Lob Success Response

Request Headers and Method

Lob’s documentation states that you must include your API key in the header to authorize the request. To do so, simply navigate to the setting section and add a new pair. For an authentication header, set the key to “Authorization”. Lob expects your API key to be base64 encoded, so use the Base64 filter in the header value: Basic APIkey:. You will need to add a “:” to the end of your API key when encoding as Lob expects the password to be left blank. Because the body of the request is in JSON format, you will also need to add a “Content-Type” key with the value “application/json”. The request method for this webhook is POST as specified on Lob’s documentation.

Lob Preview

Preview Your Request

At this point, your campaign should be ready to send. If you run into errors, check the Lob dashboard and the developer console error message logs found in the Braze dashboard. Using these two resources you should be able to troubleshoot and debug your request. For example, the error below is caused by an incorrectly formatted authentication header.

Error Log Message

New Stuff!