Getting started with External feeds

Here you can get to know about the working and handling the external feeds. Below are some methods to include an external feed in your emails.

Working with External feeds

You can create an external feed using the API endpoint in the public API reference.

There are two ways to connect the external feeds with the email templates which are:


Html editor

To add in html code, use this code below, before the html body.

<!--feed.myvariable : {{feed.get("feedname")}}-->

where myvariable is variable name used to access feed data and feedname is the name of the feed you have setup via the API endpoint.


Drag and drop editor

For the drag and drop editor, you should be in developer mode. Add the code mentioned below, at the start of the template in the developer mode.

feeds:
  -
    name: myvariable
    source: feedname

where myvariable is variable name used to access feed data and feedname is the name of the feed you have setup via the API endpoint.

Accessing external feeds in email

To access the data from the external feeds, you have to utilize the code below:

{{ feed.myvariable.field }}
{{ feed.myvariable.field.0.item }}

field is any field in the JSON and to access any item we suffix a number which starts from 0.

Errors in external feeds

Errors may occur at various steps when using an external feed. If an error is encountered for a particular contact, that contact will be skipped from receiving the email campaign. If there is a general error that applies to all contacts, then all recipients will be skipped, and the reasons can be viewed in the email report.

Some common errors that can be encountered include:

  • The external feed either does not exist or its definition is incorrect in the template.
  • External feed placeholders are defined incorrectly in the template.
  • An API issue prevents access to the external feed.

How to access external feeds with token authentication

When creating the feeds, bearer token can be sent as headers for authentication. When the feed is called the token will be passed into the headers and the API is called with all the information provided by the user. An example of how the token will be passed in headers is mentioned below.

headers : {
  "token": "Bearer token"
}

Frequently Asked Questions (FAQ)

When sending out an email for a campaign, lets hypothetically assume 50,000 recipients. Does Brevo's servers send 50,000 http requests to the API specified in external feed, or one request and use the same response JSON for all emails?

for global feed:
for 'n' contacts server will send request 'n' times to API unless client has set cache: 'true' while creating feed.

When sending out an email for a campaign using personal emails with attributes, do Brevo servers send one request per user or once for the whole campaign?

In case of personalised feed:
As value is expected to be different for each recipient, we don't consider caching functionality, server will send request multiple times as per number of recipients even if caching is true.

If one request per user is sent, Do the http request to their external feed API send the attributes along as variables, either as POST variables or GET parameters?

As of now we support GET and we don't send any variable to API, we replace the variable value at our end and then send the request to API.

If one request is sent per campaign and personalization is based on attributes mapped to the response JSON,
How big is the response json file allowed to be?

There is no limit for response json as of now but yes we will suggest to have only required data, as more the response data more would be the latency.