Documentation

Templates
in package

Manage the Templates in your account.

Table of Contents

Properties

$master  : mixed

Methods

__construct()  : mixed
add()  : struct
Add a new template.
delete()  : struct
Delete a template.
getList()  : array<string|int, mixed>
Return a list of all the templates available to this user.
info()  : struct
Get the information for an existing template.
publish()  : struct
Publish the content for the template. Any new messages sent using this template will start using the content that was previously in draft.
render()  : struct
Inject content and optionally merge fields into a template, returning the HTML that results.
timeSeries()  : array<string|int, mixed>
Return the recent history (hourly stats for the last 30 days) for a template.
update()  : struct
Update the code for an existing template. If null is provided for any fields, the values will remain unchanged.

Properties

Methods

add()

Add a new template.

public add(string $name[, string $fromEmail = null ][, string $fromName = null ][, string $subject = null ][, string $code = null ][, string $text = null ][, bool $publish = true ][, array<string|int, mixed> $labels = [] ]) : struct
Parameters
$name : string

the name for the new template - must be unique

$fromEmail : string = null

a default sending address for emails sent using this template

$fromName : string = null

a default from name to be used

$subject : string = null

a default subject line to be used

$code : string = null

the HTML code for the template with mc:edit attributes for the editable elements

$text : string = null

a default text part to be used when sending with this template

$publish : bool = true

set to false to add a draft template without publishing

$labels : array<string|int, mixed> = []

an optional array of up to 10 labels to use for filtering templates

  • labels[] string a single label
Return values
struct

the information saved about the new template

  • slug string the immutable unique code name of the template
  • name string the name of the template
  • labels array the list of labels applied to the template
  • labels[] string a single label
  • code string the full HTML code of the template, with mc:edit attributes marking the editable elements - draft version
  • subject string the subject line of the template, if provided - draft version
  • from_email string the default sender address for the template, if provided - draft version
  • from_name string the default sender from name for the template, if provided - draft version
  • text string the default text part of messages sent with the template, if provided - draft version
  • publish_name string the same as the template name - kept as a separate field for backwards compatibility
  • publish_code string the full HTML code of the template, with mc:edit attributes marking the editable elements that are available as published, if it has been published
  • publish_subject string the subject line of the template, if provided
  • publish_from_email string the default sender address for the template, if provided
  • publish_from_name string the default sender from name for the template, if provided
  • publish_text string the default text part of messages sent with the template, if provided
  • published_at string the date and time the template was last published as a UTC string in YYYY-MM-DD HH:MM:SS format, or null if it has not been published
  • created_at string the date and time the template was first created as a UTC string in YYYY-MM-DD HH:MM:SS format
  • updated_at string the date and time the template was last modified as a UTC string in YYYY-MM-DD HH:MM:SS format

delete()

Delete a template.

public delete(string $name) : struct
Parameters
$name : string

the immutable name of an existing template

Return values
struct

the template that was deleted

  • slug string the immutable unique code name of the template
  • name string the name of the template
  • labels array the list of labels applied to the template
  • labels[] string a single label
  • code string the full HTML code of the template, with mc:edit attributes marking the editable elements - draft version
  • subject string the subject line of the template, if provided - draft version
  • from_email string the default sender address for the template, if provided - draft version
  • from_name string the default sender from name for the template, if provided - draft version
  • text string the default text part of messages sent with the template, if provided - draft version
  • publish_name string the same as the template name - kept as a separate field for backwards compatibility
  • publish_code string the full HTML code of the template, with mc:edit attributes marking the editable elements that are available as published, if it has been published
  • publish_subject string the subject line of the template, if provided
  • publish_from_email string the default sender address for the template, if provided
  • publish_from_name string the default sender from name for the template, if provided
  • publish_text string the default text part of messages sent with the template, if provided
  • published_at string the date and time the template was last published as a UTC string in YYYY-MM-DD HH:MM:SS format, or null if it has not been published
  • created_at string the date and time the template was first created as a UTC string in YYYY-MM-DD HH:MM:SS format
  • updated_at string the date and time the template was last modified as a UTC string in YYYY-MM-DD HH:MM:SS format

