The Sendkit API lets you send emails using a Sendkit template and personalize their content for each recipient.
To use a template and pass personalization data, the following two headers are required:
X-SKT-TEMPLATE : selects the Sendkit template to use.
X-SKT-SUB : passes personalization data for each recipient.
The template you use must be created in Sendkit under “My campaigns.” It is not possible to call a Studio template directly via the API. However, you can create a Sendkit template using a Studio template as a base.
In the following example:
the template used is called name1;
the personalization fields are FirstName and LastName.
curl --request POST \
--url https://api.sarbacane.com/sendkit/email/send \
--header 'content-type: application/json' \
--header 'x-apikey: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' \
--data '{
"to": [
{
"address": "[email protected]"
}
],
"msg": {
"from": {
"address": "[email protected]",
"personalName": "Frank Sender"
},
"replyTo": {
"personalName": "Frank Sender",
"address": "[email protected]"
},
"subject": ".",
"html": "."
},
"headers": {
"X-SKT-TEMPLATE": "name1",
"X-SKT-SUB": [
{
"email": "[email protected]",
"values": {
"FirstName": "John",
"LastName": "Doe"
},
"meta": {
"orderId": 1234567890,
"shipmentId": 123456789
}
}
],
"X-SKT-TEXTVERSION": 1,
"X-SKT-TAGS": [
"Test",
"Sendkit",
"Shipping",
"Hello"
]
}
}'
Important : the html field is required
In the example above, the content is simply ".", because it will be automatically replaced with the content of the template specified in X-SKT-TEMPLATE.
The X-SKT-SUB header allows you to transmit data specific to each recipient.
It can notably be used to:
replace dynamic variables;
personalize email content for each recipient;
add business data;
personalize the subject;
manage conditional content;
transmit data that is not displayed in the email.
There are many possibilities. For example, you can use data from your information system to:
display complementary products;
modify certain content or CSS elements;
generate a different subject for each recipient;
display information related to an order or delivery.
You can add variables to the content of your template.
For example:
Hello {{FirstName}} {{LastName}},
Then pass the corresponding values in X-SKT-SUB:
"values": {
"FirstName": "John",
"LastName": "Doe"
}
The X-SKT-META header allows you to add custom key-value elements. The elements contained in the meta header are not present in the destination email. Only webhooks allow you to retrieve this information and process it in your system.
For example, it can contain:
a user ID;
an order number;
a delivery ID;
any other data that can be used to link to your information system.
Example:
"meta": {
"unique_id": "987654321",
"order_id": "132456798",
"shipment_id": "1237498798"
}
Note: if a key exists in both X-SKT-META and X-SKT-SUB, the SUB value takes priority.
The X-SKT-TEXTVERSION header automatically generates a text version from the HTML content of the email.
Example:
"X-SKT-TEXTVERSION": 1
The X-SKT-TAGS header lets you associate tags with the email to filter and analyze statistics in Sendkit. This allows you to distinguish between emails such as "password reset" or "welcome" emails, or according to their sources. Tags are of course not visible to your recipients.
Maximum of 5 tags per email;
only the first 5 tags are retained;
Maximum of 50 alphanumeric characters per tag;
special characters are not allowed (@, -, ,, etc.).
Example:
"X-SKT-TAGS": [
"Test",
"Sendkit",
"Shipping",
"Hello"
]
By default, the sending domain is inferred from the sender's address.
The X-SKT-DOMAIN header lets you force the domain used for sending.
Example:
"X-SKT-DOMAIN": "sendkit.example.com"
Important : if the specified domain is not fully configured and validated in Sendkit, a shared domain may be used for sending.
The X-SKT-TRACKING header allows you to enable or disable tracking of interactions with the email.
It allows you in particular to manage:
open tracking;
click tracking.
Example:
"X-SKT-TRACKING": {
"html": {
"open": 1
"click": 1
},
"text": {
"click": 1
}
}
The X-SKT-GOOGLEANALYTICS header lets you enable and customize Google Analytics tracking on links contained in the email.
Example :
"X-SKT-GOOGLEANALYTICS": {
"enable": "1",
"utm_source": "Sendkit_Support",
"utm_medium": "email",
"utm_content": "Test_Sending",
"utm_campaign": "Have_a_look"
}
UTM parameters allow you to identify the source and context of clicks in your analytics tools.
Header | Usage |
X-SKT-TEMPLATE | Select the Sendkit template to use |
X-SKT-SUB | Customize the email for each recipient |
X-SKT-META | Add global data accessible via webhooks |
X-SKT-TEXTVERSION | Generate a text version from the HTML |
X-SKT-TAGS | Add tags to filter and analyze statistics |
X-SKT-DOMAIN | Force the sending domain |
X-SKT-TRACKING | Configure open and click tracking |
X-SKT-GOOGLEANALYTICS | Configure Google Analytics tracking |
With X-SKT-TEMPLATE and X-SKT-SUB, you can use a Sendkit template while dynamically personalizing its content for each recipient.