Templates
Manage the Templates in your account.
List template
Return a list of all the templates available to this user.
POST template/list
Body Parameters
- key REQUIRED
string
a valid api key - label
string
an optional label to filter the templates
List templates
curl -X POST \ https://api.squalomail.com/mc/v3/transactional/templates/list \ -d '{"key":"","label":""}'
Success Response
HTTP Status 200
an array of structs with information about each template
- Array
object[]
the information on each template in the account
Properties
- slug
string
the immutable unique code name of the template - name
string
the name of the template - labels
string[]
the list of labels applied to the template - 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 forma
Example response
JSON
[
{
"slug": "string",
"name": "string",
"labels": [
"string"
],
"code": "string",
"subject": "string",
"from_email": "string",
"from_name": "string",
"text": "string",
"publish_name": "string",
"publish_code": "string",
"publish_subject": "string",
"publish_from_email": "user@example.com",
"publish_from_name": "string",
"publish_text": "string",
"published_at": "2019-08-24T14:15:22Z",
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z"
}
]}
Send using message template
Send a new transactional message through the Transactional API using a template.
POST /messages/send-template
Body Parameters
- key REQUIRED
string
a valid api key - template_name REQUIRED
string
the immutable name or slug of a template that exists in the user’s account. For backwards-compatibility, the template name may also be used but the immutable slug is preferred. Example: “[123] newsletter name” where [123] is the Id of the newsletter and newsletter name is the name of the newsletter. - template_content REQUIRED
string
an array of template content to send.
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 blockProperties
- name
string
an array of template content to send. the name of the mc: edit editable region to inject
into - content
string
the content to inject
- name
- message REQUIRED
object
the other information on the message to send – same as /messages/send, but without the html contentProperties- to
object[]
an array of recipient information.Properties
- email
string
the email address of the recipient - name
string
string the optional display name to use for the
recipient - type
string
the header type to use for the recipient,
defaults to “to” if not provided Possible
values: “to”</code >, “cc”</code >, or “bcc”</code >.
- email
- global_merge_vars
object[]
global merge variables to use for all recipients. You
can override these per recipient.Properties
- name
string
the global merge variable’s name. Merge
variable names are case-insensitive and may not start with _ - content
string
the global merge variable’s content
- name
- merge_vars
object[]
per-recipient merge variables, which override global merge variables with the same name.Properties- rcpt
string
the email address of the recipient that the merge variables should apply to - vars
object[]
the recipient’s merge variablesProperties- 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
- name
- rcpt
- attachments
object[]
an array of supported attachments to add to the
message-
Properties
- type
string
the MIME type of the attachment - name
string
an associated array containing the recipient’s unique metadata. If a key exists in both the per-recipient metadata and the global metadata, the per-recipient metadata will be used. - content
string
string the content of the attachment as a base64-encoded string
- type
-
- to
- send_at
string
when this message should be sent as a UTC timestamp in
YYYY-MM-DD HH:MM:SS format. If you specify a time in the past, the
message will be sent immediately; for future dates, you’re limited to
one year from the date of scheduling.
Send using message template
curl -X POST \
https://api.squalomail.com/mc/v3/transactional/messages/send-template \
-d '{"key":"","template_name":"","template_content":[],"message":{"to":[],"global_merge_vars":[],"merge_vars":[],"attachments":[],},"send_at":""}'' \
Success Response
HTTP Status 200
an array of objects for each recipient containing the key “email” with the email address, and details of the message status for that
recipient
- Array
object[]
the sending results for a single recipientProperties
- email
string
the email address of the recipient - status
string
the sending status of the recipient Possible
values: “sent”</code >, “queued”</code >, “rejected”</code >, or “invalid”</code >. - reject_reason
string
the sending status of the recipient Possible
the reason for the rejection if the recipient
status is “rejected” Possible values: “hard-bounce”</code >, “soft-bounce”</code >, “spam”</code >, “unsub”</code >, “custom”</code >, “invalid-sender”</code >, “invalid”</code >, “test-mode-limit”</code >, “unsigned”</code >, or “rule”</code >. - _id
string
the message’s unique id
- email
Example response
[ { "email": "user@example.com", "status": "sent", "reject_reason": "hard-bounce", "_id": "string" } ]