Skip to content

Create header

Headers collection allows creating new headers. Created headers can then be used in any email messages.

Request data format

Data part of request for creating a new header.

Data element children:

Element/attributeTypeNotes
NamestringName of header. Required.
HtmlstringHTML content of header. The data should be enclosed in CDATA section for XML transport. See examples. Required.
PlainstringPlain text content of header. Required.
AmpHtmlstringAMP HTML content of header. The data should be enclosed in CDATA section for XML transport. See examples. Optional. 
IsDefaultbooleanIf set to “true” (note the lowercase!), the new created header will be used as default in all new email messages. Optional. If not specified, default will be set to “false”

Response

Method returns ID of created header. ID can be used e.g. for creating new email messages.

Response Data element:

Element/attributeTypeNotes
(Data element content)intID of created header.

Examples

Creating new header with default options

Request:

POST https://api.esv2.com/v2/Api/Headers HTTP/1.1 
Accept-Encoding: gzip,deflate 
Content-Type: application/xml 
User-Agent: Jakarta Commons-HttpClient/3.1 
Host: api.esv2.com 
Content-Length: 278 

<ApiRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <ApiKey>test_api_key1</ApiKey>
  <Data>   
    <Name>New header</Name>
    <Html><![CDATA[<h2>Completely new header</h2>]]></Html>
    <Plain>Just my new plain header</Plain>
  </Data> 
</ApiRequest>

Response:

HTTP/1.1 201 Created 
Cache-Control: private 
Content-Type: text/xml; charset=utf-8 
Server: Microsoft-IIS/7.5 
X-AspNetMvc-Version: 3.0 
X-AspNet-Version: 4.0.30319 
X-Powered-By: ASP.NET 
Date: Thu, 05 Apr 2012 15:25:57 GMT 
Content-Length: 147 

<ApiResponse xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <Data>33</Data>
</ApiResponse>

Creating header with full options

Request:

POST https://api.esv2.com/v2/Api/Headers HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: application/xml
User-Agent: Jakarta Commons-HttpClient/3.1
Host: api.esv2.com
Content-Length: 1983

<ApiRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">
 <ApiKey>test_api_key1</ApiKey>
   <Data>
     <Name>New default header</Name>
     <Html><![CDATA[<h2>Completely new header</h2>]]></Html>
     <Plain>Just my new plain default header</Plain>
     <IsDefault>true</IsDefault>
     <AmpHtml><![CDATA[ <!doctype html>
              <html amp4email>
              <head>
              <meta charset="utf-8">
              <script async src="https://cdn.ampproject.org/v0.js"></script>
              <style amp4email-boilerplate>body{visibility:hidden}</style>
              </head>
              <body>
              AMP Default header

              Please use AMP markup if there is such like "amp-img" instead of "img"

              <amp-img src="https://sites.google.com/site/expertsenderapiv2/_/rsrc/1530873497175/config/Es- API.png.1530873496983.png"
             alt="Welcome"
             width="906"
             height="132">
             </amp-img>
             </body>
             </html>
             ]]></AmpHtml>
   </Data>
</ApiRequest>
On this page
To top