Template Service Guide

May 7, 2013

PUBLIC DISTRIBUTION

DST Systems
Electronic Solutions Division
333 W 11th St
Kansas City, MO 64105
www.dstsystems.com

ePriority Development
www.epriority.com


ePriority Logo
© Copyright 2001-2015 DST Systems. All rights reserved. This file may not be copied in whole or in part in any medium without the express written consent of the owner.



Contents Up


Introduction Up

The Template Hosting service is used to transfer and store plain text and html email content on the ePriority servers. The Template Hosting web service allows transfer of content to and from ePriority, updating existing hosted content, version control, content statuses indicating production worthy or currently editable drafts, and metadata. Errors may occur when bad credentials are supplied or incorrect/incomplete data is given in the template query.

If you have not already done so, you should read the «ePriority Service Overview» before going further with this document as it will provide context for all ePriority features.


HTTP Query Up

To interact with a hosted template through an HTTPS query, the following parameters must be supplied:

authDate Allowed: T, 0-9, dash, colon
Authentication Date: the date and time the request was created, represented as a string in UTC. The following ISO 8601 format should be used: YYYY-MM-DDThh:mm:ss (eg 1997-07-16T19:20:30)
authHash Allowed: a-f, A-F, 0-9
Length: 32
SHA256 Hexidecimal Authentication String.
action Allowed: list | create | update | view | release | preview | delete
name Allowed: a-z, A-Z, 0-9, period, underscore
Length: 1-35

The name of the template. The name is not case sensitive.
version Allowed: integer, "v" plus Integer, "draft", "production"
The version or status of the specified template name.
desc Length: 1-254 Allowed: a-z, A-Z, 0-9, .-_~!@#$%^&*()+[]{}\\|;:,<>/?
Brief descriptor of the template
comment Length: 1-254 Allowed: a-z, A-Z, 0-9, .-_~!@#$%^&*()+[]{}\\|;:,<>/?
Brief descriptor of changes made from last revision to current.
type Allowed: text/plain | text/html
Content type of the template.
user Length: 1-129 Allowed: a-z, A-Z, 0-9, .-_~!@#$%^&*()+[]{}\\|;:,<>/?
Username sufficient to identify the user on the particular system using the template service.
subject Length: 1-254 Restricted: tab, carriage return, newline
This value is used for the subject in the emails.
from Length: 1-64
Name to display with the sender's address.
fromaddress Designates the return/sender email address.
reply Length: 1-64
Name to display with the reply address.
replyaddress Defines an alternative to the "From" address for reply mail. Not all mail clients or mail servers may use the two addresses in the same way. Additionally, there is no assurance that mail servers will not send bounced mail to the "reply" address instead of the "from" address.
contents HTML or plain text email content.

Authentication Up

The cid (ePriority Client ID), authDate and authHash parameters are required for authentication of all Web API requests. See authentication instructions.


Using the Template Service Up


Sample Requests Up

https://www.epriority.com/TemplateService?cid=12345&version=1&authDate=2010-04-19T08:24:39&authHash=3ad64d6780d2c4762b335570646939e0&action=list
Return all template information for a given account.

https://www.epriority.com/TemplateService?cid=12345&authDate=1303224086377&authHash=cce48ea23edf7c97fa65bb1f2bd1b341&action=create&user=toddplankton&name=Account_Update&desc=Account update alert&comment=Initial Revision&type=text/html&contents=Dear User, Your account has been updated. Your company, The Company
Create a new email template.

https://www.epriority.com/TemplateService?cid=12345&authDate=1303225511226&authHash=7f6038f801fb69cd9513a7a7d9a31482&action=update&user=toddplankton&name=Account_Update&desc=Account update alert&comment=Initial Revision&type=text/html&contents=Dear User, Your account has been updated. Your company, The Company
Update an existing template.

https://www.epriority.com/TemplateService?cid=12345&authDate=1303224194210&authHash=381a47e16fb5d9f20ec99a556e3cdf68&action=view&name=Account_Update&version=v3
View the raw html or plain text of a template and its metadata.

