Skip to content

Send transactional messages

Transactionals collection allows sending previously created transactional message to a single subscriber, using HTTP POST method. Transactional message is identified by required ID parameter.

Request data format

Request URL parameters:

Element/attributeTypeNotes
IDintegerTransactional message ID. Required as a part of address (not GET parameter). See example below.

Example URL:

https://api.esv2.com/v2/Api/Transactionals/123

Data part of request for sending transactional message to a single subscriber.

Data element children:

Element/attributeTypeNotes
ReturnGuidbooleanIf set to true, the request will return XML with GUID (globally unique identifier) of sent transactional message. Optional, defaults to false.
ReceivercomplexDescribes subscriber that will receive the transactional message.
SnippetscomplexCollection of “Snippet” elements, describing HTML snippets that should be inserted in message body/subject etc. Optional.
AttachmentscomplexCollection of “Attachment” elements, containing additional attachment data (e.g. encoded PDF files sent with the transactional message). Optional. 

Receiver element children:

Element/attributeTypeNotes
IdintegerSubscriber’s identifier. Optional.*
EmailstringSubscriber’s email. Optional.*
EmailMd5stringMD5 hash of subscriber’s email. Optional.*
ListIdinteger Identifier of subscriber’s list. May be used to specify list context used to send the transactional message. This can be useful if subscriber is present on multiple lists. If omitted, first found list will be used as a context. Optional.
BccstringEmail address/-es which will receive a hidden copy of each message. Optional.**

* Note: One of Id/Email/EmailMd5 fields must be specified to identify the subscriber. If Email/EmailMd5 is specified, subscriber with this email or its MD5 hash must exist in the database. If more fields are specified, Id always takes precedence.
** Note: It is also possible to use personalization tags and multiple email addresses separated with ‘;’. Each email address provided will double the volume of this message. Dynamic content is not available for Bcc element.

Snippet element children:

Element/attributeTypeNotes
NamestringSnippet name.*
ValuestringSnippet value.**

* Note: Snippet name corresponds with tags that can be used in message content, subject and other message fields.
Example: If snippet’s name is mySnippet, its value will be inserted where *[tr_mySnippet]* tags have been used.
** Note: Snippets can contain HTML tags (if enclosed in CDATA section – see example requests) and personalization tags (e.g.
*[subscriber_firstname]*). Dynamic Content does NOT work inside snippets.

Attachment element children:

Element/attributeTypeNotes
FileNamestringAttachment filename. E.g. “infosheet.pdf“. Should be unique (no 2 attachments should have the same filename). Required.
MimeTypestringFile type according to MIME standards. E.g. “application/pdf“. If omitted, default MIME type will be used: “application/octet-stream“. Optional.

MIME type can affect how email attachments are treated in different email clients, so it is advisable to always specify the correct type.*
ContentstringAttachment file content. Must be Base64 encoded.** See example requests. Required.

** Note: For list of MIME types for different files, see: http://en.wikipedia.org/wiki/Internet_media_type
** Note: Binary to Base64 encoding is available in most programming languages. For more information about Base64 encoding, see: http://en.wikipedia.org/wiki/Base64

Warning: Trying to send a transactional message that is inactive or deleted will trigger an error. An error is also returned if specified subscriber cannot be found in the database or has unsubscribed from all lists.

Response

By default, response is empty and HTTP code “201 – Created” is returned. However, you can specify ReturnGuid flag in request and receive an XML response containing GUID of sent transactional message.

Response Data element:

Element/attributeTypeNotes
(Data element content)stringGUID (globally unique identifier) of sent transactional message.

Examples

Request with two snippets, subscriber identified by email:

POST https://api.esv2.com/v2/Api/Transactionals/123 HTTP/1.1 
Accept-Encoding: gzip,deflate 
Content-Type: application/xml;charset=UTF-8 
User-Agent: Jakarta Commons-HttpClient/3.1 
Host: api.esv2.com 
Content-Length: 585 

<ApiRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <ApiKey>test_api_key1</ApiKey>
  <Data>
    <Receiver>
      <Email>patrick@mydomain.com</Email>
    </Receiver>
    <Snippets>
      <Snippet>
        <Name>helloMessage</Name>
        <Value><![CDATA[ <b>Hello Patrick!<-b> ]]></Value>
      </Snippet>
      <Snippet>
        <Name>pointsNumber</Name>
        <Value>2076</Value>
      </Snippet>
    </Snippets>
  </Data>
