Skip to content

Email payload

Steve Lebleu edited this page Feb 25, 2024 · 11 revisions

This section describe the email payload structure.

> Table of contents

> Properties resume

Property Type Members Description Values Default
[transporterId] string Transporter id string 1st transporter found in array
[renderEngine] string Render engine self, cliam or provider /
meta object subject: string
to: object[]
[from: object]
[replyTo: object]
[cc:object[]]
[bcc:object[]]
[attachments:object[]]
Email subject
Recipients list
From address
Reply-to address
CC addresses
BCC addresses
Attachements
*
[{email,name}]
{email,name}
{email,name}
[{email,name}]
[{email,name}]
[{}]
/
/
.cliamrc
.cliamrc
/
/
/
[data] object * Data to compile * /
[content] object[] * Compiled contents [ { type, value } ] /

> Properties details

transporterId

The transporterId expects a transporter id to indicate which one of your transporters you want to use to send the mail. Give there one of the transporter id's defined in cliamrc.js.

The property can be omitted, in this case we fallback on the first transporter found in the cliamrc.js file.

{
  transporterId: String
}

renderEngine

The renderEngine property allows to indicate which one of the render engine you want to use to compile your templates.

The property can be omitted, in this case we fallback on the first workable setup regarding your payload.

{
  renderEngine: String // cliam | self | provider
}

meta

The meta property defines the subject of the email, the sender, recipient and reply addresses.

{
  meta: {
    subject: String,
    to: [String] || [{
      name?: String,
      email: String
    }],
    from?: {
      name?: String,
      email: String
    },
    replyTo?: {
      name?: String,
      email: String
    },
    cc?: [String] || [{
      name?: String,
      email: String
    }],
    bcc?: [String] || [{
      name?: String,
      email: String
    }],
    attachments?: [
      {
        content: String, // Base64 encoded content
        filename: String,
        type?: String, // Mime-Type
        disposition?: String, // inline || attachment
      }
    ]
  }
}

Fields from and replyTo are optionals and can be omitted if you have specified them in the .cliamrc.js file. This way, you don't have to burden your payload with redundant data. Note that if you whish increase there default addresses, you have just to define it on the fly in the request payload.meta option.

data

The data property allows you to define the variables you will use in your email. This property is free of style ... according to your templates definitions.

{
  data: {
    [key: String]: any
  }
}

In practice, you will need to use this property in two cases:

  • You delegate the template compilation to your web API provider, using templates.
  • You delegate the template compilation to Cliam, using default templates.

In the first case, you define the template and his variables, so you know the expected payload.

In the second case, you use Cliam templates. See the transactions list to find more about expected payload according to each transaction.

In a third case, you will not need to do with data property when you compile with 'self', since you compile your own content. In this case, see the content section below.

content

The content property defines compiled contents that can be sent as is and used to deliver the text and html version of your email. This is useful if you already have an efficient templating system that gives you more flexibility in generating your content.

{
  content?: [{
    type: String, // plain/text || text/html
    value: String
  }]
}

In practice, you will need to use this property in only one case:

  • You compile your template yourself

You can pass an array of two elements maximum, in which each element contains a type and a value property. The type property must be defined with 'plain/text' or 'text/html', and value contains the compiled content, in plain text or HTML.

Note that the plain text version is not required, and if she's omitted we generate one from the HTML content.