Messages

Email messages

Whispir can easily be used as an API email gateway to deliver thousands of rich content emails for your communication campaigns.

Mandatory fields

Only 4 fields are required in order to send an email message:

  • To: The recipient of the email message.
  • Subject: The subject line of the email message.
  • Body: The content of the email (either HTML or plain text content).
  • Type: Either ‘text/plain’ or ‘text/html’ to describe the content of the message.

Whispir strongly recommends that you use workspaces for all your messaging needs. Refer to Workspaces.

Whispir’s support of rich (HTML) emails

  • The html, head and body HTML elements are not supported. HTML content assumes that it’s starting from within the body tag.
  • HTML form and input elements are not supported in most email clients. You can include them in the HTML content but you should thoroughly test them prior to use.
  • STYLE elements are supported. Whispir recommends using a single style element at the top of the HTML that defines the styles for the entire email. However, inline styles are also supported.
  • JavaScript is not supported and should not be used in email messages.
  • Images must be referenced through absolute web URLs. Any other mechanism will not work on most email clients.

Note: Whispir doesn't host images for clients. You must use another hosting service and reference the image’s URL in your Whispir request payload.

Including attachments in email messages

The Whispir API provides users with the ability to compose email messages that also contain message attachments.

Attachments can be of any type (for example, PDF, images and documents), and can be up to 10 MB in size (that is, the maximum size of all attached files combined is 10 MB).

Attachments must be provided in the payload of the message. URLs can be referenced in the email but will not be added as message attachments.

Notes:

  • attachmentName: The name of the file being attached (mandatory).
  • attachmentDesc: An optional description of the file being attached.
  • derefUri: The base64 representation of the file being uploaded.
  • Important! The attachment element in JSON is also an array, so be sure to add the square brackets!
  • JSON
  • XML

Sending plain text emails

{{codeStart}}

HTTP 1.1 POST https://api.<region>.whispir.com/messages?apikey=[your_api_key]

Authorization: Basic am9obi5zbWl0aDpteXBhc3N3b3Jk

x-api-key: your_api_key

Content-Type: application/vnd.whispir.message-v1+json

Accept: application/vnd.whispir.message-v1+json

{

"to" : "john.smith@test.com",

"subject" : "Test Email Message",

"email" : {

"body" : "Email Body goes here.",

"footer" : "Email signature goes here.",

"type" : "text/plain"

}

}

{{codeEnd}}

 

Sending rich text (HTML) emails

{{codeStart}}

HTTP 1.1 POST https://api.<region>.whispir.com/messages?apikey=[your_api_key]

Authorization: Basic am9obi5zbWl0aDpteXBhc3N3b3Jk

x-api-key: your_api_key

Content-Type: application/vnd.whispir.message-v1+json

Accept: application/vnd.whispir.message-v1+json

{

"to" : "john.smith@test.com",

"subject" : "Test Email Message",

"email" : {

"body" : "<div id='content'><p>This is my content</p></div>",

"type" : "text/html"

}

}

{{codeEnd}}

 

Sending emails with attachments

{{codeStart}}

HTTP 1.1 POST https://api.<region>.whispir.com/messages?apikey=[your_api_key]

Authorization: Basic am9obi5zbWl0aDpteXBhc3N3b3Jk

x-api-key: your_api_key

Content-Type: application/vnd.whispir.message-v1+json

Accept: application/vnd.whispir.message-v1+json

{

"to" : "jsmith@test.com",

"subject" : "Test e-mail message with attachment",

"email" : {

"body" : "This is my content",

"type" : "text/plain",

"resources" : {

"attachment" : [{

"attachmentName" : "TestIcon.png",

"attachmentDesc" : "TestIcon.png",

"derefUri" : "iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAIAAADUsmlHAAAAAXNSR0IArs4c6QAAAARnQU1BAACx

jwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAMvSURBVDhPTVT5S1RhFD3fezOOOePTXHKriWgj

sogWC1TSMuuHIFqoX0KsIIgSWwiq/6FFU8MKK6KyXYSKpkUKR4QMSSpCLQpyxHHUZpztzdu63xub

5vKWj/fu+c6599z3mMfjSU9P13UdZoiCaLfZYQWiUGKq1WrBLEBDOBpWNTWeQyEIwvT0NAsEAgRO

PKXFxceNbQOtv4ShkKCkaZZ5kYU1Sw6dqT0NMTkLBIbf7zf+xaOuJzgG4RmyPyP/Kwq/oWAYeT+R

6gYOofnmlUQmLQjI6JQkifasu368KdCQWwFEwBiYQOIgiDBETDFIORh/iZ0De55cehgXQJIphce9

d/ebJhuyV0P3QY9Cj/HDUKhseIPomP/CW2QYB42nSx+db76YUM9IusPhYHVM2g5Bpo5xNuIkZibC

F8On0oGVjhWabmR8EBx5GDuHaItsy0zhzA6bo/H5ZSyDMQ1d4YQa0Sqc1hdAe3E7IYkqp9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