Postmark
Postmark API

Templates

Create, edit, validate, list and push email templates and layouts.


List templates

GET
https://api.postmarkapp.com
/templates

Lists the templates on the server with brief details. Filter by type with templateType or by wrapping layout with layoutTemplate.

List templates › query Parameters

count
​integer · min: 1 · max: 500 · required

Number of records to return per request. Max 500.

offset
​integer · min: 0 · required

Number of records to skip.

templateType
​TemplateType · enum

Filter by template type. Defaults to all types.

Standard templates render a full message; Layout templates wrap the content of Standard templates.

Enum values:
Standard
Layout
Example: Standard
layoutTemplate
​string

Filter to templates that use the given Layout template alias.

List templates › Responses

A page of templates.

Paged list of templates.
TotalCount
​integer · required

Number of templates matching the request.

Example: 2
​TemplateSummary[] · required

Templates for the requested page.

Example: [{"Active":true,"TemplateId":1234567,"Name":"Onboarding Email","Alias":"onboarding-v1","TemplateType":"Standard","LayoutTemplate":"my-layout"}]

Create a template

POST
https://api.postmarkapp.com
/templates

Creates a Standard or Layout template on the server. Standard templates need a Subject and at least one of HtmlBody or TextBody.

Create a template › Request Body

Details of the template to create.
Name
​string · required

Template name.

Example: Onboarding Email
Subject
​string

Subject template. Required for Standard templates.

Example: Hello from {{company.name}}!
HtmlBody
​string

HTML body template. HtmlBody or TextBody is required.

Example: <html><body>Hello, {{name}}!</body></html>
TextBody
​string

Plain-text body template.

Example: Hello, {{name}}!
Alias
​string | null

Unique alias used to reference the template when sending.

Example: onboarding-v1
TemplateType
​TemplateType · enum

Standard templates render a full message; Layout templates wrap the content of Standard templates.

Enum values:
Standard
Layout
Example: Standard
LayoutTemplate
​string | null

Alias of the Layout template that wraps this template, if any.

Example: my-layout

Create a template › Responses

The created template.

The created template. Field of `CreateTemplateResponse`.
TemplateId
​integer

ID of the new template.

Example: 1234567

Template name.

Example: Onboarding Email
Active
​boolean

Whether the template is active.

Example: true

Unique alias used to reference the template when sending.

Example: onboarding-v1
TemplateType
​TemplateType · enum

Standard templates render a full message; Layout templates wrap the content of Standard templates.

Enum values:
Standard
Layout
Example: Standard

Alias of the Layout template that wraps this template, if any.

Example: my-layout

Push templates to another server

PUT
https://api.postmarkapp.com
/templates/push

Copies all templates that have aliases from one server to another on the same account. Set PerformChanges to false to preview the changes without applying them. Requires an account token.

Push templates to another server › Request Body

Push all templates with aliases from one server to another.
SourceServerID
​integer · required

ID of the server to copy templates from.

Example: 997287
DestinationServerID
​integer · required

ID of the server to copy templates to.

Example: 997285
PerformChanges
​boolean · required

true applies the push; false only previews what would change.

Example: true

Push templates to another server › Responses

Templates pushed, or that would be pushed in preview mode.

Result of a template push.
TotalCount
​integer · required

Number of templates affected.

Example: 2
​object[] · required

Templates pushed or that would be pushed.

Example: [{"Action":"Create","TemplateId":1234567,"Alias":"onboarding-v1","Name":"Onboarding Email","TemplateType":"Standard"}]

Validate a template

POST
https://api.postmarkapp.com
/templates/validate

Checks template syntax and returns per-part validation results, an optional rendered preview and a suggested template model.

Validate a template › Request Body

Template content to validate. At least one of `Subject`, `HtmlBody` or `TextBody` is required.
Subject
​string

Subject template to validate.