</ApiRequest>

Request with no snippets, subscriber identified by ID:

POST https://api.esv2.com/v2/Api/Transactionals/1593 HTTP/1.1 
Accept-Encoding: gzip,deflate 
Content-Type: application/xml;charset=UTF-8 
User-Agent: Jakarta Commons-HttpClient/3.1 
Host: api.esv2.com 
Content-Length: 241 

<ApiRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <ApiKey>test_api_key1</ApiKey>
  <Data>
    <Receiver>
      <Id>12345</Id>
    </Receiver>
  </Data>
</ApiRequest>

Request with attachment:

POST http://api.esv2.com/v2/Api/Transactionals/2449 HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: application/xml;charset=UTF-8
Content-Length: 113056
Host: api.esv2.com
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

<ApiRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">
   <ApiKey>test_api_key1</ApiKey>
   <Data>
      <Receiver>
         <Email>patrick@mydomain.com</Email>
      </Receiver>
      <Attachments>
        <Attachment>
        <FileName>test.pdf</FileName>
        <MimeType>application/pdf</MimeType><Content>JVBERi0xLjUNCiW1tbW1DQoxIDAgb2JqDQo8PC9UeXBlL0NhdGFsb2cvUGFnZXMgMiAwIFIvTGFu
ZyhwbC1QTCkgL1N0cnVjdFRyZWVSb290IDggMCBSL01hcmtJbmZvPDwvTWFya2VkIHRydWU+Pj4+
DQplbmRvYmoNCjIgMCBvYmoNCjw8L1R5cGUvUGFnZXMvQ291bnQgMS9LaWRzWyAzIDAgUl0gPj4N
CmVuZG9iag0KMyAwIG9iag0KPDwvVHlwZS9QYWdlL1BhcmVudCAyIDAgUi9SZXNvdXJjZXM8PC9G
...
ODlFOENBQTNGMTY5NzFBRTU+XSAvUHJldiA4MjU0MS9YUmVmU3RtIDgyMjcwPj4NCnN0YXJ0eHJl
Zg0KODMwNTcNCiUlRU9G</Content>
      </Attachment>
    </Attachments>
  </Data>
</ApiRequest>

Note: Part of long attachment content was cut and “…” was inserted.

Request with ReturnGuid option:

POST https://api.esv2.com/v2/Api/Transactionals/2449 HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: application/xml;charset=UTF-8
Content-Length: 317
Host: api.esv2.com
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

<ApiRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">
     <ApiKey>test_api_key1</ApiKey>
     <Data>
         <ReturnGuid>true</ReturnGuid>
         <Receiver>
             <Email>patrick@mydomain.com</Email>
         </Receiver>
    </Data>
 </ApiRequest>

OK Response (no GUID):

HTTP/1.1 201 Created 
Cache-Control: private 
Server: Microsoft-IIS/7.5 
X-AspNetMvc-Version: 2.0 
X-AspNet-Version: 2.0.50727 
Set-Cookie: TIMEZONE=Central European Standard Time; path=/ 
X-Powered-By: ASP.NET 
Date: Fri, 08 Jul 2011 11:34:53 GMT 
Content-Length: 0

OK Response (with GUID):

HTTP/1.1 201 Created
Cache-Control: private
Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNetMvc-Version: 5.2
X-AspNet-Version: 4.0.30319
Set-Cookie: TEMP_DATA=72940603-7e6e-4e32-8dcf-85b547297551; path=/
X-Powered-By: ASP.NET
Date: Wed, 28 Jan 2015 16:30:11 GMT
Content-Length: 181

<ApiResponse xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Data>c3a4bda9-07be-4d48-af20-df51293ec78f</Data>
</ApiResponse>

Error Response (bad subscriber):

HTTP/1.1 400 Bad Request 
Cache-Control: private 
Content-Type: text/xml; charset=utf-8 
Server: Microsoft-IIS/7.5 
X-AspNetMvc-Version: 2.0 
X-AspNet-Version: 2.0.50727 
Set-Cookie: TIMEZONE=Central European Standard Time; path=/ 
X-Powered-By: ASP.NET 
Date: Fri, 08 Jul 2011 11:37:19 GMT 
Content-Length: 274 

<ApiResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <ErrorMessage>
    <Code>400</Code>
    <Message>Subscriber does not exist in the database or has unsubscribed.</Message>
  </ErrorMessage>
</ApiResponse>
On this page
To top