https://www.epriority.com/TemplateService?cid=12345&authDate=1303240706669&authHash=31701e5db9800e11619764aec833cba1&action=release&name=Account_Update&user=vernonshofts
Release, or promote, an email template from draft to production status.

https://www.epriority.com/TemplateService?cid=12345&authDate=1303240706669&authHash=31701e5db9800e11619764aec833cba1&action=delete&name=Account_Update&user=vernonshofts
Excludes an email template from viewing and use.

https://www.epriority.com/TemplateService?cid=12345&authDate=1303240706669&authHash=31701e5db9800e11619764aec833cba1&action=preview&name=Account_Update&version=production
Preview an existing template as it would look in the browser.


Outputs Up

HTTP response 403 (forbidden) is returned when authentication fails.
<root>Access Denied</root>

Successful List Request

<?xml version="1.0" encoding="iso-8859-1"?>
<root>
  <template>
    <template_id>52<template_id>
    <client_id>1105<client_id>
    <name>ARCHER_LETTER<name>
    <description>my transactional stuff<description>
    <comment>won't sell an apple<comment>
    <status>0<status>
    <version>1<version>
    <content_type>text/html<content_type>
    <charset>iso-8859-1<charset>
    <creator>tteague@dstoutput.com<creator>
    <last_editor />
    <releasor />
    <deletor />
    <byte_count>29<byte_count>
    <parse>false<parse>
    <creation_dt>2011-09-12<creation_dt>
    <last_mod_dt>2011-09-12<last_mod_dt>
  </template>
  <template>
    <template_id>28<template_id>
    <client_id>1105<client_id>
    <name>ARCHER_NEWSLETTER<name>
    <description>Awesome newsletter that everyone wants<description>
    <comment>Initial Revision<comment>
    <status>2<status>
    <version>1<version>
    <content_type>text/html<content_type>
    <charset>iso-8859-1<charset>
    <creator>tteague@dstoutput.com<creator>
    <last_editor>tteague@dstoutput.com<last_editor>
    <releasor>tteague@dstoutput.com<releasor>
    <deletor />
    <byte_count>2009<byte_count>
    <parse>false<parse>
    <creation_dt>2011-08-03<creation_dt>
    <last_mod_dt>2011-08-05<last_mod_dt>
  </template>
</root>

Successful List/Create/Update/Release/Delete Request

<?xml version="1.0" encoding="UTF-8"?>
<root>
  <status>SUCCESS</status>
</root>

Successful Preview Request

Text/plain or HTML content of body with a text/plain or html mimetype accordingly. 

Successful View Request

