Overview
If you are using transactional email templates, you can use this request to insert personalised information into the templates before the emails are sent. This is especially useful when sending password reminder emails, voucher codes, or account balances.
When using this request, you must specify the template by using the template hash associated with it, provide us with the tag that will be used to personalise the email, and provide the data that will be substituted into the tag when the email is sent.
The Method
API | - | Method |
---|---|---|
REST | POST | https://[Your URL]/api/2.0/trans_mails/template |
XML-RPC | Call | CreateTemplate |
Your method must be structured as follows:
Parameters
Required Parameters
You must specify the template hash, the placeholder tag, and the data that will be substituted into the placeholder when the email is sent.
Property | Type | Description | Default | Required |
---|---|---|---|---|
$identifier | string | This is the unique template identifier, assigned to each template when it is created. | none | yes |
$emails | array | The email addresses which this email must be sent to. | none | yes |
$tags | array | List of common tags in the template. | none | yes |
$unique_tags | array | The unique tags, such as email address or new password, which must be included in the email. | none | yes |
$settings | array | Transactional sending settings, these would be the same as the settings when sending a normal transactional email. | none | yes |
Code Samples
PHP:
$template_hash = 'hash here'; $emails = array('[email protected]' => 'Example name'); $common_tags = array('common_tag_placeholder' => 'Common tag data'); $unique_tags = array('[email protected]' => array('unique_tag_placeholder' => 'unique tag data')); $result = $api->send($template_hash, $emails, $common_tags = [], $unique_tags = [], $attachments = []);
JSON:
{ "identifier": "sJWnzzH5VzOiZ8Ki", "emails": {"[email protected]": "Example name"}, 'settings': {}, 'tags' : {"common_tag_placeholder": "Common data"} 'unique_tags' : {"[email protected]": {"unique_tag_placeholder": "Unique data"}} }