Making an API Call

Messages sent by Braze can retrieve content from a web server to be included in a message by using the {% connected_content %} tag. For example, the following message body will access the url http://numbersapi.com/random/trivia and include a fun trivia fact in your message:

1
Hi there, here is fun some trivia for you!: {% connected_content http://numbersapi.com/random/trivia %}

You can also include user profile attributes as variables in the URL string when making Connected Content requests. As an example, you may have a web service that returns content based on a user’s email address and ID. If you’re passing attributes containing special characters, such as @, make sure to use the Liquid filter url_param_escape to replace any characters not allowed in URLs with their URL-friendly escaped versions, as shown in the e-mail address attribute below.

1
2
3
Hi, here are some articles that you might find interesting:

{% connected_content http://www.yourwebsite.com/articles?email={{${email_address} | url_param_escape}}&user_id={{${user_id}}} %}

If the URL is unavailable, Braze will render an empty string in its place. Because Braze delivers messages at a very fast rate, be sure that your server can handle thousands of concurrent connections so we do not overload your server when pulling down content. When using public APIs, ensure your usage will not violate any rate-limiting that the API provider may employ. Braze requires that server response time is less than 2 seconds for performance reasons; if the server takes longer than 2 seconds to respond, the content will not be inserted.

If the endpoint returns JSON, you can detect that by checking if the connected value is null, and then conditionally abort the message. Additionally, Connected Content messages are processed with lower priority in our systems as not to roadblock other messaging campaigns due to long response times from servers. As a result, you may notice that delivery on Connected Content messages are slightly slower than other messages you send normally. Braze only allows URLs that communicate over port 80 (HTTP) and 443 (HTTPS).

Attribute values must be surrounded by ${} in order to operate properly within Braze’s version of Liquid Syntax.

Connected Content calls do not follow redirects.

Braze’s systems may make the same Connected Content API call more than once per recipient. That is because Braze may need to make a Connected Content API call to render a message payload, and message payloads can be rendered multiple times per recipient for the purposes of validation, retry logic, or other internal purposes. Your systems should be able to tolerate the same Connected Content call being made more than one time per recipient.

Using Basic Authentication

If the URL requires basic authentication, Braze can generate a basic authentication credential for you to use in your API call. In the Connected Content tab in Manage App Group, you can manage existing basic authentication credentials and add new ones.

Basic Authentication Credential Management

To add a new credential, click Add Credential. You can then name your credential and put in the username and password.

Basic Authentication Credential Creation

You can then use this basic authentication credential in your API calls by referencing the token’s name:

1
Hi there, here is fun some trivia for you!: {% connected_content https://yourwebsite.com/random/trivia :basic_auth credential_name %}

If you delete a credential, keep in mind that any Connected Content calls trying to use it will be aborted.

WAS THIS PAGE HELPFUL?