The Email Builder API

The Email Builder API allows you to retrieve the list of projects, folders, and campaigns of a given project for a given client account, as well as retrieve the HTML markup and media URLs associated with a campaign. Access to this API must be requested from your account manager.

Once access to the API has been granted, you can generate your API key.

Notes on use

The data made available to you originate from your client account.

The Email Builder backend does not have an absolute usage limit in terms of the number of requests. However, it has a frequency limit for queries. For security reasons, the number of requests to the API is limited to 100 per minute. To avoid exceeding this quota, the retrieved data should be cached. In the event of an exceedance, the IP address of the requesting service will be temporarily blocked.

Integration

Obtaining a connection token

To obtain a connection token or access_token to authenticate with the Email Builder API, execute a POST request to the URL:

https://app.dartagnan.io/oauth/v2/token

The header of your request must contain:

The body of your request must contain the following three parameters in a JSON object:

Your client_id and client_secret need to be generated by your administrator as described above.

Example request

Example response

The value returned for access_token should then be passed in the header of each request made to the API.

The lifespan of tokens generated is available in the expires_in property (duration expressed in seconds). The lifespan of a token is 1 hour.

Retrieving the list of projects for a client account

To obtain the list of projects for your client account, execute a GET request to the URL:

https://app.dartagnan.io/api/public/projects

Then, in the request body, pass the Authorization parameter set to Bearer followed by your access_token.

Example request body

The access_token variable is an alphanumeric string that is 86 characters long.

Example request

Example response

Retrieving the list of folders and campaigns for a project

To obtain the list of folders and campaigns for a client account, execute a GET request to this URL:

https://app.dartagnan.io/api/public/projects/{project_id}

Then, replace {project_id} in the URL with the ID (integer) of the project whose hierarchy you want to retrieve. In the header of this request, set the Authorization parameter to Bearer followed by your access_token.

Example header

Example request

Example response

Retrieving the HTML markup and media assets of a campaign

To retrieve the HTML markup and media assets of a campaign, execute a GET request to the URL:

https://app.dartagnan.io/api/public/campaigns/{campaign_id}

Then, replace {campaign_id} in the URL with the ID (integer) of a campaign retrieved from the project hierarchy (see above, "Retrieving the list of folders and campaigns for a project").

In the header of this request, set the Authorization parameter to Bearer followed by your access_token.

Example header

Example request

Example response

Retrieving the HTML markup separated by section and the media assets of a campaign

To retrieve the HTML code separated by section and the media assets of a campaign, execute a GET request to the URL:

https://app.dartagnan.io/api/public/campaigns/{campaign_id}/split

Next, add the following parameters:

encode

Allows you to activate or deactivate the encoding of special characters in the texts present in the generated HTML markup.
The values accepted are true (recommended) and false.

router

Allows you to select the type of encoding to apply to the generated HTML markup.
The values accepted are UTF8 (recommended), ISO88595, and ISO885915.

splitPattern

Allows you to define the HTML string that will be inserted into the campaign template in place of each section. The { sectionName } string will be automatically replaced with the name of the corresponding section. An example for a value:

<span class="droppable" id="{ sectionName }"></span>

The value of the splitPattern string must be encoded for the URL to be syntactically correct (url encode).

Then, replace {campaign_id} in the URL with the ID (integer) of a campaign retrieved from the project hierarchy (see above, "Retrieving the list of folders and campaigns for a project").

In the header of this request, set the Authorization parameter to Bearer followed by your access_token.

Example header

Example request

Example response

The section names listed in the sections object correspond to the names defined in the Email Builder’s “Structure” tab when editing the campaign.

If a section does not have a defined name in the Email Builder, its generated UUID is used as the identifier in the sections object and in the HTML markup available in the skeleton property.

For security reasons, the lifespan of the media retrieved through this method is limited. Therefore, you cannot use their URLs for your routing. You need to download and host them yourself.