Lets you manage templates for a specific server.
Please note that a Server may have up to 100 templates. Requests that exceed this limit won't be processed. Please contact support if you need more Templates within a Server.
Accept |
required application/json |
---|---|
Content-Type |
required application/json |
X-Postmark-Server-Token |
required This request requires server level privileges. This token can be found on the API Tokens tab under your Postmark server. |
curl "https://api.postmarkapp.com/email/withTemplate" \
-X POST \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Postmark-Server-Token: server token" \
-d '{
"From": "sender@example.com",
"To": "receiver@example.com",
"TemplateId": 1234,
"TemplateModel": {
"user_name": "John Smith"
}
}'
TemplateId | integer |
required The template to use when sending this message. Required if |
---|---|---|
TemplateAlias | string |
required The alias of a template to use when sending this message. Required if |
TemplateModel | object |
required The model to be applied to the specified template to generate |
InlineCss | boolean |
By default, if the specified template contains an |
From | string |
required The sender email address. Must have a registered and confirmed Sender Signature. To include a name, use the format
|
To | string |
required Recipient email address. Multiple addresses are comma separated. Max 50. |
Cc | string |
Cc recipient email address. Multiple addresses are comma separated. Max 50. |
Bcc | string |
Bcc recipient email address. Multiple addresses are comma separated. Max 50. |
Tag | string |
Email tag that allows you to categorize outgoing emails and get detailed statistics. Max characters 1000. |
ReplyTo | string |
Reply To override email address. Defaults to the Reply To set in the sender signature. |
Headers | array |
List of custom headers to include. |
TrackOpens | boolean |
Activate open tracking for this email. |
TrackLinks | string |
Activate link tracking for links in the HTML or Text bodies of this email. Possible options: |
Attachments | array |
List of attachments |
Metadata | object |
Custom metadata key/value pairs. |
MessageStream | string |
Set message stream ID that's used for sending. If not provided, message will default to the |
{
"TemplateId": 1234,
"TemplateModel": {
"user_name": "John Smith",
"company": {
"name": "ACME"
}
},
"InlineCss": true,
"From": "sender@example.com",
"To": "receiver@example.com",
"Cc": "copied@example.com",
"Bcc": "blank-copied@example.com",
"Tag": "Invitation",
"ReplyTo": "reply@example.com",
"Headers": [
{
"Name": "CUSTOM-HEADER",
"Value": "value"
}
],
"TrackOpens": true,
"TrackLinks": "None",
"Attachments": [
{
"Name": "readme.txt",
"Content": "dGVzdCBjb250ZW50",
"ContentType": "text/plain"
},
{
"Name": "report.pdf",
"Content": "dGVzdCBjb250ZW50",
"ContentType": "application/octet-stream"
}
],
"Metadata": {
"color":"blue",
"client-id":"12345"
},
"MessageStream": "outbound"
}
To | string |
Recipient email address |
---|---|---|
SubmittedAt | string |
Timestamp |
MessageID | string |
ID of message |
ErrorCode | integer | |
Message | string |
Response message |
HTTP/1.1 200 OK
Content-Type: application/json
{
"To": "receiver@example.com",
"SubmittedAt": "2014-02-17T07:25:01.4178645-05:00",
"MessageID": "0a129aee-e1cd-480d-b08d-4f48548ff48d",
"ErrorCode": 0,
"Message": "OK"
}
Content-Type |
required application/json |
---|---|
Accept |
required application/json |
X-Postmark-Server-Token |
required This request requires server level privileges. This token can be found from the API Tokens tab under your Postmark server. |
curl "https://api.postmarkapp.com/email/batchWithTemplates" \
-X POST \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Postmark-Server-Token: server token" \
-d '{
"Messages": [
{
"From": "sender@example.com",
"To": "receiver1@example.com",
"TemplateId": 12345,
"TemplateModel": {
"fizz": "buzz"
}
},
{
"From": "sender@example.com",
"To": "receiver2@example.com",
"TemplateAlias": "welcome-notification",
"TemplateModel": {
"fizz": "buzz"
}
}
]
}'
Messages | array |
required The list of templates to send. Please note that we accept up to 500 messages per API call. |
---|---|---|
TemplateAlias | string |
The template to use for this message. This value is required if TemplateId is not supplied. If both are supplied, TemplateId will be used to select the template. |
TemplateId | integer |
The template to use for this message. This value is required if TemplateAlias is not supplied. If both are supplied, TemplateId will be used to select the template. |
From | string |
required The sender email address. Must have a registered and confirmed Sender Signature. To include a name, use the format
|
To | string |
required Recipient email address. Multiple addresses are comma separated. Max 50. |
Cc | string |
Cc recipient email address. Multiple addresses are comma separated. Max 50. |
Bcc | string |
Bcc recipient email address. Multiple addresses are comma separated. Max 50. |
Tag | string |
Email tag that allows you to categorize outgoing emails and get detailed statistics. Max characters 1000. |
ReplyTo | string |
Reply To override email address. Defaults to the Reply To set in the sender signature. |
Headers | array |
List of custom headers to include. |
TrackOpens | boolean |
Activate open tracking for this email. |
TrackLinks | string |
Activate link tracking for links in the HTML or Text bodies of this email. Possible options: |
Attachments | array |
List of attachments |
Metadata | object |
Custom metadata key/value pairs. |
MessageStream | string |
Set message stream ID that's used for sending. If not provided, message will default to the |
{
"Messages": [
{
"From": "sender@example.com",
"To": "receiver@example.com",
"Cc": "copied@example.com",
"Bcc": "blank-copied@example.com",
"Tag": "Invitation",
"ReplyTo": "reply@example.com",
"TemplateAlias": "invitation-letter",
"TemplateModel": {
"fizz": "buzz"
},
"Headers": [
{
"Name": "CUSTOM-HEADER",
"Value": "value"
}
],
"TrackOpens": true,
"TrackLinks": "None",
"Attachments": [
{
"Name": "readme.txt",
"Content": "dGVzdCBjb250ZW50",
"ContentType": "text/plain"
},
{
"Name": "report.pdf",
"Content": "dGVzdCBjb250ZW50",
"ContentType": "application/octet-stream"
},
{
"Name": "image.jpg",
"ContentID": "cid:image.jpg",
"Content": "dGVzdCBjb250ZW50",
"ContentType": "image/jpeg"
}
],
"Metadata": {
"color":"blue",
"client-id":"12345"
},
"MessageStream": "outbound"
}
]
}
Please note that the /batchWithTemplates
endpoint will return a 200-level http status, even when validation for individual messages may fail. Users of these endpoints should check the success and error code for each message in the response from our API (the results are ordered the same as the original messages).
To | string |
Recipient email address |
---|---|---|
SubmittedAt | string |
Timestamp |
MessageID | string |
ID of message |
ErrorCode | integer | |
Message | string |
Response message |
HTTP/1.1 200 OK
Content-Type: application/json
[
{
"ErrorCode": 0,
"Message": "OK",
"MessageID": "b7bc2f4a-e38e-4336-af7d-e6c392c2f817",
"SubmittedAt": "2010-11-26T12:01:05.1794748-05:00",
"To": "receiver1@example.com"
},
{
"ErrorCode": 406,
"Message": "You tried to send to a recipient that has been marked as inactive. Found inactive addresses: example@example.com. Inactive recipients are ones that have generated a hard bounce, a spam complaint, or a manual suppression.",
}
]
Push all templates with changes to another server. If the template already exists on the destination server, the template will be updated. If the template does not exist on the destination server, it will be created and assigned the alias of the template on the source server.
Accept |
required application/json |
---|---|
Content-Type |
required application/json |
X-Postmark-Account-Token |
required This request requires account level privileges. Only accessible by the account owner, this token can be found on the API Tokens tab of your Postmark account. |
curl "https://api.postmarkapp.com/templates/push" \
-X PUT \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Postmark-Account-Token: account token" \
-d '{
"SourceServerID": 997287,
"DestinationServerID": 997285,
"PerformChanges": true
}'
SourceServerID | string |
required Server ID of the source server containing the templates that will be pushed. |
---|---|---|
DestinationServerID | string |
required Server ID of the destination server receiving the pushed templates. |
PerformChanges | boolean |
required Specifies whether to push templates to destination server or not. This parameter can be set to |
{
"SourceServerID": 997287 ,
"DestinationServerID":997285 ,
"PerformChanges": true
}
TotalCount | integer |
Indicates the total number of template changes. |
---|---|---|
Templates | object |
List of affected templates on the destination server. |
Action | string |
Value will be Create or Edit, depending on whether the pushed template will modify an existing template on the destination server or create a new template. |
Alias | string |
Template alias |
Name | string |
Name of the template. |
TemplateType | string |
The type of template in changeset pushed. Possible options: |
HTTP/1.1 200 OK
Content-Type: application/json
{
"TotalCount": 1,
"Templates": [
{
"Action": "Create",
"TemplateId": 7270,
"Alias": "comment-notification",
"Name": "Comment notification",
"TemplateType": "Standard"
}
]
}
Accept |
required application/json |
---|---|
X-Postmark-Server-Token |
required This request requires server level privileges. This token can be found from the API Tokens tab under your Postmark server. |
curl "https://api.postmarkapp.com/templates/{templateIdOrAlias}" \
-X GET \
-H "Accept: application/json" \
-H "X-Postmark-Server-Token: server token"
TemplateId | integer |
ID of template |
---|---|---|
Name | string |
Name of template |
Subject | string |
The content to use for the Subject when this template is used to send email. |
HtmlBody | string |
The content to use for the HtmlBody when this template is used to send email. |
TextBody | string |
The content to use for the TextBody when this template is used to send email. |
AssociatedServerId | integer |
The ID of the Server with which this template is associated. |
Active | boolean |
Indicates that this template may be used for sending email. |
Alias | string |
An optional string you can provide to identify this Template. Allowed characters are numbers, ASCII letters, and ‘.’, ‘-’, ‘_’ characters, and the string has to start with a letter. |
TemplateType | string |
The type of template returned. Possible options: |
LayoutTemplate | string |
If returned template is a standard template and uses a layout template, this returns the layout template alias. |
HTTP/1.1 200 OK
Content-Type: application/json
{
"Name": "Onboarding Email",
"TemplateId": 1234,
"Subject": "Hi there, {{Name}}",
"HtmlBody": "Hello dear Postmark user. {{Name}}",
"TextBody": "{{Name}} is a {{Occupation}}",
"AssociatedServerId": 1,
"Active": false,
"Alias": "onboarding-v1",
"TemplateType": "Standard",
"LayoutTemplate": "my-layout"
},
{
"Name": "Receipt Email",
"TemplateId": 1235,
"Subject": "Receipt for {{ product_name }}",
"HtmlBody": "<body><span class="preheader">This is a receipt for {{ product_name }}...",
"TextBody": "This is a receipt for {{ product_name }}",
"AssociatedServerId": 1,
"Active": false,
"Alias": "receipt-v1",
"TemplateType": "Standard",
"LayoutTemplate": "null"
}
Accept |
required application/json |
---|---|
Content-Type |
required application/json |
X-Postmark-Server-Token |
required This request requires server level privileges. This token can be found from the API Tokens tab under your Postmark server. |
curl "https://api.postmarkapp.com/templates" \
-X POST \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Postmark-Server-Token: server token" \
-d '{
"Name": "Welcome Email",
"Alias": "onboarding-v1",
"HtmlBody": "<html><body>Hello{{name}}<body><html>",
"TextBody": "Hello, {{name}}",
"Subject": "Hello, from {{company.name}}",
"TemplateType": "Standard",
"LayoutTemplate": "my-layout"
}'
Name | string |
required Name of template |
---|---|---|
Alias | string |
An optional string you can provide to identify this template (if creating a standard template). Allowed characters are numbers, ASCII letters, and ‘.’, ‘-’, ‘_’ characters, and the string has to start with a letter. |
HtmlBody | string |
required The content to use for the HtmlBody when this template is used to send email. Required if A content placeholder is required to be present for a layout template, and can be placed only once in the HtmlBody. |
TextBody | string |
required The content to use for the TextBody when this template is used to send email. Required if A content placeholder is required to be present for a layout template, and can be placed only once in the TextBody. |
Subject | string |
required The content to use for the Subject when this template is used to send email. Subject is only required on standard templates. See our template language documentation for more information on the syntax for this field. Subjects are not allowed for layout templates and will result in an API error. |
TemplateType | string |
Available when creating a template. To set if a template is standard template or layout template. Possible options: |
LayoutTemplate | string |
An optional string to specify which Layout Template to use (via layout alias) for an existing Layout Template when creating a standard template. Allowed characters are numbers, ASCII letters, and ‘.’, ‘-’, ‘_’ characters, and the string has to start with a letter. The API will throw an error if |
{
"Name": "Onboarding Email",
"Subject": "Hello from {{company.name}}!",
"TextBody": "Hello, {{name}}!",
"HtmlBody": "<html><body>Hello, {{name}}!</body></html>",
"TemplateType": "Standard",
"Alias": "onboarding-v1",
"LayoutTemplate": "my-layout"
}
TemplateId | integer |
ID of template. |
---|---|---|
Name | string |
Name of template. |
Active | boolean |
Indicates that this template may be used for sending email. |
Alias | string |
Template alias (or |
TemplateType | string |
Type of template. Possible options: |
LayoutTemplate | string |
Alias of layout used. |
HTTP/1.1 200 OK
Content-Type: application/json
{
"TemplateId": 1234,
"Name": "Onboarding Email",
"Active": true,
"Alias": "onboarding-v1",
"TemplateType": "Standard",
"LayoutTemplate": "my-layout"
}
Accept |
required application/json |
---|---|
Content-Type |
required application/json |
X-Postmark-Server-Token |
required This request requires server level privileges. This token can be found from the API Tokens tab under your Postmark server. |
curl "https://api.postmarkapp.com/templates/{templateIdOrAlias}" \
-X PUT \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Postmark-Server-Token: server token" \
-d '{
"Name": "Onboarding Email",
"Subject": "Hello from {{company.name}}!",
"TextBody": "Hello, {{name}}!",
"HtmlBody": "<html><body>Hello, {{name}}!</body></html>",
"Alias": "welcome-v1"
}'
Name | string |
required Name of template |
---|---|---|
Subject | string |
required The content to use for the Subject when this template is used to send email. See our template language documentation for more information on the syntax for this field. |
HtmlBody | string |
required The content to use for the HtmlBody when this template is used to send email. Required if |
TextBody | string |
required The content to use for the TextBody when this template is used to send email. Required if |
Alias | string |
An optional string you can provide to identify this Template. Allowed characters are numbers, ASCII letters, and ‘.’, ‘-’, ‘_’ characters, and the string has to start with a letter. |
LayoutTemplate | string |
An optional string to specify which Layout Template to use (via layout alias) for an existing Layout Template when creating a standard template. Allowed characters are numbers, ASCII letters, and ‘.’, ‘-’, ‘_’ characters, and the string has to start with a letter. The API will throw an error if LayoutTemplate is present and the template type is a Layout. This field can also be set to null by using an empty string "". |
{
"Name": "Onboarding Email",
"Subject": "Hello from {{company.name}}!",
"TextBody": "Hello, {{name}}!",
"HtmlBody": "<html><body>Hello, {{name}}!</body></html>",
"Alias": "welcome-v1",
"LayoutTemplate": "my-layout"
}
TemplateId | integer |
ID of template |
---|---|---|
Name | string |
Name of template |
Active | boolean |
Indicates that this template may be used for sending email. |
Alias | string |
Template alias (or |
HTTP/1.1 200 OK
Content-Type: application/json
{
"TemplateId": 1234,
"Name": "Onboarding Email",
"Active": true,
"Alias": "welcome-v1",
"LayoutTemplate": "my-layout"
}
Accept |
required application/json |
---|---|
X-Postmark-Server-Token |
required This request requires server level privileges. This token can be found from the API Tokens tab under your Postmark server. |
curl "https://api.postmarkapp.com/templates?count=100&offset=0&LayoutTemplate=my-layout" \
-X GET \
-H "Accept: application/json" \
-H "X-Postmark-Server-Token: server token"
Count |
required The number of templates to return. |
---|---|
Offset |
required The number of templates to "skip" before returning results. |
TemplateType |
Filters templates based on template type (layout template or standard template). Possible options: |
LayoutTemplate |
Filter results by layout alias. |
TotalCount | integer |
The total number of templates associated with the current server. |
---|---|---|
Templates | array |
A list of templates associated with this server. |
HTTP/1.1 200 OK
Content-Type: application/json
{
"TotalCount": 2,
"Templates": [
{
"Active": true,
"TemplateId": 1234,
"Name": "Password Recovery Email",
"Alias": "password-recovery",
"TemplateType": "Standard",
"LayoutTemplate": "my-layout"
},
{
"Active": true,
"TemplateId": 5678,
"Name": "Default Layout",
"Alias": "my-layout",
"TemplateType": "Layout",
"LayoutTemplate": null
}]
}
Accept |
required application/json |
---|---|
X-Postmark-Server-Token |
required This request requires server level privileges. This token can be found from the API Tokens tab under your Postmark server. |
curl "https://api.postmarkapp.com/templates/{templateIdOrAlias}" \
-X DELETE \
-H "Accept: application/json" \
-H "X-Postmark-Server-Token: server token"
ErrorCode | integer | |
---|---|---|
Message | string |
Associated success or error message. |
HTTP/1.1 200 OK
Content-Type: application/json
{
"ErrorCode": 0,
"Message": "Template 1234 removed."
}
Accept |
required application/json |
---|---|
Content-Type |
required application/json |
X-Postmark-Server-Token |
required This request requires server level privileges. This token can be found from the API Tokens tab under your Postmark server. |
curl "https://api.postmarkapp.com/templates/validate" \
-X POST \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Postmark-Server-Token: server token" \
-d '{
"Subject": "{{#company}}{{name}}{{/company}} {{subjectHeadline}}",
"HtmlBody": "{{#company}}{{address}}{{/company}}{{#each person}} {{name}} {{/each}}",
"TextBody": "{{#company}}{{phone}}{{/company}}{{#each person}} {{name}} {{/each}}",
"TestRenderModel": {
"userName": "bobby joe"
},
"TemplateType": "Standard",
"LayoutTemplate": "my-layout"
}'
Subject | string |
required The subject content to validate. Must be specified if |
---|---|---|
HtmlBody | string |
required The HTML body content to validate. Must be specified if A content placeholder is required to be present to validate a layout template, and can be placed only once in the HtmlBody. |
TextBody | string |
required The plain text body content to validate. Must be specified if A content placeholder is required to be present to validate a layout template, and can be placed only once in the TextBody. |
TestRenderModel | object |
The template model to be used when rendering test content. |
InlineCssForHtmlTestRender | boolean |
When |
TemplateType | string |
Validates templates based on template type (layout template or standard template). Possible options: |
LayoutTemplate | string |
An optional string to specify which layout template alias to use to validate a standard template. If not provided a standard template will not use a layout template. |
{
"Subject": "{{#company}}{{name}}{{/company}} {{subjectHeadline}}",
"HtmlBody": "{{#company}}{{address}}{{/company}}{{#each person}} {{name}} {{/each}}",
"TextBody": "{{#company}}{{phone}}{{/company}}{{#each person}} {{name}} {{/each}}",
"TestRenderModel": {
"userName": "bobby joe"
},
"TemplateType": "Standard",
"LayoutTemplate": "my-layout"
}
AllContentIsValid | boolean |
Indicates all of the template content that was submitted is parseable. Note, we do not "Validate" HTML content to match any HTML standards, simply that we are able to parse the markup, and inline styles. |
---|---|---|
ContentIsValid | boolean |
Whether the supplied content is parseable/renderable by the template system. |
ValidationErrors | array |
An array of validation errors related to the content being validated. This property will never be When the result contains errors, |
RenderedContent | string |
Using the |
SuggestedTemplateModel | object |
A JSON object structure that will provide information for all keys found in the template content submitted. If a |
HTTP/1.1 200 OK
Content-Type: application/json
{
"AllContentIsValid": true,
"HtmlBody": {
"ContentIsValid": true,
"ValidationErrors": [],
"RenderedContent": "address_Value name_Value "
},
"TextBody": {
"ContentIsValid": true,
"ValidationErrors": [{
"Message" : "The syntax for this template is invalid.",
"Line" : 1,
"CharacterPosition" : 1
}],
"RenderedContent": "phone_Value name_Value "
},
"Subject": {
"ContentIsValid": true,
"ValidationErrors": [],
"RenderedContent": "name_Value subjectHeadline_Value"
},
"SuggestedTemplateModel": {
"userName": "bobby joe",
"company": {
"address": "address_Value",
"phone": "phone_Value",
"name": "name_Value"
},
"person": [
{
"name": "name_Value"
}
],
"subjectHeadline": "subjectHeadline_Value"
}
}