Logic description

This article provides a detailed explanation of the logical process involved in utilizing the API method to create email messages.

πŸ‘

Please be advised

Prior to initiating the creation of email templates using the API, it is essential to follow the instructions outlined on the Preparing to create emails page to ensure all necessary steps have been completed.

Within the API reference, you will find the Generate an email method, which facilitates the creation of email messages via the API. Although it may initially appear complex, we are here to guide you through the process by explaining each parameter involved in the request and providing practical examples for better understanding.

Now, let's delve into the specifics of the request's body for a more detailed examination.

{
   dataSources: DataSourceDto[],
   transformers: TransformerDto[],
   composers: ComposerDto[],
   templateId: Long,
   emailId: Long,
   emailName: String,
   title: String,
   preheader: String
}

Here is a description of the parameters involved:

ParameterRequiredDescription
dataSourcesMandatoryThe dataSources refer to the content that will be utilized for generating the email message. Essentially, this is where you can specify the information appearing in your final email message.

dataSourcesDto description
{
name: String, // M
type: String, // M
value: Object // M
}

where:

name β€” represents the identifier for a specific data source. Since connecting multiple data sources simultaneously is possible, assigning a name helps determine which source should be utilized in particular cases. This can be useful for tasks such as data trimming, enrichment with additional parameters, and more.
type β€” specifies the method for retrieving the data. Currently, two types are supported:
- RAW: In this case, the data should be directly placed in the value field of your request.
- LINK: The data will be loaded from the specified URL provided in the value field.
value β€” represents the actual data obtained from your data feed. It contains the content or information that will be used in the email generation process.

For more information about the supported data source formats and to explore examples, please refer to the Resources section.
transformersOptionalThis parameter represents the list of transformers that can be applied to the initial data in order to generate an email message.

transformersDto description
{
type: String, //M
source: String, //O
outputSource: String, //O
config: JSON //M
}

where:

type β€” refers to the type of transformers used. Please refer to the Resources section to learn more about the supported transformer types.

source β€” an optional field that specifies the name of the source to which the transformer should be applied. If the source name is not specified, the first source will be used by default.

outputSource β€” an optional field that indicates the name of the destination source where the modified data will be written after transforming by this particular transformer. The results will be returned to the initial source by default if no output source is specified.

config β€” represents the configuration specific to the transformer being used. Each transformer has its own format of configuration. To explore more about the supported transformers and their respective configurations, please refer to the Resources.
composersOptionalThe list of composers is employed to map the data from the data source to the appropriate generation areas within the email message.

composersDto description
{
type: String, //O
source: String, //O
templateArea: String //O
}

where:

type β€” an optional parameter that determines the type of composer to be used. There are two supported types:
-canonical (default one): This type matches the data from a canonical JSON data source with the generation area of the template.
- plain: This type matches the data from a plain text data source, importing it without any modifications.

source β€” an optional parameter that specifies the name of the data source from which the data should be retrieved and applied to the message. If not specified, the data will be taken from the first source.

templateArea β€” an optional parameter that identifies the email generation area within the template where the records should be inserted. If not specified, the first available area will be used.
templateIdMandatoryThis parameter represents a template's ID containing the generation area for email message generation. It is important to note that this template must be one that you have created and saved within your own project rather than a basic or prepared template.

To access and view all your templates, please navigate to the Templates menu within your Stripo account.
emailIdOptionalIf you wish to override an existing email message, please provide its ID in this parameter. Leaving this empty will result in the creation of a new email message.
emailNameOptionalThis parameter represents the desired name for the generated email message. If this is left empty, the template's name will be used as the name for the generated email message.
titleOptionalThis parameter determines the value that will be inserted into the <title> tag of the generated email message, which represents its subject line.
preheaderOptionalThis parameter specifies the value that will be inserted into the hidden preheader <span> tag of the generated email message. The preheader represents the invisible text within the email message that is visible to recipients before they open it, appearing right after the Subject line.

Excellent job! Now, let's examine an example of the request provided in the following article.