<xml version="1.0" encoding="iso-8859-1"?>
<root>
  <template>
    <template_id>28<template_id>
    <client_id>1105<client_id>
    <name>ARCHER_NEWSLETTER<name>
    <description>Awesome newsletter that everyone wants<description>
    <comment>Initial Revision<comment>
    <status>2<status>
    <version>3<version>
    <content_type>text/html<content_type>
    <charset>iso-8859-1<charset>
    <creator>tteague@dstoutput.com<creator>
    <last_editor>tteague@dstoutput.com<last_editor>
    <releasor>tteague@dstoutput.com<releasor>
    <deletor />
    <byte_count>2107<byte_count>
    <parse>false<parse>
    <creation_dt>2011-08-03<creation_dt>
    <last_mod_dt>2011-08-05<last_mod_dt>
    <content>
      <CDATA[ <html>
        <head>
          <style type="text/css">
            #madeup
            {
            }
            #mainbody
            {
              border: 1px solid black;
              background-color: white;
              padding: 5%;
              margin: 5%;
              min-width: 400px;
              background-image: url( "companyInc.png" );
              background-repeat: no-repeat;
              background-position: right center;
            }
      
            #header
            {
              border-bottom: 1px solid #2F8395;
              text-align: right;
            }
      
            #imagediv
            {
              position: absolute;
              left: 250px;
              top: 200px;
              opacity:0.2;
              filter:alpha(opacity=20);
            }
      
            #business
            {
              font-size: x-small;
            }
      
            a
            {
              color: brown;
            }
          </style>
        </head>
        <body bgcolor="green">
          <div id="mainbody">
            <div id="header">
              <img src="toplogo.gif" border="0"/>
            <div>
            <p>Dear <EPRIORITY key="First" name="PDATA" /> <epriority name="Pdata" key="last"/>lt;p>
            <p>Your Company, Inc. bill is due.  Please visit the Company, Inc. website to submit payment,
               in the amount of $74.33.<p>
            <p>This message was delivered to the following ISP:<epriority name="Pdata" key="ISP"/>lt;p>
            <p>Wanda Support<br/>
                <a href="<epriority name="TrackLink" url="www.msn.com" />Visit MSN<a>lt;br/>lt;br/>
               ePriority Development Group<br/>
               DST Output, Inc.<br/>
               customerservice@dstoutput.com<p>
            <a href="<epriority name="TrackLink" url="http://www.google.com"/>Company, Inc. Support<a>lt;br/>lt;br/>
            <div id="business">
              You have received this email because you have signed up for billing notifications.  If you would
              like to cancel these notifications, <a href="<epriority name="OptOut" />opt-out<a>  To
              subscribe to billing notification emails in the future, contact a Company, Inc. representative
              or <a href="<epriority name="OptIn" />opt-in<a>
        
                      <epriority name="TrackViewing" />
            <div>
          <div>
        <body>
      <html>
    ]]<content>
  <template>
<root>

Unsuccessful Request

<?xml version="1.0" encoding="ISO-8859-1"?>
<root>
  <status>FAILED</status>
  <message>Error message</message>
</root>

Unsuccessful Request (Invalid parameter)

  <root>
    <status>FAILED</status>
    <message>Parameter invalid</message>
  <root>

Java Example Up

import java.io.*;
import java.net.*;
import java.text.*;
import java.util.*;
import java.security.MessageDigest;
import javax.net.ssl.*;

public class EpriorityTemplateService
{
  static int myAccountId = 12345;

  public static void main (String[] args)
  {
    try
    {
      // Prepare Authentication Credentials
      SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
      sdf.setTimeZone(TimeZone.getTimeZone("Universal"));
      String authDate = sdf.format(new Date());
      String webServicePw = args[0];
      String searchAddress = args[1];
      String digestString = authDate + webServicePw;
      MessageDigest md = MessageDigest.getInstance("SHA256");
      byte[] hash = md.digest( digestString.getBytes() );
      String hashHex = asHex( hash );


      // Prepare Content
      StringBuilder content = new StringBuilder();
      content.append("cid=");
      content.append(myAccountId);
      content.append("&authDate=");
      content.append(authDate);
      content.append("&authHash=");
      content.append(hashHex);
      content.append("&action=list");


      // Connect to URL
      URL url = new URL ("https://www.epriority.com/TemplateService");

      URLConnection urlConn = url.openConnection();
      urlConn.setDoInput(true);
      urlConn.setDoOutput(true);
      urlConn.setUseCaches(false);
      urlConn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");


      // Send HTTP POST
      DataOutputStream printout = new DataOutputStream(urlConn.getOutputStream());
      printout.writeBytes (content.toString());
      printout.flush ();
      printout.close ();


      // Read XML Response
      BufferedReader input = new BufferedReader(new InputStreamReader(urlConn.getInputStream()));
      String str;
      while (null != ((str = input.readLine())))
      {
        System.out.println(str);
      }
      input.close ();
    }
    catch (Exception e)
    {
      System.out.println(e.getMessage());
    }
  }

  public static final String asHex(byte[] data)
  {
    //double size, two bytes (hex range) for one byte
    StringBuffer buf = new StringBuffer(data.length * 2);

    for (int i = 0; i < data.length; i++)
    {
      //don't forget the second hex digit
      if (((int) data[i] & 0xff) < 0x10)
      {
        buf.append("0");
      }

      buf.append(Long.toString((int) data[i] & 0xff, 16));
    }

    return buf.toString();
  }

}