DocumentationSend with template
Send with template
Use templateVersionId to send published template versions.
Send emails using a published template version instead of inline HTML.
Prerequisites
- Create and publish a template in the dashboard — see Publish workflow.
- Copy the version ID (
clx...) from the template detail page.
SDK example
import { MailingCore } from 'mailingcore-js'
MailingCore.init({ apiKey: process.env.MAILINGCORE_API_KEY! })
const result = await MailingCore.send({
to: '[email protected]',
subject: 'Your order confirmation', // optional override
htmlBody: '<p>Fallback if needed</p>', // required by API; template HTML takes precedence when version is set
templateVersionId: 'clxversion...',
metadata: { orderId: 'ORD-42' },
})
console.log(result.id, result.status)
REST equivalent
curl -X POST "https://api.mailingcore.com/emails/send" \
-H "Authorization: Bearer mc_live_xxxx" \
-H "Content-Type: application/json" \
-d '{
"to": "[email protected]",
"subject": "Welcome",
"htmlBody": "<p>Hi</p>",
"templateVersionId": "clxversion..."
}'
Only published versions can be used for sending. Draft versions return an error.
Multi-locale templates
For campaigns with locale variants, see Locale variants and Locale coverage.