Braze

Please use the following as an addendum to the Braze integration documentation for using Lob with Braze.

Step 1

Add Custom Attributes for user mailing address information:

  • address_line1
  • address_line2
  • address_city
  • address_state
  • address_zip
  • address_country

Step 2

Update user profiles with mailing addresses.

Import CSV:

API call:

Anything highlighted is a custom variable that will need to be updated for each customer or use case.

curl -X POST \
  https://rest.iad-01.braze.com/users/track \
  -H 'Content-Type: application/json' \
  -d '{
    "api_key": "Braze_API_Key",
    "attributes": [
      {
          "external_id" : "10142019",
          "address_line1" : "185 BERRY ST STE 6100",
          "address_line2" : null,
          "address_city" : "SAN FRANCISCO",
          "address_state" : "CA",
          "address_zip" : "94107-1741",
          "address_country" : "UNITED STATES"
      }
     ]
   }'

Step 3

Create Webhook Template:

Example Postcard

Compose Tab:

WEBHOOK URL: https://api.lob.com/v1/postcards

REQUEST BODY: Raw Text

{
  "description" : "{{campaign.${name}}}",
    "metadata" : {
        "campaign" : "{{campaign.${name}}}"
    },
    "to" : {
        "name" : "{{${first_name}}} {{${last_name}}}",
        "address_line1" : "{{custom_attribute.${address_line1}}}",
        "address_line2" : "{{custom_attribute.${address_line2}}}",
        "address_city" : "{{custom_attribute.${address_city}}}",
        "address_state" : "{{custom_attribute.${address_state}}}",
        "address_zip" : "{{custom_attribute.${address_zip}}}"
    },
    "from" : "adr_2066448bdef840f1",
    "front" : "tmpl_8b3b1249ede0406",
    "back" : "tmpl_d69077c7be7bd09",
    "merge_variables" : {
        "name" : "{{${first_name}}}"
    }
}

Settings Tab:

Be sure to leave the : after the Lob API key you paste in between the apostrophes.

REQUEST HEADERS:

  • Authorization: Basic {{ 'YOUR_LOB_API_KEY:' | base64_encode }}
  • Content-Type: application/json
  • Idempotency-Key: {{${user_id}}}

HTTP METHOD: POST

Step 4

Test your new Webhook template and check your Lob dashboard to ensure desired results.

Idempotent Requests

  • We have added a feature that will allow you to safely resend the same POST request to /v1/postcards, /v1/letters, or /v1/checks and ensure that duplicate products are not created. To perform an idempotent POST request, you simply need to provide an additional Idempotency-Key header that uniquely identifies that resource (such as the user id in the example above.)
  • This key will expire after 24 hours, meaning if you resend the same request with the same idempotency key after 24 hours, a second resource will be created.
  • https://lob.com/docs#idempotent-requests
  • https://lob.com/resources/guides/general/idempotent-requests

Rate Limiting

Create a postcard

Create a letter