getList()

Return a list of all the templates available to this user.

public getList([string $label = null ]) : array<string|int, mixed>
Parameters
$label : string = null

an optional label to filter the templates

Return values
array<string|int, mixed>

an array of structs with information about each template

  • return[] struct the information on each template in the account
  • slug string the immutable unique code name of the template
  • name string the name of the template
  • labels array the list of labels applied to the template
  • labels[] string a single label
  • code string the full HTML code of the template, with mc:edit attributes marking the editable elements - draft version
  • subject string the subject line of the template, if provided - draft version
  • from_email string the default sender address for the template, if provided - draft version
  • from_name string the default sender from name for the template, if provided - draft version
  • text string the default text part of messages sent with the template, if provided - draft version
  • publish_name string the same as the template name - kept as a separate field for backwards compatibility
  • publish_code string the full HTML code of the template, with mc:edit attributes marking the editable elements that are available as published, if it has been published
  • publish_subject string the subject line of the template, if provided
  • publish_from_email string the default sender address for the template, if provided
  • publish_from_name string the default sender from name for the template, if provided
  • publish_text string the default text part of messages sent with the template, if provided
  • published_at string the date and time the template was last published as a UTC string in YYYY-MM-DD HH:MM:SS format, or null if it has not been published
  • created_at string the date and time the template was first created as a UTC string in YYYY-MM-DD HH:MM:SS format
  • updated_at string the date and time the template was last modified as a UTC string in YYYY-MM-DD HH:MM:SS format

info()

Get the information for an existing template.

public info(string $name) : struct
Parameters
$name : string

the immutable name of an existing template

Return values
struct

the requested template information

  • slug string the immutable unique code name of the template
  • name string the name of the template
  • labels array the list of labels applied to the template
  • labels[] string a single label
  • code string the full HTML code of the template, with mc:edit attributes marking the editable elements - draft version
  • subject string the subject line of the template, if provided - draft version
  • from_email string the default sender address for the template, if provided - draft version
  • from_name string the default sender from name for the template, if provided - draft version
  • text string the default text part of messages sent with the template, if provided - draft version
  • publish_name string the same as the template name - kept as a separate field for backwards compatibility
  • publish_code string the full HTML code of the template, with mc:edit attributes marking the editable elements that are available as published, if it has been published
  • publish_subject string the subject line of the template, if provided
  • publish_from_email string the default sender address for the template, if provided
  • publish_from_name string the default sender from name for the template, if provided
  • publish_text string the default text part of messages sent with the template, if provided
  • published_at string the date and time the template was last published as a UTC string in YYYY-MM-DD HH:MM:SS format, or null if it has not been published
  • created_at string the date and time the template was first created as a UTC string in YYYY-MM-DD HH:MM:SS format
  • updated_at string the date and time the template was last modified as a UTC string in YYYY-MM-DD HH:MM:SS format

publish()

Publish the content for the template. Any new messages sent using this template will start using the content that was previously in draft.

public publish(string $name) : struct
Parameters
$name : string

the immutable name of an existing template

Return values
struct

the template that was published

  • slug string the immutable unique code name of the template
  • name string the name of the template
  • labels array the list of labels applied to the template
  • labels[] string a single label
  • code string the full HTML code of the template, with mc:edit attributes marking the editable elements - draft version
  • subject string the subject line of the template, if provided - draft version
  • from_email string the default sender address for the template, if provided - draft version
  • from_name string the default sender from name for the template, if provided - draft version
  • text string the default text part of messages sent with the template, if provided - draft version
  • publish_name string the same as the template name - kept as a separate field for backwards compatibility
  • publish_code string the full HTML code of the template, with mc:edit attributes marking the editable elements that are available as published, if it has been published
  • publish_subject string the subject line of the template, if provided
  • publish_from_email string the default sender address for the template, if provided
  • publish_from_name string the default sender from name for the template, if provided
  • publish_text string the default text part of messages sent with the template, if provided
  • published_at string the date and time the template was last published as a UTC string in YYYY-MM-DD HH:MM:SS format, or null if it has not been published
  • created_at string the date and time the template was first created as a UTC string in YYYY-MM-DD HH:MM:SS format
  • updated_at string the date and time the template was last modified as a UTC string in YYYY-MM-DD HH:MM:SS format