Example: {{#company}}{{name}}{{/company}} {{subjectHeadline}}
HtmlBody
​string

HTML body template to validate.

Example: {{#company}}{{address}}{{/company}}{{#each person}} {{name}} {{/each}}
TextBody
​string

Plain-text body template to validate.

Example: {{#company}}{{phone}}{{/company}}{{#each person}} {{name}} {{/each}}
​object

Model used to render a preview. If omitted, a suggested model is returned.

Example: {"userName":"bobby joe"}
InlineCssForHtmlTestRender
​boolean

Inline CSS when rendering the HTML preview. Defaults to true.

Example: true
TemplateType
​TemplateType · enum

Standard templates render a full message; Layout templates wrap the content of Standard templates.

Enum values:
Standard
Layout
Example: Standard

Alias of the Layout template that wraps this template, if any.

Example: my-layout

Validate a template › Responses

Validation results.

Validation outcome for a template.
AllContentIsValid
​boolean · required

true only if every supplied part is valid.

Example: true
​TemplateValidationResult

Validation result for one part of the template.

​TemplateValidationResult

Validation result for one part of the template.

Validation result for one part of the template.

​object

A model with the variables the template appears to use.

Example: {"name":"name_Value","company":{"address":"address_Value"}}

Get a template

GET
https://api.postmarkapp.com
/templates/{templateIdOrAlias}

Returns a template, including its subject and bodies.

Get a template › path Parameters

templateIdOrAlias
​string · required

Template ID (integer) or template alias (string).

Get a template › Responses

The template.

A full template record.
TemplateId
​integer

Unique ID of the template.

Example: 1234567

Template name.

Example: Onboarding Email

Subject template.

Example: Hello from {{company.name}}!

HTML body template.

Example: <html><body>Hello, {{name}}!</body></html>

Plain-text body template.

Example: Hello, {{name}}!
AssociatedServerId
​integer

ID of the server the template belongs to.

Example: 12345
Active
​boolean

Whether the template is active and can be used for sending.

Example: true

Unique alias used to reference the template when sending.

Example: onboarding-v1
TemplateType
​TemplateType · enum

Standard templates render a full message; Layout templates wrap the content of Standard templates.

Enum values:
Standard
Layout
Example: Standard

Alias of the Layout template that wraps this template, if any.

Example: my-layout

Edit a template

PUT
https://api.postmarkapp.com
/templates/{templateIdOrAlias}

Updates a template. Omitted fields are left unchanged.

Edit a template › path Parameters

templateIdOrAlias
​string · required

Template ID (integer) or template alias (string).

Edit a template › Request Body

Fields to change. Omitted fields are left unchanged. Field of `EditTemplateRequest`.

Template name.

Example: Onboarding Email
Subject
​string

Subject template.

Example: Hello from {{company.name}}!
HtmlBody
​string

HTML body template.

Example: <html><body>Hello, {{name}}!</body></html>

Plain-text body template.

Example: Hello, {{name}}!

Unique alias used to reference the template when sending.

Example: onboarding-v1

Alias of the Layout template that wraps this template, if any.

Example: my-layout

Edit a template › Responses

The updated template.

The created template. Field of `CreateTemplateResponse`.
TemplateId
​integer

ID of the new template.

Example: 1234567

Template name.

Example: Onboarding Email
Active
​boolean

Whether the template is active.

Example: true

Unique alias used to reference the template when sending.

Example: onboarding-v1
TemplateType
​TemplateType · enum

Standard templates render a full message; Layout templates wrap the content of Standard templates.

Enum values:
Standard
Layout
Example: Standard

Alias of the Layout template that wraps this template, if any.

Example: my-layout

Delete a template

DELETE
https://api.postmarkapp.com
/templates/{templateIdOrAlias}

Permanently deletes a template. A Layout template that other templates depend on cannot be deleted (error code 1130).

Delete a template › path Parameters

templateIdOrAlias
​string · required

Template ID (integer) or template alias (string).

Delete a template › Responses

The template was deleted.

Generic response returned by operations that only report a result code and message.
ErrorCode
​integer · required

Postmark API error code. 0 means the request succeeded. See the API error code table in the API description.

Example: 0
Message
​string · required

Human-readable result of the request.

Example: OK