Service: CreateTemplate

The CreateTemplate service allows you to create a new template within Flexmail. The ID of the newly created template will be returned to you.

Service Details

SOAP Action: CreateTemplate
SOAP Return Object: CreateTemplateResp

Input

The following table describes the parameters used for calling the CreateTemplate service.

Table: instance of CreateTemplateReq

Parameter Mandatory Type Description
header Y APIRequestHeader Header for authentication
templateType Y TemplateType Template type

Output

The following table describes the parameters returned from the CreateTemplate service.

Table: instance of CreateTemplateResp

Parameter Mandatory Type Description
header / APIResponseHeader Header containing authentication information
errorCode / Integer Numerical value of the error
errorMessage / String Short literal description of the error
templateId / Integer Id of the new template

Table: response codes of CreateTemplateResp.

0 No error
220 Authentication error, see header object for detailed information
221 Template name is mandatory
222 Template text is mandatory
223 Template name already exists
224 Internal error

Example

This example shows you the creation of a new template within Flexmail, the name of our template is "my new template" and the text contains the actual HTML code which makes up the message.

<?php
$header->userId = USER_ID;
$header->userToken = USER_TOKEN;

$createTemplateReq->header = $header;
$createTemplateReq->templateType->templateName = "my new tempwxcvlate";
$createTemplateReq->templateType->templateText = urlencode("<html>new</html>");

$createTemplateResp = $SoapClient->__soapCall("CreateTemplate", array($createTemplateReq));

if ($createTemplateResp->errorCode == 0) {
    echo "Template created, template id: " . $createTemplateResp->templateId;
} else {
    echo 	"Template creation failed: " . $createTemplateResp->errorMessage;
}

?>