render()

Inject content and optionally merge fields into a template, returning the HTML that results.

public render(string $templateName, array<string|int, mixed> $templateContent[, array<string|int, mixed> $mergeVars = null ]) : struct
Parameters
$templateName : string

the immutable name of a template that exists in the user's account

$templateContent : array<string|int, mixed>

an array of template content to render. Each item in the array should be a struct with two keys - name: the name of the content block to set the content for, and content: the actual content to put into the block

  • template_content[] struct the injection of a single piece of content into a single editable region
  • name string the name of the mc:edit editable region to inject into
  • content string the content to inject
$mergeVars : array<string|int, mixed> = null

optional merge variables to use for injecting merge field content. If this is not provided, no merge fields will be replaced.

  • merge_vars[] struct a single merge variable
  • name string the merge variable's name. Merge variable names are case-insensitive and may not start with _
  • content string the merge variable's content
Return values
struct

the result of rendering the given template with the content and merge field values injected

  • html string the rendered HTML as a string

timeSeries()

Return the recent history (hourly stats for the last 30 days) for a template.

public timeSeries(string $name) : array<string|int, mixed>
Parameters
$name : string

the name of an existing template

Return values
array<string|int, mixed>

the array of history information

  • return[] struct the stats for a single hour
  • time string the hour as a UTC date string in YYYY-MM-DD HH:MM:SS format
  • sent integer the number of emails that were sent during the hour
  • hard_bounces integer the number of emails that hard bounced during the hour
  • soft_bounces integer the number of emails that soft bounced during the hour
  • rejects integer the number of emails that were rejected during the hour
  • complaints integer the number of spam complaints received during the hour
  • opens integer the number of emails opened during the hour
  • unique_opens integer the number of unique opens generated by messages sent during the hour
  • clicks integer the number of tracked URLs clicked during the hour
  • unique_clicks integer the number of unique clicks generated by messages sent during the hour

update()

Update the code for an existing template. If null is provided for any fields, the values will remain unchanged.

public update(string $name[, string $fromEmail = null ][, string $fromName = null ][, string $subject = null ][, string $code = null ][, string $text = null ][, bool $publish = true ][, array<string|int, mixed> $labels = null ]) : struct
Parameters
$name : string

the immutable name of an existing template

$fromEmail : string = null

the new default sending address

$fromName : string = null

the new default from name

$subject : string = null

the new default subject line

$code : string = null

the new code for the template

$text : string = null

the new default text part to be used

$publish : bool = true

set to false to update the draft version of the template without publishing

$labels : array<string|int, mixed> = null

an optional array of up to 10 labels to use for filtering templates

  • labels[] string a single label
Return values
struct

the template that was updated

  • slug string the immutable unique code name of the template
  • name string the name of the template
  • labels array the list of labels applied to the template
  • labels[] string a single label
  • code string the full HTML code of the template, with mc:edit attributes marking the editable elements - draft version
  • subject string the subject line of the template, if provided - draft version
  • from_email string the default sender address for the template, if provided - draft version
  • from_name string the default sender from name for the template, if provided - draft version
  • text string the default text part of messages sent with the template, if provided - draft version
  • publish_name string the same as the template name - kept as a separate field for backwards compatibility
  • publish_code string the full HTML code of the template, with mc:edit attributes marking the editable elements that are available as published, if it has been published
  • publish_subject string the subject line of the template, if provided
  • publish_from_email string the default sender address for the template, if provided
  • publish_from_name string the default sender from name for the template, if provided
  • publish_text string the default text part of messages sent with the template, if provided
  • published_at string the date and time the template was last published as a UTC string in YYYY-MM-DD HH:MM:SS format, or null if it has not been published
  • created_at string the date and time the template was first created as a UTC string in YYYY-MM-DD HH:MM:SS format
  • updated_at string the date and time the template was last modified as a UTC string in YYYY-MM-DD HH:MM:SS format

        
On this page

Search results