Sending messages

In order to send an Email message, you must have an active Email channel and perform a HTTP request to the following endpoint with a valid access key

Send a plain text email

To send a plain text email message with the above endpoint set the request body as follows:

{
 "receiver": {
   "contacts": [
     {
       "identifierValue": "john.smith@example.com"
     }
   ]
 },
 "body": {
  "type": "text",
  "text": {
    "text": "Single text message"
  }
}
}

Send a html email

To send a html email message with the above endpoint set the request body as follows. For email clients that do not support html / rich content set the plain text fallback field.

{
  "receiver": {
    "contacts": [
      {
        "identifierValue": "john.smith@example.com"
      }
    ]
  },
 "body": {
  "type": "html",
  "html": {
  "text": "Single text message",
  "html": "<p style=\"\">Single html message</p><p style=\"\"></p><p style=\"\">"
 }
}
}

HTML metadata

Within the HTML body object you can include a metdata object as follows:

body.metadata.html.subject = set the email subject

body.metadata.emailfrom.username = set the sender before the @ e.g. support@acme.com

body.metadata.emailfrom.displayname = set the display name appearing in users inbox e.g. Support team

body.metadata.headers.reply-to = the reply-to address

As an example:

{
  "receiver": {
    "contacts": [
      {
        "identifierValue": "john.smith@example.com"
      }
    ]
  },
 "body": {
  "type": "html",
   "html": {
  "text": "Single text message",
  "html": "<p style=\"\">Single html message</p><p style=\"\"></p><p style=\"\">",
        "metadata": {
        "subject": "Here is an Email!",
        "headers":{
        "reply-to": "replyto@this.address"
        },
        "emailFrom": {
          "username": "support",
          "displayName": "Support Team"
        }
      }
   }
  }
}

Send a html message with attachments

To send an email with attached media, ensure that your media file is either publicly available or see uploading media

Add attachment objects to body.html.attachments[] as shown. Each attachment object has the following properties

mediaUrl = The URL location of the media

filename = The name of the file

inline = boolean (default false). See sending inline images

  {
  "receiver": {
    "contacts": [
      {
        "identifierValue": "john.smith@example.com"
      }
    ]
  },
  "body": {
    "type": "html",
    "html": {
      "text": "Single text message",
      "html": "<p style=\"\">Single html message</p><p style=\"\"></p><p style=\"\">",
      "metadata": {
        "subject": "Here is an Email with an attachment",
        "headers": {
          "reply-to": "replyto@this.address"
        },
        "emailFrom": {
          "username": "support",
          "displayName": "Support Team"
        }
      },
      "attachments": [
        {
          "mediaUrl": "mediaurl",
          "filename": "image.png",
          "inline": false
        }
      ]
    }
  }
}

Send a html message with inline images

To send an email with images inline, ensure that your media file is either publicly available or see uploading media.

Add an array of attachments to body.html as above, but set body.html.attachments[].inline to true

Within body.html reference the image in an image tag and prefix the filename with cid:

For example

<img src="cid:imagetext.png">
 {
  "receiver": {
    "contacts": [
      {
        "identifierValue": "john.smith@example.com"
      }
    ]
  },
  "body": {
    "type": "html",
    "html": {
      "text": "Single text message",
      "html": "<p style=\"\">Single html message</p><p style=\"\"></p><p style=\"\"><p>INLINE IMAGE! <img src=\"cid:image.png\"></p>",
      "metadata": {
        "subject": "Here is an Email with an attachment",
        "headers": {
          "reply-to": "replyto@this.address"
        },
        "emailFrom": {
          "username": "support",
          "displayName": "Support Team"
        }
      },
      "attachments": [
        {
          "mediaUrl": "mediaurl",
          "filename": "image.png",
          "inline": true
        }
      ]
    }
  }
}

Last updated