This endpoint allows you to send email with your template using any SMTP server.
POST
/templates/{templateId}/send/{integrationId}
Here is a list of features you can achieve:
In order to send an email using this endpoint, you need to have an email template and SMTP integration.
You can create an email template in the dashboard.
To create SMTP integration, you'll need to add your SMTP server login details in the dashboard.
To attach a PDF when sending email, you'll need to create a PDF template in the dashboard.
Top level
Parameter | Type | Required |
---|---|---|
from
Specify sender details |
Object | Yes |
to
Array of recipients. You must specify at least one recipient |
Array | Yes |
variables
Will replace placeholders in the template |
Object | No |
Sender (from
)
Parameter | Type | Required |
---|---|---|
from.email
Must be a valid email address. Also, make sure to use the email address that is associated with your SMTP |
String | Yes |
from.name
Sender name |
String | No |
Recipients (to
)
Parameter | Type | Required |
---|---|---|
to.*.email
Must be a valid email address |
String | Yes |
to.*.name
Recipient name |
String | No |
to.*.variables
Will replace placeholders in the template. Keys with the same name will override top level variables |
Object | No |
to.*.attachments
Array of attachments |
Array | No |
Attachments (to.*.attachments
)
Parameter | Type | Required |
---|---|---|
to.*.attachments.*.id
PDF template ID |
Integer | Yes |
to.*.attachments.*.filename
Filename of the attachment that will be displayed in the email |
string | No |
to.*.attachments.*.variables
Will replace placeholders in the template. Keys with the same name will override top level and recipient variables |
string | No |
You will receive a message that the email was put in the queue.
Response JSON body will contain
status
and
message
fields.
Code | Name | Description |
---|---|---|
200 | OK | Request was accepted successfully |
400 | Bad Request | Request JSON is invalid or missing required parameters |
401 | Unauthorized | Request without a token, or token is invalid |
404 | Not Found | Template with the provided {templateId} does not exist |
Request example:
curl -X POST "https://api.templid.com/v1/templates/{templateId}/send/{integrationId}" \
-H "Authorization: Bearer YOUR_TOKEN_HERE" \
-H "Content-type: application/json" \
-d '{
"from": {
"email": "[email protected]",
"name": "Example company"
},
"to": [
{
"email": "[email protected]",
"name": "John Doe",
"variables": {
"amount": 44.99
}
},
{
"email": "[email protected]",
"name": "Jane Doe",
"variables": {
"amount": 2569.73,
"manager_email": "[email protected]"
},
"attachments": [
{
"id": 39,
"filename": "order-confirmation.pdf",
"variables": {
"order": {
"id": 12345,
"date": "2023-09-25",
"payment_method": "Card"
}
}
},
{
"id": 40,
"filename": "terms-and-conditions.pdf"
}
]
}
],
"variables": {
"manager_email": "[email protected]"
}
}'
Response example:
{
"status": "success",
"message": "Emails was put to the queue. We are sending your messages."
}
Think of SMTP integration as a bridge between your SMTP server and our API. So you don't need to worry about setting up SMTP sending from your application. Simply add your SMTP server details in the dashboard, and you are ready to go. All you need is to make an HTTP request to our API.
/templates/{templateId}/send/{integrationId}
Main benefits of using SMTP integration:
You can attach a PDF template to your email for your recipients.
Here is a list of steps you need to follow in order to send an email with a PDF attachment:
You can define attachment specific variables. Also, you can attach multiple files. This page includes examples to help you understand how to send an email with a PDF attachment.
You can use variables (placeholders) in your email and PDF templates.
When making an API call, you can define variable values in the request body. Variables will be replaced with the actual values passed.
If you define the same variable on multiple levels, the variable on the lowest level will override the higher level:
This way, you can use the same template for multiple recipients and attach PDFs with personalized data.
Let's take a look at the example below.
We have a top level variable name
with the value "Mike".
This variable will be used in case where the recipient object or attachment object does not have the name
variable.
The first recipient has the name
variable with the value "John".
This value will be used in the HTML and PDF templates for the [email protected].
The second recipient has the name
variable with the value "Tom" inside the attachment object.
This value will be used in the PDF template only for [email protected].
And the top level value "Mike" will be used in the HTML template.
In the table below, we show the final result of the values in the HTML and PDF templates:
Recipient | HTML | |
---|---|---|
[email protected] |
John
|
John
|
[email protected] |
Mike
|
Tom
|
{
"from": {...},
"to": [
{
"email": "[email protected]",
"variables": {
"name": "John"
},
"attachments": [
{
"id": 123
}
]
},
{
"email": "[email protected]",
"attachments": [
{
"id": 123,
"variables": {
"name": "Tom"
},
}
]
},
],
"variables": {
"name": "Mike"
}
}
In all the examples below, we will show only the request JSON body.
The request URL will be the same for all examples:
POST https://api.templid.com/v1/templates/{templateId}/send/{integrationId}
Also, the response will be the same for all examples:
{
"status": "success",
"message": "Emails was put to the queue. We are sending your messages."
}
Send an email to the customer with a tracking code after the order has been shipped.
{
"from": {
"email": "[email protected]",
"name": "Business name"
},
"to": [
{
"email": "[email protected]",
"name": "Tom"
}
],
"variables": {
"order_number": "22349",
"tracking_code": "XYZ123"
}
}
Send an email to the customer with the order confirmation.
Attach the PDF with the order details. PDF template ID is 123
.
{
"from": {
"email": "[email protected]",
"name": "Business name"
},
"to": [
{
"email": "[email protected]",
"name": "Tom",
"attachments": [
{
"id": 123,
"filename": "order-confirmation.pdf"
}
]
}
],
"variables": {
"order_number": "22349"
}
}
Send an email to the customer with the order confirmation.
Attach the PDF (id: 123
) with the order details.
Also, attach the terms and conditions PDF (id: 234
).
{
"from": {
"email": "[email protected]",
"name": "Business name"
},
"to": [
{
"email": "[email protected]",
"name": "Tom",
"attachments": [
{
"id": 123,
"filename": "order-confirmation.pdf"
},
{
"id": 234,
"filename": "terms-and-conditions.pdf"
}
]
}
],
"variables": {
"order_number": "22349"
}
}
Send an email to the customer with the order confirmation.
Attach the PDF (id: 123
) with the order details.
Send another email to the store admin with the same email template. Admin will receive email only without PDF attachment.
Our HTML template will have the {{ name }}
and {{ order_number }}
variables.
The {{ order_number }}
variable will be replaced with the value 22349 for all recipients.
The {{ name }}
variable will be replaced with the value Admin for the admin, and Tom for the customer.
{
"from": {
"email": "[email protected]",
"name": "Business name"
},
"to": [
{
"email": "[email protected]",
"name": "Tom",
"variables": {
"name": "Tom"
},
"attachments": [
{
"id": 123,
"filename": "order-confirmation.pdf"
}
]
},
{
"email": "[email protected]",
"name": "Admin",
"variables": {
"name": "Admin"
}
}
],
"variables": {
"order_number": "22349"
}
}
Send an email to multiple recipients with the billing PDF at the end of the month.
All recipients will receive the same email template with the billing PDF attachment.
But each recipient will see a different
amount
in the PDF.
{
"from": {
"email": "[email protected]",
"name": "Business name"
},
"to": [
{
"email": "[email protected]",
"name": "John",
"attachments": [
{
"id": 123,
"filename": "billing.pdf",
"variables": {
"amount": 44.99
}
}
]
},
{
"email": "[email protected]",
"attachments": [
{
"id": 123,
"filename": "billing.pdf",
"variables": {
"amount": 2569.73
}
}
]
}
],
"variables": {
"billing_period": "September 2023"
}
}