{
"to": "",
"submittedAt": 1704067200000000000,
"messageId": "",
"errorCode": 11,
"message": "tpspFrom email must be on the same registered domain as from email"
}
Email
Send Email With Template
Send emails using pre-configured templates stored in SendPost. Templates separate email content from code, enabling:
Benefits:
Update email content without code deployments
Marketing teams can manage templates independently
Consistent branding across all applications
A/B test different template versions
How It Works:
Create templates in the SendPost dashboard with Handlebars variables
Reference the template by name or ID in this API call
{
"to": "",
"submittedAt": 1704067200000000000,
"messageId": "",
"errorCode": 11,
"message": "tpspFrom email must be on the same registered domain as from email"
}
This api key can be used only for sub account level operations
Body
application/json
Email message details with template information
Email message object containing all the details required to send an email.
At minimum, you need to provide from, to, and either subject with htmlBody/textBody or a template.
Optional sender for emails delivered through a third-party sending provider (TPSP): SendGrid, Amazon SES, Mailgun, SparkPost, Postmark, or Custom SMTP. For example, when sending over your SendPost warmup cap overflows to a TPSP pool, those emails go out as tpspFrom instead of from.
Must be on the same registered domain as from. For example, from on agent1.example.com and tpspFrom on agent2.example.com.
It doesn't need to be verified in SendPost, but it must be set up as a sender at the TPSP.
Emails delivered on SendPost IPs still go out as from. Stats and webhook events are always reported under from.
If name is omitted, the from name is used. If replyTo isn't set, replies go to tpspFrom.
If tpspFrom is invalid, the whole request is rejected with HTTP 400 and errorCode 11.
Plain text content of the email. Used as fallback when HTML cannot be rendered.
Also improves deliverability as some spam filters prefer multipart emails.
Example:
"Hello {{firstName}},\n\nWelcome to our platform!\n\nBest regards,\nThe Team"
AMP HTML content for supported email clients (Gmail, Yahoo).
Enables interactive email experiences like carousels, forms, and real-time content.
See https://amp.dev/about/email/ for more details.
Name of a pre-defined template to use for this email.
When specified, the template's subject, htmlBody, and textBody will be used
unless explicitly overridden in this request.
Custom email headers to include in the message.
Common uses: adding List-Unsubscribe headers, custom tracking IDs, or priority flags.
Note: Some headers like From, To, Subject are set automatically and cannot be overridden.
Whether to track email opens using a tracking pixel.
When enabled, a 1x1 transparent image is inserted into the HTML body.
Default: true (if not specified)
Whether to track link clicks by rewriting URLs through SendPost's tracking domain.
When enabled, all links in htmlBody are replaced with tracking URLs.
Default: true (if not specified)
Tags/groups to categorize this email for analytics and reporting.
Use groups to segment your email statistics (e.g., by campaign, email type, or customer segment).
Custom webhook URL to receive events for this specific email.
It receives every event of the email except Validation, in addition to your account webhooks; it doesn't replace them.
Requests to it are signed only when the URL exactly matches an account webhook that has a secret. See Webhook Signature Verification.
Useful for per-email or per-customer webhook routing.
Skip the real-time list cleaning check for this email. Only matters when the sub-account has the Real-Time List Cleaning add-on: the email is then sent without a check and no Validation webhook event (type 82) is sent for it. It can only turn the check off, never on.
The header X-Sendpost-Validate: false in headers does the same, including over SMTP relay. See Real-Time Validation Results.
Human-readable message describing the result.
On success: "Email submitted successfully"
On error: Description of what went wrong
Example:
"Email submitted successfully"
Was this page helpful?
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"SendPost Docs","colors":{"primary":"#5750EC","light":"#5750EC","dark":"#5750EC"},"logo":{"light":"https://mintcdn.com/sendx-43e2b6a9/xWJ6M32vFagLUxJg/logo/sendpost.svg?fit=max\u0026auto=format\u0026n=xWJ6M32vFagLUxJg\u0026q=85\u0026s=fc1d92fba901bca2cbab1ee394bc02ed","dark":"https://mintcdn.com/sendx-43e2b6a9/xWJ6M32vFagLUxJg/logo/sendpost.svg?fit=max\u0026auto=format\u0026n=xWJ6M32vFagLUxJg\u0026q=85\u0026s=fc1d92fba901bca2cbab1ee394bc02ed"},"favicon":"https://mintcdn.com/sendx-43e2b6a9/xWJ6M32vFagLUxJg/favicon.svg?fit=max\u0026auto=format\u0026n=xWJ6M32vFagLUxJg\u0026q=85\u0026s=49e9debc4f6238bdb21ed33aa69238f1","navbar":{"links":[{"href":"mailto:dev@sendpost.io","label":"Support"}],"primary":{"type":"button","label":"SendPost","href":"https://app.sendpost.io/"}},"footer":{"socials":{"github":"https://github.com/sendpost","linkedin":"https://www.linkedin.com/company/sendpost"}},"integrations":{"intercom":{"appId":"APP_ID"}},"styling":{"latex":false},"navigation":{"global":{"anchors":[]},"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"sendx-43e2b6a9","hasAudioNarration":false,"actualSubdomain":"sendx-43e2b6a9","customDomains":["docs.sendpost.io"],"gitSource":{"type":"github","owner":"sendpost","repo":"sendpost-api-docs","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"feedback":{"thumbs":true},"entitlements":{},"buildId":"6aec41183744ce14d0837e22","clientVersion":"0.0.4094","searchFilterCounts":[{"language":"default","tag":"Welcome","count":68},{"language":"default","tag":"API Reference","count":49},{"language":"default","tag":"Guides","count":39},{"language":"default","tag":"Quickstarts","count":22},{"language":"default","tag":"Webhook","count":10},{"language":"default","tag":"Amazon SES","count":7},{"language":"default","tag":"Custom SMTP","count":7},{"language":"default","tag":"SendGrid","count":7},{"language":"default","tag":"Common Use Cases","count":6},{"language":"default","tag":"IPPools","count":6}]},"assistantConfig":{},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"comment-mode","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[],"page":{"pagePath":"api-reference/email/send-email-with-template","slug":"/api-reference/email/send-email-with-template","pageMetadata":{"openapi":"post /subaccount/email/template","title":"Send Email With Template","description":"Send emails using pre-configured templates stored in SendPost. Templates separate email content from code, enabling:\n\n**Benefits:**\n- Update email content without code deployments\n- Marketing teams can manage templates independently\n- Consistent branding across all applications\n- A/B test different template versions\n\n**How It Works:**\n1. Create templates in the SendPost dashboard with Handlebars variables\n2. Reference the template by name or ID in this API call\n3. Pass dynamic data through recipient `customFields`\n4. SendPost merges data with template and sends\n\n**Common Use Cases:**\n\n| Template Type | Dynamic Data |\n|---------------|--------------|\n| Welcome Email | `firstName`, `accountType`, `loginUrl` |\n| Order Receipt | `orderNumber`, `items`, `total`, `shippingAddress` |\n| Password Reset | `resetLink`, `expiryTime`, `userName` |\n| Weekly Digest | `articleList`, `unreadCount`, `userName` |\n\n**Example Request:**\n```json\n{\n \"from\": { \"email\": \"orders@yourstore.com\" },\n \"to\": [{\n \"email\": \"customer@example.com\",\n \"customFields\": {\n \"firstName\": \"Sarah\",\n \"orderNumber\": \"ORD-2024-001\",\n \"totalAmount\": \"$149.99\"\n }\n }],\n \"template\": \"order-confirmation-v2\"\n}\n```\n\n**Note:** Template variables not provided in `customFields` will render as empty strings.\n","href":"/api-reference/email/send-email-with-template"},"description":{"compiledSource":"\"use strict\";\nconst {Fragment: _Fragment, jsx: _jsx, jsxs: _jsxs} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n code: \"code\",\n li: \"li\",\n ol: \"ol\",\n p: \"p\",\n pre: \"pre\",\n span: \"span\",\n strong: \"strong\",\n table: \"table\",\n tbody: \"tbody\",\n td: \"td\",\n th: \"th\",\n thead: \"thead\",\n tr: \"tr\",\n ul: \"ul\",\n ..._provideComponents(),\n ...props.components\n }, {CodeBlock} = _components;\n if (!CodeBlock) _missingMdxReference(\"CodeBlock\", true);\n return _jsxs(_Fragment, {\n children: [_jsx(_components.p, {\n children: \"Send emails using pre-configured templates stored in SendPost. Templates separate email content from code, enabling:\"\n }), \"\\n\", _jsx(_components.p, {\n children: _jsx(_components.strong, {\n children: \"Benefits:\"\n })\n }), \"\\n\", _jsxs(_components.ul, {\n children: [\"\\n\", _jsx(_components.li, {\n children: \"Update email content without code deployments\"\n }), \"\\n\", _jsx(_components.li, {\n children: \"Marketing teams can manage templates independently\"\n }), \"\\n\", _jsx(_components.li, {\n children: \"Consistent branding across all applications\"\n }), \"\\n\", _jsx(_components.li, {\n children: \"A/B test different template versions\"\n }), \"\\n\"]\n }), \"\\n\", _jsx(_components.p, {\n children: _jsx(_components.strong, {\n children: \"How It Works:\"\n })\n }), \"\\n\", _jsxs(_components.ol, {\n children: [\"\\n\", _jsx(_components.li, {\n children: \"Create templates in the SendPost dashboard with Handlebars variables\"\n }), \"\\n\", _jsx(_components.li, {\n children: \"Reference the template by name or ID in this API call\"\n }), \"\\n\", _jsxs(_components.li, {\n children: [\"Pass dynamic data through recipient \", _jsx(_components.code, {\n children: \"customFields\"\n })]\n }), \"\\n\", _jsx(_components.li, {\n children: \"SendPost merges data with template and sends\"\n }), \"\\n\"]\n }), \"\\n\", _jsx(_components.p, {\n children: _jsx(_components.strong, {\n children: \"Common Use Cases:\"\n })\n }), \"\\n\", _jsxs(_components.table, {\n children: [_jsx(_components.thead, {\n children: _jsxs(_components.tr, {\n children: [_jsx(_components.th, {\n children: \"Template Type\"\n }), _jsx(_components.th, {\n children: \"Dynamic Data\"\n })]\n })\n }), _jsxs(_components.tbody, {\n children: [_jsxs(_components.tr, {\n children: [_jsx(_components.td, {\n children: \"Welcome Email\"\n }), _jsxs(_components.td, {\n children: [_jsx(_components.code, {\n children: \"firstName\"\n }), \", \", _jsx(_components.code, {\n children: \"accountType\"\n }), \", \", _jsx(_components.code, {\n children: \"loginUrl\"\n })]\n })]\n }), _jsxs(_components.tr, {\n children: [_jsx(_components.td, {\n children: \"Order Receipt\"\n }), _jsxs(_components.td, {\n children: [_jsx(_components.code, {\n children: \"orderNumber\"\n }), \", \", _jsx(_components.code, {\n children: \"items\"\n }), \", \", _jsx(_components.code, {\n children: \"total\"\n }), \", \", _jsx(_components.code, {\n children: \"shippingAddress\"\n })]\n })]\n }), _jsxs(_components.tr, {\n children: [_jsx(_components.td, {\n children: \"Password Reset\"\n }), _jsxs(_components.td, {\n children: [_jsx(_components.code, {\n children: \"resetLink\"\n }), \", \", _jsx(_components.code, {\n children: \"expiryTime\"\n }), \", \", _jsx(_components.code, {\n children: \"userName\"\n })]\n })]\n }), _jsxs(_components.tr, {\n children: [_jsx(_components.td, {\n children: \"Weekly Digest\"\n }), _jsxs(_components.td, {\n children: [_jsx(_components.code, {\n children: \"articleList\"\n }), \", \", _jsx(_components.code, {\n children: \"unreadCount\"\n }), \", \", _jsx(_components.code, {\n children: \"userName\"\n })]\n })]\n })]\n })]\n }), \"\\n\", _jsx(_components.p, {\n children: _jsx(_components.strong, {\n children: \"Example Request:\"\n })\n }), \"\\n\", _jsx(CodeBlock, {\n numberOfLines: \"12\",\n language: \"json\",\n children: _jsx(_components.pre, {\n className: \"shiki shiki-themes github-light-default dark-plus\",\n style: {\n backgroundColor: \"#ffffff\",\n \"--shiki-dark-bg\": \"#0B0C0E\",\n color: \"#1f2328\",\n \"--shiki-dark\": \"#D4D4D4\"\n },\n language: \"json\",\n children: _jsxs(_components.code, {\n language: \"json\",\n numberOfLines: \"12\",\n children: [_jsx(_components.span, {\n className: \"line\",\n children: _jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#D4D4D4\"\n },\n children: \"{\"\n })\n }), \"\\n\", _jsxs(_components.span, {\n className: \"line\",\n children: [_jsx(_components.span, {\n style: {\n color: \"#116329\",\n \"--shiki-dark\": \"#9CDCFE\"\n },\n children: \" \\\"from\\\"\"\n }), _jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#D4D4D4\"\n },\n children: \": { \"\n }), _jsx(_components.span, {\n style: {\n color: \"#116329\",\n \"--shiki-dark\": \"#9CDCFE\"\n },\n children: \"\\\"email\\\"\"\n }), _jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#D4D4D4\"\n },\n children: \": \"\n }), _jsx(_components.span, {\n style: {\n color: \"#0A3069\",\n \"--shiki-dark\": \"#CE9178\"\n },\n children: \"\\\"orders@yourstore.com\\\"\"\n }), _jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#D4D4D4\"\n },\n children: \" },\"\n })]\n }), \"\\n\", _jsxs(_components.span, {\n className: \"line\",\n children: [_jsx(_components.span, {\n style: {\n color: \"#116329\",\n \"--shiki-dark\": \"#9CDCFE\"\n },\n children: \" \\\"to\\\"\"\n }), _jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#D4D4D4\"\n },\n children: \": [{\"\n })]\n }), \"\\n\", _jsxs(_components.span, {\n className: \"line\",\n children: [_jsx(_components.span, {\n style: {\n color: \"#116329\",\n \"--shiki-dark\": \"#9CDCFE\"\n },\n children: \" \\\"email\\\"\"\n }), _jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#D4D4D4\"\n },\n children: \": \"\n }), _jsx(_components.span, {\n style: {\n color: \"#0A3069\",\n \"--shiki-dark\": \"#CE9178\"\n },\n children: \"\\\"customer@example.com\\\"\"\n }), _jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#D4D4D4\"\n },\n children: \",\"\n })]\n }), \"\\n\", _jsxs(_components.span, {\n className: \"line\",\n children: [_jsx(_components.span, {\n style: {\n color: \"#116329\",\n \"--shiki-dark\": \"#9CDCFE\"\n },\n children: \" \\\"customFields\\\"\"\n }), _jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#D4D4D4\"\n },\n children: \": {\"\n })]\n }), \"\\n\", _jsxs(_components.span, {\n className: \"line\",\n children: [_jsx(_components.span, {\n style: {\n color: \"#116329\",\n \"--shiki-dark\": \"#9CDCFE\"\n },\n children: \" \\\"firstName\\\"\"\n }), _jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#D4D4D4\"\n },\n children: \": \"\n }), _jsx(_components.span, {\n style: {\n color: \"#0A3069\",\n \"--shiki-dark\": \"#CE9178\"\n },\n children: \"\\\"Sarah\\\"\"\n }), _jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#D4D4D4\"\n },\n children: \",\"\n })]\n }), \"\\n\", _jsxs(_components.span, {\n className: \"line\",\n children: [_jsx(_components.span, {\n style: {\n color: \"#116329\",\n \"--shiki-dark\": \"#9CDCFE\"\n },\n children: \" \\\"orderNumber\\\"\"\n }), _jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#D4D4D4\"\n },\n children: \": \"\n }), _jsx(_components.span, {\n style: {\n color: \"#0A3069\",\n \"--shiki-dark\": \"#CE9178\"\n },\n children: \"\\\"ORD-2024-001\\\"\"\n }), _jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#D4D4D4\"\n },\n children: \",\"\n })]\n }), \"\\n\", _jsxs(_components.span, {\n className: \"line\",\n children: [_jsx(_components.span, {\n style: {\n color: \"#116329\",\n \"--shiki-dark\": \"#9CDCFE\"\n },\n children: \" \\\"totalAmount\\\"\"\n }), _jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#D4D4D4\"\n },\n children: \": \"\n }), _jsx(_components.span, {\n style: {\n color: \"#0A3069\",\n \"--shiki-dark\": \"#CE9178\"\n },\n children: \"\\\"$149.99\\\"\"\n })]\n }), \"\\n\", _jsx(_components.span, {\n className: \"line\",\n children: _jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#D4D4D4\"\n },\n children: \" }\"\n })\n }), \"\\n\", _jsx(_components.span, {\n className: \"line\",\n children: _jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#D4D4D4\"\n },\n children: \" }],\"\n })\n }), \"\\n\", _jsxs(_components.span, {\n className: \"line\",\n children: [_jsx(_components.span, {\n style: {\n color: \"#116329\",\n \"--shiki-dark\": \"#9CDCFE\"\n },\n children: \" \\\"template\\\"\"\n }), _jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#D4D4D4\"\n },\n children: \": \"\n }), _jsx(_components.span, {\n style: {\n color: \"#0A3069\",\n \"--shiki-dark\": \"#CE9178\"\n },\n children: \"\\\"order-confirmation-v2\\\"\"\n })]\n }), \"\\n\", _jsx(_components.span, {\n className: \"line\",\n children: _jsx(_components.span, {\n style: {\n color: \"#1F2328\",\n \"--shiki-dark\": \"#D4D4D4\"\n },\n children: \"}\"\n })\n }), \"\\n\"]\n })\n })\n }), \"\\n\", _jsxs(_components.p, {\n children: [_jsx(_components.strong, {\n children: \"Note:\"\n }), \" Template variables not provided in \", _jsx(_components.code, {\n children: \"customFields\"\n }), \" will render as empty strings.\"]\n })]\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\nfunction _missingMdxReference(id, component) {\n throw new Error(\"Expected \" + (component ? \"component\" : \"object\") + \" `\" + id + \"` to be defined: you likely forgot to import, pass, or provide it.\");\n}\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){return _jsx(_Fragment,{})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"openapi":"post /subaccount/email/template","title":"Send Email With Template","description":"Send emails using pre-configured templates stored in SendPost. Templates separate email content from code, enabling:\n\n**Benefits:**\n- Update email content without code deployments\n- Marketing teams can manage templates independently\n- Consistent branding across all applications\n- A/B test different template versions\n\n**How It Works:**\n1. Create templates in the SendPost dashboard with Handlebars variables\n2. Reference the template by name or ID in this API call\n3. Pass dynamic data through recipient `customFields`\n4. SendPost merges data with template and sends\n\n**Common Use Cases:**\n\n| Template Type | Dynamic Data |\n|---------------|--------------|\n| Welcome Email | `firstName`, `accountType`, `loginUrl` |\n| Order Receipt | `orderNumber`, `items`, `total`, `shippingAddress` |\n| Password Reset | `resetLink`, `expiryTime`, `userName` |\n| Weekly Digest | `articleList`, `unreadCount`, `userName` |\n\n**Example Request:**\n```json\n{\n \"from\": { \"email\": \"orders@yourstore.com\" },\n \"to\": [{\n \"email\": \"customer@example.com\",\n \"customFields\": {\n \"firstName\": \"Sarah\",\n \"orderNumber\": \"ORD-2024-001\",\n \"totalAmount\": \"$149.99\"\n }\n }],\n \"template\": \"order-confirmation-v2\"\n}\n```\n\n**Note:** Template variables not provided in `customFields` will render as empty strings.\n","href":"/api-reference/email/send-email-with-template"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[],"codeExamples":{}},"jsLinks":[],"openApiReferenceData":{"operation":{"summary":"Send Email With Template","security":["40a3e3dd-dd21-4213-a8c2-dbda2a522b96"],"tags":["Email"],"description":"Send emails using pre-configured templates stored in SendPost. Templates separate email content from code, enabling:\n\n**Benefits:**\n- Update email content without code deployments\n- Marketing teams can manage templates independently\n- Consistent branding across all applications\n- A/B test different template versions\n\n**How It Works:**\n1. Create templates in the SendPost dashboard with Handlebars variables\n2. Reference the template by name or ID in this API call\n3. Pass dynamic data through recipient `customFields`\n4. SendPost merges data with template and sends\n\n**Common Use Cases:**\n\n| Template Type | Dynamic Data |\n|---------------|--------------|\n| Welcome Email | `firstName`, `accountType`, `loginUrl` |\n| Order Receipt | `orderNumber`, `items`, `total`, `shippingAddress` |\n| Password Reset | `resetLink`, `expiryTime`, `userName` |\n| Weekly Digest | `articleList`, `unreadCount`, `userName` |\n\n**Example Request:**\n```json\n{\n \"from\": { \"email\": \"orders@yourstore.com\" },\n \"to\": [{\n \"email\": \"customer@example.com\",\n \"customFields\": {\n \"firstName\": \"Sarah\",\n \"orderNumber\": \"ORD-2024-001\",\n \"totalAmount\": \"$149.99\"\n }\n }],\n \"template\": \"order-confirmation-v2\"\n}\n```\n\n**Note:** Template variables not provided in `customFields` will render as empty strings.\n","operationId":"sendEmailWithTemplate","requestBody":"61ac6bbf-bf40-40cc-87e5-017f1a45a8a1","responses":{"200":"6ad95069-232b-4d11-b438-818a8135e997","400":"7b4d100c-936f-4864-bd58-615d9ac14dbf"},"x-code-samples":[{"lang":"JavaScript","label":"JavaSript","source":"const { EmailApi, EmailMessage } = require('sendpost_js');\nconst email = new EmailApi();\nconst apiKey = 'your_api_key'; // {String} Sub-Account API Key\n\n(async function() {\n const message = new EmailMessage();\n message.from = { email: 'richard@piedpiper.com' };\n\n message.to = [{\n email: 'gavin@hooli.com',\n cc: [{ email: 'dinesh@bachmanity.com' }],\n bcc: [{ email: 'jian@bachmanity.com' }],\n }]\n\n message.subject = 'Hello'\n message.htmlBody = '\u003cstrong>it works!\u003c/strong>';\n message.ippool = 'PiedPiper'\n\n message.template = 'Welcome Mail'\n\n const opts = {\n emailMessage: message\n };\n try {\n const data = await email.sendEmailWithTemplate(apiKey, opts)\n console.log('API called successfully. Returned data: ', data);\n } catch (error) {\n console.error(error);\n }\n})()\n"},{"lang":"php","label":"PHP","source":"require_once(__DIR__ . '/vendor/autoload.php');\n$client = new GuzzleHttp\\Client();\n\n$apiInstance = new sendpost\\api\\EmailApi($client);\n\n$x_sub_account_api_key = 'your_api_key'; // string | Sub-Account API Key\n$email_message = new \\sendpost\\model\\EmailMessage(); \n$email_message->setSubject('Hello World');\n$email_message->setHtmlBody('\u003cstrong>it works!\u003c/strong>');\n$email_message->setIppool('PiedPiper');\n$from = new \\sendpost\\model\\From();\n$from->setEmail('richard@piedpiper.com');\n\n$cc = new \\sendpost\\model\\CopyTo();\n$cc->setEmail('dinesh@bachmanity.com');\n$to->setCc(array($cc));\n$bcc = new \\sendpost\\model\\CopyTo();\n$bcc->setEmail('jian@bachmanity.com');\n$to->setBcc(array($bcc));\n\n$email_message->setTemplate('Welcome Mail');\n\n$to = new \\sendpost\\model\\To();\n$to->setEmail('gavin@hooli.com');\n$email_message->setTo(array($to));\n$email_message->setFrom($from);\n\ntry {\n $result = $apiInstance->sendEmailWithTemplate($x_sub_account_api_key, $email_message);\n print_r($result);\n} catch (Exception $e) {\n echo 'Exception when calling EmailApi->sendEmail: ', $e->getMessage(), PHP_EOL;\n}\n"},{"lang":"Python","label":"Python SDK","source":"import sendpost_python_sdk\nfrom pprint import pprint\nfrom sendpost_python_sdk.apis.tags import email_api\n\n# Enter a context with an instance of the API client\nwith sendpost_python_sdk.ApiClient() as api_client:\n # Create an instance of the API class\n api_instance = email_api.EmailApi(api_client)\n x_sub_account_api_key = \"your_api_key\" # str | Sub-Account API Key\n email = {\n \"from\": {\n \"email\": \"richard@piedpiper.com\",\n },\n \"to\": [\n {\n \"email\": \"gavin@hooli.com\",\n \"cc\": [{ \"email\": \"dinesh@bachmanity.com\" }],\n \"bcc\": [{ \"email\": \"jian@bachmanity.com\" }],\n }\n ],\n \"template\": \"Welcome Mail\",\n \"subject\": \"Hello World\",\n \"htmlBody\": \"\u003cstrong>it works!\u003c/strong>\",\n \"ippool\": \"PiedPiper\",\n }\n try:\n api_response = api_instance.send_email_with_template(header_params={ 'X-SubAccount-ApiKey': x_sub_account_api_key}, body=email)\n pprint(api_response)\n except sendpost_python_sdk.ApiException as e:\n print(\"Exception when calling EmailApi->send_email: %s\\n\" % e)\n"},{"lang":"go","label":"Go","source":"cfg := sendpost.NewConfiguration()\nclient := sendpost.NewAPIClient(cfg)\n\nemailMessage := sendpost.EmailMessage{}\nemailMessage.SetSubject(\"Hello World\")\nemailMessage.SetHtmlBody(\"\u003cstrong>it works!\u003c/strong>\")\nemailMessage.SetIppool(\"PiedPiper\")\nemailMessage.From = \u0026sendpost.From{}\nemailMessage.From.SetEmail(\"richard@piedpiper.com\")\n\nemailMessage.SetTemplate(\"Welcome Mail\")\n\ntos := make([]sendpost.To, 0)\nto := \u0026sendpost.To{}\nto.SetEmail(\"gavin@hooli.com\")\n\nccs := make([]sendpost.CopyTo, 0)\ncc := \u0026sendpost.CopyTo{}\ncc.SetEmail(\"dinesh@bachmanity.com\")\nccs = append(ccs, *cc)\nto.SetCc(ccs)\nbccs := make([]sendpost.CopyTo, 0)\nbcc := \u0026sendpost.CopyTo{}\nbcc.SetEmail(\"jian@bachmanity.com\")\nbccs = append(bccs, *bcc)\nto.SetBcc(bccs)\n\ntos = append(tos, *to)\nemailMessage.To = tos\n\nemailRequest := sendpost.ApiSendEmailWithTemplateRequest{}\nemailRequest = emailRequest.XSubAccountApiKey(\"your_api_key\")\nemailRequest = emailRequest.EmailMessage(emailMessage)\nres, _, err := client.EmailApi.SendEmailWithTemplateExecute(emailRequest)\n"},{"lang":"ruby","label":"Ruby","source":"require 'sendpost_ruby_sdk'\n\napi_instance = Sendpost::EmailApi.new\nx_sub_account_api_key = 'your_api_key' # String | Sub-Account API Key\nemail_message = Sendpost::EmailMessage.new\nemail_message.from = {\n email: 'richard@piedpiper.com'\n}\nemail_message.to = [{\n email: 'gavin@hooli.com',\n cc: [{ email: 'dinesh@bachmanity.com' }],\n bcc: [{ email: 'jian@bachmanity.com' }]\n}]\n\nemail_message.subject = 'Hello World'\nemail_message.template = 'Welcome Mail'\nemail_message.html_body = '\u003cstrong>it works!\u003c/strong>'\nemail_message.ippool = 'PiedPiper'\n\nopts = {\n email_message: email_message # EmailMessage | Email message\n}\n\nbegin\n result = api_instance.send_email_with_template(x_sub_account_api_key, opts)\n p result\nrescue Sendpost::ApiError => e\n puts \"Exception when calling EmailApi->send_email: #{e}\"\nend\n"},{"lang":"shell","label":"cURL","source":"curl -X POST \"https://api.sendpost.io/api/v1/subaccount/email/template\" \\\n-H \"accept: application/json\" \\\n-H \"X-SubAccount-ApiKey: your_api_key\" \\\n-d '{\n \"from\": { \"email\": \"richard@piedpiper.com\" },\n \"to\": [{ \"email\": \"gavin@hooli.com\" }],\n \"templateId\": \"12345\",\n \"dynamicData\": {\n \"name\": \"Gavin\",\n \"product\": \"Compression Algorithm\"\n },\n \"ippool\": \"PiedPiper\"\n}'\n"}],"method":"post","type":"path","servers":["3e2bf5d9-3b9c-4724-ba94-ee3efb46f2dc"],"path":"/subaccount/email/template","baseUrlOptions":["https://api.sendpost.io/api/v1"],"title":"Send Email With Template","codeSamples":[{"label":"JavaSript","lang":"JavaScript","source":"const { EmailApi, EmailMessage } = require('sendpost_js');\nconst email = new EmailApi();\nconst apiKey = 'your_api_key'; // {String} Sub-Account API Key\n\n(async function() {\n const message = new EmailMessage();\n message.from = { email: 'richard@piedpiper.com' };\n\n message.to = [{\n email: 'gavin@hooli.com',\n cc: [{ email: 'dinesh@bachmanity.com' }],\n bcc: [{ email: 'jian@bachmanity.com' }],\n }]\n\n message.subject = 'Hello'\n message.htmlBody = '\u003cstrong>it works!\u003c/strong>';\n message.ippool = 'PiedPiper'\n\n message.template = 'Welcome Mail'\n\n const opts = {\n emailMessage: message\n };\n try {\n const data = await email.sendEmailWithTemplate(apiKey, opts)\n console.log('API called successfully. Returned data: ', data);\n } catch (error) {\n console.error(error);\n }\n})()\n"},{"label":"PHP","lang":"php","source":"require_once(__DIR__ . '/vendor/autoload.php');\n$client = new GuzzleHttp\\Client();\n\n$apiInstance = new sendpost\\api\\EmailApi($client);\n\n$x_sub_account_api_key = 'your_api_key'; // string | Sub-Account API Key\n$email_message = new \\sendpost\\model\\EmailMessage(); \n$email_message->setSubject('Hello World');\n$email_message->setHtmlBody('\u003cstrong>it works!\u003c/strong>');\n$email_message->setIppool('PiedPiper');\n$from = new \\sendpost\\model\\From();\n$from->setEmail('richard@piedpiper.com');\n\n$cc = new \\sendpost\\model\\CopyTo();\n$cc->setEmail('dinesh@bachmanity.com');\n$to->setCc(array($cc));\n$bcc = new \\sendpost\\model\\CopyTo();\n$bcc->setEmail('jian@bachmanity.com');\n$to->setBcc(array($bcc));\n\n$email_message->setTemplate('Welcome Mail');\n\n$to = new \\sendpost\\model\\To();\n$to->setEmail('gavin@hooli.com');\n$email_message->setTo(array($to));\n$email_message->setFrom($from);\n\ntry {\n $result = $apiInstance->sendEmailWithTemplate($x_sub_account_api_key, $email_message);\n print_r($result);\n} catch (Exception $e) {\n echo 'Exception when calling EmailApi->sendEmail: ', $e->getMessage(), PHP_EOL;\n}\n"},{"label":"Python SDK","lang":"Python","source":"import sendpost_python_sdk\nfrom pprint import pprint\nfrom sendpost_python_sdk.apis.tags import email_api\n\n# Enter a context with an instance of the API client\nwith sendpost_python_sdk.ApiClient() as api_client:\n # Create an instance of the API class\n api_instance = email_api.EmailApi(api_client)\n x_sub_account_api_key = \"your_api_key\" # str | Sub-Account API Key\n email = {\n \"from\": {\n \"email\": \"richard@piedpiper.com\",\n },\n \"to\": [\n {\n \"email\": \"gavin@hooli.com\",\n \"cc\": [{ \"email\": \"dinesh@bachmanity.com\" }],\n \"bcc\": [{ \"email\": \"jian@bachmanity.com\" }],\n }\n ],\n \"template\": \"Welcome Mail\",\n \"subject\": \"Hello World\",\n \"htmlBody\": \"\u003cstrong>it works!\u003c/strong>\",\n \"ippool\": \"PiedPiper\",\n }\n try:\n api_response = api_instance.send_email_with_template(header_params={ 'X-SubAccount-ApiKey': x_sub_account_api_key}, body=email)\n pprint(api_response)\n except sendpost_python_sdk.ApiException as e:\n print(\"Exception when calling EmailApi->send_email: %s\\n\" % e)\n"},{"label":"Go","lang":"go","source":"cfg := sendpost.NewConfiguration()\nclient := sendpost.NewAPIClient(cfg)\n\nemailMessage := sendpost.EmailMessage{}\nemailMessage.SetSubject(\"Hello World\")\nemailMessage.SetHtmlBody(\"\u003cstrong>it works!\u003c/strong>\")\nemailMessage.SetIppool(\"PiedPiper\")\nemailMessage.From = \u0026sendpost.From{}\nemailMessage.From.SetEmail(\"richard@piedpiper.com\")\n\nemailMessage.SetTemplate(\"Welcome Mail\")\n\ntos := make([]sendpost.To, 0)\nto := \u0026sendpost.To{}\nto.SetEmail(\"gavin@hooli.com\")\n\nccs := make([]sendpost.CopyTo, 0)\ncc := \u0026sendpost.CopyTo{}\ncc.SetEmail(\"dinesh@bachmanity.com\")\nccs = append(ccs, *cc)\nto.SetCc(ccs)\nbccs := make([]sendpost.CopyTo, 0)\nbcc := \u0026sendpost.CopyTo{}\nbcc.SetEmail(\"jian@bachmanity.com\")\nbccs = append(bccs, *bcc)\nto.SetBcc(bccs)\n\ntos = append(tos, *to)\nemailMessage.To = tos\n\nemailRequest := sendpost.ApiSendEmailWithTemplateRequest{}\nemailRequest = emailRequest.XSubAccountApiKey(\"your_api_key\")\nemailRequest = emailRequest.EmailMessage(emailMessage)\nres, _, err := client.EmailApi.SendEmailWithTemplateExecute(emailRequest)\n"},{"label":"Ruby","lang":"ruby","source":"require 'sendpost_ruby_sdk'\n\napi_instance = Sendpost::EmailApi.new\nx_sub_account_api_key = 'your_api_key' # String | Sub-Account API Key\nemail_message = Sendpost::EmailMessage.new\nemail_message.from = {\n email: 'richard@piedpiper.com'\n}\nemail_message.to = [{\n email: 'gavin@hooli.com',\n cc: [{ email: 'dinesh@bachmanity.com' }],\n bcc: [{ email: 'jian@bachmanity.com' }]\n}]\n\nemail_message.subject = 'Hello World'\nemail_message.template = 'Welcome Mail'\nemail_message.html_body = '\u003cstrong>it works!\u003c/strong>'\nemail_message.ippool = 'PiedPiper'\n\nopts = {\n email_message: email_message # EmailMessage | Email message\n}\n\nbegin\n result = api_instance.send_email_with_template(x_sub_account_api_key, opts)\n p result\nrescue Sendpost::ApiError => e\n puts \"Exception when calling EmailApi->send_email: #{e}\"\nend\n"},{"label":"cURL","lang":"shell","source":"curl -X POST \"https://api.sendpost.io/api/v1/subaccount/email/template\" \\\n-H \"accept: application/json\" \\\n-H \"X-SubAccount-ApiKey: your_api_key\" \\\n-d '{\n \"from\": { \"email\": \"richard@piedpiper.com\" },\n \"to\": [{ \"email\": \"gavin@hooli.com\" }],\n \"templateId\": \"12345\",\n \"dynamicData\": {\n \"name\": \"Gavin\",\n \"product\": \"Compression Algorithm\"\n },\n \"ippool\": \"PiedPiper\"\n}'\n"}],"requiredOnlyExamples":false,"requestExampleType":"codeSamples","responseExampleType":"generated"},"dependencies":{"parameters":{},"requestBody":{"description":"Email message details with template information","required":true,"content":{"application/json":{"schema":{"type":"object","description":"Email message object containing all the details required to send an email.\nAt minimum, you need to provide `from`, `to`, and either `subject` with `htmlBody`/`textBody` or a `template`.\n","required":["from","to"],"example":{"from":{"email":"notifications@yourcompany.com","name":"Your Company"},"replyTo":{"email":"support@yourcompany.com","name":"Support Team"},"to":[{"email":"customer@example.com","name":"John Doe","customFields":{"firstName":"John","orderId":"ORD-12345","orderTotal":"$99.99"}}],"subject":"Your order {{orderId}} has been shipped!","htmlBody":"\u003ch1>Hi {{firstName}}\u003c/h1>\u003cp>Your order {{orderId}} worth {{orderTotal}} is on its way!\u003c/p>","textBody":"Hi {{firstName}}, Your order {{orderId}} worth {{orderTotal}} is on its way!","ippool":"transactional","trackOpens":true,"trackClicks":true,"groups":["order-shipped","transactional"]},"properties":{"from":{"type":"object","description":"The sender's email address and optional display name","required":["email"],"properties":{"email":{"type":"string","format":"email","description":"The email address (must be a valid email format)","example":"sender@example.com","isRequired":true,"uniqueKey":"from.email","typeLabel":"string\u003cemail>"},"name":{"type":"string","description":"Display name shown in email clients.\nWill appear as \"Name \u003cemail@example.com>\" in the From/To fields.\n","example":"John Doe","maxLength":256,"uniqueKey":"from.name","typeLabel":"string"}},"example":{"email":"sender@example.com","name":"John Doe"},"isRequired":true,"uniqueKey":"from","typeLabel":"object"},"to":{"type":"array","description":"List of recipients. Each recipient can have their own CC, BCC, and custom fields for personalization.\nMaximum 1000 recipients per API call.\n","items":{"type":"object","description":"A recipient of the email with optional CC, BCC, and custom fields for personalization.\nEach recipient receives their own copy of the email with their specific custom field values.\n","required":["email"],"properties":{"email":{"type":"string","format":"email","description":"The recipient's email address","example":"recipient@example.com","isRequired":true,"uniqueKey":"to.items.[INDEX].email","typeLabel":"string\u003cemail>"},"name":{"type":"string","description":"The recipient's display name","example":"Jane Smith","maxLength":256,"uniqueKey":"to.items.[INDEX].name","typeLabel":"string"},"cc":{"type":"array","description":"Carbon copy recipients for this specific recipient's email.\nCC addresses will be visible to all recipients of this email copy.\n","items":{"type":"object","description":"A CC or BCC recipient with optional custom fields","required":["email"],"properties":{"email":{"type":"string","format":"email","description":"The CC/BCC recipient's email address","example":"cc@example.com","isRequired":true,"uniqueKey":"to.items.[INDEX].cc.items.[INDEX].email","typeLabel":"string\u003cemail>"},"name":{"type":"string","description":"The CC/BCC recipient's display name","example":"Copy Recipient","maxLength":256,"uniqueKey":"to.items.[INDEX].cc.items.[INDEX].name","typeLabel":"string"},"customFields":{"type":"object","additionalProperties":true,"description":"Custom fields specific to this CC/BCC recipient.\nAllows personalization in CC/BCC copies of the email.\n","example":{"role":"Manager"},"uniqueKey":"to.items.[INDEX].cc.items.[INDEX].customFields","typeLabel":"object"}},"example":{"email":"cc@example.com","name":"Copy Recipient"},"uniqueKey":"to.items.[INDEX].cc.items.[INDEX]","typeLabel":"object"},"maxItems":50,"uniqueKey":"to.items.[INDEX].cc","typeLabel":"object[]"},"bcc":{"type":"array","description":"Blind carbon copy recipients for this specific recipient's email.\nBCC addresses are hidden from all other recipients.\n","items":{"type":"object","description":"A CC or BCC recipient with optional custom fields","required":["email"],"properties":{"email":{"type":"string","format":"email","description":"The CC/BCC recipient's email address","example":"cc@example.com","isRequired":true,"uniqueKey":"to.items.[INDEX].bcc.items.[INDEX].email","typeLabel":"string\u003cemail>"},"name":{"type":"string","description":"The CC/BCC recipient's display name","example":"Copy Recipient","maxLength":256,"uniqueKey":"to.items.[INDEX].bcc.items.[INDEX].name","typeLabel":"string"},"customFields":{"type":"object","additionalProperties":true,"description":"Custom fields specific to this CC/BCC recipient.\nAllows personalization in CC/BCC copies of the email.\n","example":{"role":"Manager"},"uniqueKey":"to.items.[INDEX].bcc.items.[INDEX].customFields","typeLabel":"object"}},"example":{"email":"cc@example.com","name":"Copy Recipient"},"uniqueKey":"to.items.[INDEX].bcc.items.[INDEX]","typeLabel":"object"},"maxItems":50,"uniqueKey":"to.items.[INDEX].bcc","typeLabel":"object[]"},"customFields":{"type":"object","additionalProperties":true,"description":"Custom fields for personalizing the email content for this recipient.\nUse Handlebars syntax ({{fieldName}}) in subject, htmlBody, or textBody to insert values.\nReserved field names: `unsubscribe` (auto-generated unsubscribe link).\n","example":{"firstName":"Jane","lastName":"Smith","accountId":"ACC-12345","planName":"Premium"},"uniqueKey":"to.items.[INDEX].customFields","typeLabel":"object"}},"example":{"email":"jane@example.com","name":"Jane Smith","cc":[{"email":"manager@example.com","name":"Manager"}],"customFields":{"firstName":"Jane","companyName":"Acme Corp"}},"uniqueKey":"to.items.[INDEX]","typeLabel":"object"},"minItems":1,"maxItems":1000,"isRequired":true,"uniqueKey":"to","typeLabel":"object[]"},"replyTo":{"type":"object","description":"The reply-to email address. If not specified, replies will go to the `from` address","required":["email"],"properties":{"email":{"type":"string","format":"email","description":"The email address (must be a valid email format)","example":"sender@example.com","isRequired":true,"uniqueKey":"replyTo.email","typeLabel":"string\u003cemail>"},"name":{"type":"string","description":"Display name shown in email clients.\nWill appear as \"Name \u003cemail@example.com>\" in the From/To fields.\n","example":"John Doe","maxLength":256,"uniqueKey":"replyTo.name","typeLabel":"string"}},"example":{"email":"sender@example.com","name":"John Doe"},"uniqueKey":"replyTo","typeLabel":"object"},"tpspFrom":{"type":"object","description":"Optional sender for emails delivered through a third-party sending provider (TPSP): SendGrid, Amazon SES, Mailgun, SparkPost, Postmark, or Custom SMTP. For example, when sending over your SendPost warmup cap overflows to a TPSP pool, those emails go out as `tpspFrom` instead of `from`.\n\n- Must be on the same registered domain as `from`. For example, `from` on `agent1.example.com` and `tpspFrom` on `agent2.example.com`.\n- It doesn't need to be verified in SendPost, but it must be set up as a sender at the TPSP.\n- Emails delivered on SendPost IPs still go out as `from`. Stats and webhook events are always reported under `from`.\n- If `name` is omitted, the `from` name is used. If `replyTo` isn't set, replies go to `tpspFrom`.\n- If `tpspFrom` is invalid, the whole request is rejected with HTTP 400 and `errorCode` 11.\n","required":["email"],"properties":{"email":{"type":"string","format":"email","description":"The email address (must be a valid email format)","example":"sender@example.com","isRequired":true,"uniqueKey":"tpspFrom.email","typeLabel":"string\u003cemail>"},"name":{"type":"string","description":"Display name shown in email clients.\nWill appear as \"Name \u003cemail@example.com>\" in the From/To fields.\n","example":"John Doe","maxLength":256,"uniqueKey":"tpspFrom.name","typeLabel":"string"}},"example":{"email":"sender@example.com","name":"John Doe"},"uniqueKey":"tpspFrom","typeLabel":"object"},"subject":{"type":"string","description":"Email subject line. Supports Handlebars templating for personalization.\nExample: \"Hello, {{firstName}}! Your order is ready\"\n","example":"Welcome to SendPost, {{firstName}}!","maxLength":998,"uniqueKey":"subject","typeLabel":"string"},"preText":{"type":"string","description":"Preview text (preheader) shown in email clients before opening the email.\nThis text appears after the subject line in most email clients' inbox view.\n","example":"Your weekly digest is here with 5 new updates...","maxLength":200,"uniqueKey":"preText","typeLabel":"string"},"htmlBody":{"type":"string","description":"HTML content of the email. Supports Handlebars templating for personalization.\nUse {{customFieldName}} to insert recipient-specific values.\n","example":"\u003chtml>\u003cbody>\u003ch1>Hello {{firstName}}\u003c/h1>\u003cp>Welcome to our platform!\u003c/p>\u003c/body>\u003c/html>","uniqueKey":"htmlBody","typeLabel":"string"},"textBody":{"type":"string","description":"Plain text content of the email. Used as fallback when HTML cannot be rendered.\nAlso improves deliverability as some spam filters prefer multipart emails.\n","example":"Hello {{firstName}},\n\nWelcome to our platform!\n\nBest regards,\nThe Team","uniqueKey":"textBody","typeLabel":"string"},"ampBody":{"type":"string","description":"AMP HTML content for supported email clients (Gmail, Yahoo).\nEnables interactive email experiences like carousels, forms, and real-time content.\nSee https://amp.dev/about/email/ for more details.\n","example":"\u003c!doctype html>\u003chtml ⚡4email>\u003chead>...\u003c/head>\u003cbody>...\u003c/body>\u003c/html>","uniqueKey":"ampBody","typeLabel":"string"},"template":{"type":"string","description":"Name of a pre-defined template to use for this email.\nWhen specified, the template's subject, htmlBody, and textBody will be used\nunless explicitly overridden in this request.\n","example":"welcome-email-v2","uniqueKey":"template","typeLabel":"string"},"ippool":{"type":"string","description":"Name of the IP pool to use for sending this email.\nIf not specified, the default IP pool for the sub-account will be used.\n","example":"transactional","uniqueKey":"ippool","typeLabel":"string"},"headers":{"type":"object","description":"Custom email headers to include in the message.\nCommon uses: adding List-Unsubscribe headers, custom tracking IDs, or priority flags.\nNote: Some headers like From, To, Subject are set automatically and cannot be overridden.\n","additionalProperties":{"type":"string","uniqueKey":"headers.additionalProperties","typeLabel":"string"},"example":{"X-Custom-Header":"custom-value","X-Campaign-ID":"summer-sale-2024","List-Unsubscribe":"\u003cmailto:unsubscribe@example.com>"},"uniqueKey":"headers","typeLabel":"object"},"trackOpens":{"type":"boolean","description":"Whether to track email opens using a tracking pixel.\nWhen enabled, a 1x1 transparent image is inserted into the HTML body.\nDefault: true (if not specified)\n","default":true,"example":true,"uniqueKey":"trackOpens","typeLabel":"boolean"},"trackClicks":{"type":"boolean","description":"Whether to track link clicks by rewriting URLs through SendPost's tracking domain.\nWhen enabled, all links in htmlBody are replaced with tracking URLs.\nDefault: true (if not specified)\n","default":true,"example":true,"uniqueKey":"trackClicks","typeLabel":"boolean"},"groups":{"type":"array","description":"Tags/groups to categorize this email for analytics and reporting.\nUse groups to segment your email statistics (e.g., by campaign, email type, or customer segment).\n","items":{"type":"string","uniqueKey":"groups.items.[INDEX]","typeLabel":"string"},"example":["transactional","order-confirmation","premium-customers"],"uniqueKey":"groups","typeLabel":"string[]"},"attachments":{"type":"array","description":"File attachments to include with the email.\nMaximum total attachment size: 25MB.\nSupported formats: PDF, images, documents, etc.\n","items":{"type":"object","description":"A file attachment for the email.\nThe content must be Base64 encoded. Maximum total attachment size per email is 25MB.\n","required":["content","filename"],"properties":{"content":{"type":"string","format":"byte","description":"Base64 encoded content of the attachment file.\nEnsure proper encoding to avoid corruption.\n","example":"SGVsbG8gV29ybGQh","isRequired":true,"uniqueKey":"attachments.items.[INDEX].content","typeLabel":"string\u003cbyte>"},"filename":{"type":"string","description":"Name of the attachment file as it will appear to recipients.\nInclude the file extension (e.g., \"report.pdf\", \"image.png\").\n","example":"invoice-12345.pdf","maxLength":255,"isRequired":true,"uniqueKey":"attachments.items.[INDEX].filename","typeLabel":"string"}},"example":{"filename":"monthly-report.pdf","content":"JVBERi0xLjQKJeLjz9MKMyAwIG9..."},"uniqueKey":"attachments.items.[INDEX]","typeLabel":"object"},"uniqueKey":"attachments","typeLabel":"object[]"},"webhookEndpoint":{"type":"string","description":"Custom webhook URL to receive events for this specific email.\nIt receives every event of the email except Validation, in addition to your account webhooks; it doesn't replace them.\nRequests to it are signed only when the URL exactly matches an account webhook that has a `secret`. See [Webhook Signature Verification](/api-reference/webhook/webhook-signature-verification#per-email-webhook-endpoints).\nUseful for per-email or per-customer webhook routing.\n","format":"uri","example":"https://your-app.com/webhooks/email-events","uniqueKey":"webhookEndpoint","typeLabel":"string\u003curi>"},"skipValidation":{"type":"boolean","description":"Skip the real-time list cleaning check for this email. Only matters when the sub-account has the Real-Time List Cleaning add-on: the email is then sent without a check and no Validation webhook event (type 82) is sent for it. It can only turn the check off, never on.\n\nThe header `X-Sendpost-Validate: false` in `headers` does the same, including over SMTP relay. See [Real-Time Validation Results](/api-reference/webhook/validation-results).\n","default":false,"example":false,"uniqueKey":"skipValidation","typeLabel":"boolean"},"templateId":{"type":"string","description":"Template ID for the email template","uniqueKey":"templateId","typeLabel":"string"},"templateVariables":{"type":"object","description":"Key-Value pair of template variables","additionalProperties":{"type":"string","uniqueKey":"templateVariables.additionalProperties","typeLabel":"string"},"uniqueKey":"templateVariables","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"from":{"email":"notifications@yourcompany.com","name":"Your Company"},"replyTo":{"email":"support@yourcompany.com","name":"Support Team"},"to":[{"email":"customer@example.com","name":"John Doe","customFields":{"firstName":"John","orderId":"ORD-12345","orderTotal":"$99.99"}}],"subject":"Your order {{orderId}} has been shipped!","htmlBody":"\u003ch1>Hi {{firstName}}\u003c/h1>\u003cp>Your order {{orderId}} worth {{orderTotal}} is on its way!\u003c/p>","textBody":"Hi {{firstName}}, Your order {{orderId}} worth {{orderTotal}} is on its way!","ippool":"transactional","trackOpens":true,"trackClicks":true,"groups":["order-shipped","transactional"]}}},"exampleType":"generated"}},"exampleType":"generated"},"responses":{"6ad95069-232b-4d11-b438-818a8135e997":{"description":"A list of email message response objects.","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","description":"Response object returned for each recipient when sending an email.\nContains the message ID for tracking and any error information if the submission failed.\n","properties":{"to":{"type":"string","description":"The recipient email address this response corresponds to","example":"customer@example.com","uniqueKey":"items.[INDEX].to","typeLabel":"string"},"submittedAt":{"type":"integer","format":"int64","description":"UNIX epoch timestamp in nanoseconds when the email was accepted for processing.\nUse this for precise timing and correlation with webhook events.\n","example":1704067200000000000,"uniqueKey":"items.[INDEX].submittedAt","typeLabel":"integer\u003cint64>"},"messageId":{"type":"string","description":"Unique identifier (UUID) for this email message.\nUse this ID to track the email through webhooks and the message lookup API.\n","example":"550e8400-e29b-41d4-a716-446655440000","uniqueKey":"items.[INDEX].messageId","typeLabel":"string"},"errorCode":{"type":"integer","description":"Error code if the email submission failed:\n- 0: Success (no error)\n- 1: Invalid recipient email\n- 2: Recipient in suppression list\n- 3: `from` domain doesn't exist in this sub-account\n- 4: `from` domain isn't verified\n- 5: IP pool doesn't exist\n- 6: Template doesn't exist\n- 7: Empty template name\n- 8: Internal error (message ID generation)\n- 9: Internal error (message storage)\n- 10: Invalid attachment\n- 11: Invalid `tpspFrom`\n","example":0,"uniqueKey":"items.[INDEX].errorCode","typeLabel":"integer"},"message":{"type":"string","description":"Human-readable message describing the result.\nOn success: \"Email submitted successfully\"\nOn error: Description of what went wrong\n","example":"Email submitted successfully","uniqueKey":"items.[INDEX].message","typeLabel":"string"}},"example":{"to":"customer@example.com","submittedAt":1704067200000000000,"messageId":"550e8400-e29b-41d4-a716-446655440000","errorCode":0,"message":"Email submitted successfully"},"uniqueKey":"items.[INDEX]","typeLabel":"object"},"uniqueKey":"","typeLabel":"object[]"},"examples":{"Example":{"title":"Example","value":[{"to":"customer@example.com","submittedAt":1704067200000000000,"messageId":"550e8400-e29b-41d4-a716-446655440000","errorCode":0,"message":"Email submitted successfully"}]}},"exampleType":"generated"}},"exampleType":"generated"},"7b4d100c-936f-4864-bd58-615d9ac14dbf":{"description":"The request was rejected before any email was sent. The body is a single `EmailResponse` object, not an array. `errorCode` is 3 or 4 when the `from` domain doesn't exist or isn't verified, and 11 when `tpspFrom` is invalid.\n","content":{"application/json":{"schema":{"type":"object","description":"Response object returned for each recipient when sending an email.\nContains the message ID for tracking and any error information if the submission failed.\n","properties":{"to":{"type":"string","description":"The recipient email address this response corresponds to","example":"customer@example.com","uniqueKey":"to","typeLabel":"string"},"submittedAt":{"type":"integer","format":"int64","description":"UNIX epoch timestamp in nanoseconds when the email was accepted for processing.\nUse this for precise timing and correlation with webhook events.\n","example":1704067200000000000,"uniqueKey":"submittedAt","typeLabel":"integer\u003cint64>"},"messageId":{"type":"string","description":"Unique identifier (UUID) for this email message.\nUse this ID to track the email through webhooks and the message lookup API.\n","example":"550e8400-e29b-41d4-a716-446655440000","uniqueKey":"messageId","typeLabel":"string"},"errorCode":{"type":"integer","description":"Error code if the email submission failed:\n- 0: Success (no error)\n- 1: Invalid recipient email\n- 2: Recipient in suppression list\n- 3: `from` domain doesn't exist in this sub-account\n- 4: `from` domain isn't verified\n- 5: IP pool doesn't exist\n- 6: Template doesn't exist\n- 7: Empty template name\n- 8: Internal error (message ID generation)\n- 9: Internal error (message storage)\n- 10: Invalid attachment\n- 11: Invalid `tpspFrom`\n","example":0,"uniqueKey":"errorCode","typeLabel":"integer"},"message":{"type":"string","description":"Human-readable message describing the result.\nOn success: \"Email submitted successfully\"\nOn error: Description of what went wrong\n","example":"Email submitted successfully","uniqueKey":"message","typeLabel":"string"}},"example":{"to":"customer@example.com","submittedAt":1704067200000000000,"messageId":"550e8400-e29b-41d4-a716-446655440000","errorCode":0,"message":"Email submitted successfully"},"uniqueKey":"","typeLabel":"object"},"example":{"to":"","submittedAt":1704067200000000000,"messageId":"","errorCode":11,"message":"tpspFrom email must be on the same registered domain as from email"},"examples":{"Example":{"title":"Example","value":{"to":"","submittedAt":1704067200000000000,"messageId":"","errorCode":11,"message":"tpspFrom email must be on the same registered domain as from email"}}},"exampleType":"examples"}},"exampleType":"examples"}},"security":{"40a3e3dd-dd21-4213-a8c2-dbda2a522b96":{"subAccountAuth":{"type":"apiKey","in":"header","name":"X-SubAccount-ApiKey","description":"This api key can be used only for sub account level operations","scopes":[],"schemeName":"subAccountAuth"}}},"servers":{"3e2bf5d9-3b9c-4724-ba94-ee3efb46f2dc":{"url":"https://api.sendpost.io/api/v1"}},"processedSecurityOptions":[{"schemes":[{"scheme":{"type":"apiKey","in":"header","name":"X-SubAccount-ApiKey","description":"This api key can be used only for sub account level operations","scopes":[],"schemeName":"subAccountAuth"},"schema":{"title":"X-SubAccount-ApiKey","type":"string","description":"This api key can be used only for sub account level operations","isRequired":true,"typeLabel":"string","deprecated":false},"schemeName":"subAccountAuth","name":"X-SubAccount-ApiKey"}],"title":"subAccountAuth"}]},"originalFileLocation":"swagger.yaml"},"subdomain":"sendx-43e2b6a9","siteName":"SendPost Docs","title":"Send Email With Template - SendPost Docs","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-09-22T12:24:27.658Z","originalFileLocation":"api-reference/email/send-email-with-template.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Send emails using pre-configured templates stored in SendPost. Templates separate email content from code, enabling: Benefits: - Update email content without code deployments - Marketing teams can manage templates independently - Consistent branding across all applications - A/B test different template versions How It Works: 1. Create templates in the SendPost dashboard with Handlebars variables 2. Reference the template by name or ID in this API call 3. Pass dynamic data through recipient customFields 4. SendPost merges data with template and sends Common Use Cases: | Template Type | Dynamic Data | |---------------|--------------| | Welcome Email | firstName, accountType, loginUrl | | Order Receipt | orderNumber, items, total, shippingAddress | | Password Reset | resetLink, expiryTime, userName | | Weekly Digest | articleList, unreadCount, userName | Example Request: json { \u0026quot;from\u0026quot;: { \u0026quot;email\u0026quot;: \u0026quot;orders@yourstore.com\u0026quot; }, \u0026quot;to\u0026quot;: [{ \u0026quot;email\u0026quot;: \u0026quot;customer@example.com\u0026quot;, \u0026quot;customFields\u0026quot;: { \u0026quot;firstName\u0026quot;: \u0026quot;Sarah\u0026quot;, \u0026quot;orderNumber\u0026quot;: \u0026quot;ORD-2024-001\u0026quot;, \u0026quot;totalAmount\u0026quot;: \u0026quot;$149.99\u0026quot; } }], \u0026quot;template\u0026quot;: \u0026quot;order-confirmation-v2\u0026quot; } Note: Template variables not provided in customFields will render as empty strings.\">\u003cmeta data-mint-head name=\"application-name\" content=\"SendPost Docs\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/sendx-43e2b6a9/gASVnBX9Wp6ly5V-/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/sendx-43e2b6a9/gASVnBX9Wp6ly5V-/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/sendx-43e2b6a9/gASVnBX9Wp6ly5V-/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/sendx-43e2b6a9/gASVnBX9Wp6ly5V-/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/sendx-43e2b6a9/gASVnBX9Wp6ly5V-/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/sendx-43e2b6a9/gASVnBX9Wp6ly5V-/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/sendx-43e2b6a9/gASVnBX9Wp6ly5V-/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/sendx-43e2b6a9/gASVnBX9Wp6ly5V-/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/sendx-43e2b6a9/gASVnBX9Wp6ly5V-/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Send Email With Template - SendPost Docs\">\u003cmeta data-mint-head property=\"og:description\" content=\"Send emails using pre-configured templates stored in SendPost. Templates separate email content from code, enabling: Benefits: - Update email content without code deployments - Marketing teams can manage templates independently - Consistent branding across all applications - A/B test different template versions How It Works: 1. Create templates in the SendPost dashboard with Handlebars variables 2. Reference the template by name or ID in this API call 3. Pass dynamic data through recipient customFields 4. SendPost merges data with template and sends Common Use Cases: | Template Type | Dynamic Data | |---------------|--------------| | Welcome Email | firstName, accountType, loginUrl | | Order Receipt | orderNumber, items, total, shippingAddress | | Password Reset | resetLink, expiryTime, userName | | Weekly Digest | articleList, unreadCount, userName | Example Request: json { \u0026quot;from\u0026quot;: { \u0026quot;email\u0026quot;: \u0026quot;orders@yourstore.com\u0026quot; }, \u0026quot;to\u0026quot;: [{ \u0026quot;email\u0026quot;: \u0026quot;customer@example.com\u0026quot;, \u0026quot;customFields\u0026quot;: { \u0026quot;firstName\u0026quot;: \u0026quot;Sarah\u0026quot;, \u0026quot;orderNumber\u0026quot;: \u0026quot;ORD-2024-001\u0026quot;, \u0026quot;totalAmount\u0026quot;: \u0026quot;$149.99\u0026quot; } }], \u0026quot;template\u0026quot;: \u0026quot;order-confirmation-v2\u0026quot; } Note: Template variables not provided in customFields will render as empty strings.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"SendPost Docs\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.sendpost.io/api-reference/email/send-email-with-template\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://sendx-43e2b6a9.mintlify.site/_mintlify/api/og/v2?division=Email\u0026amp;title=Send+Email+With+Template\u0026amp;description=Send+emails+using+pre-configured+templates+stored+in+SendPost.+Templates+separate+email+content+from+code%2C+enabling%3A%0A%0A**Benefits%3A**%0A-+Update+email+content+witho\u0026amp;theme=36b9a144c81c41c7c881e1e9\u0026amp;signature=5a92f7869352927ee7f44ada3ade30c2e9b04f104023ffd4aa463a326432878c\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Send Email With Template - SendPost Docs\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Send emails using pre-configured templates stored in SendPost. Templates separate email content from code, enabling: Benefits: - Update email content without code deployments - Marketing teams can manage templates independently - Consistent branding across all applications - A/B test different template versions How It Works: 1. Create templates in the SendPost dashboard with Handlebars variables 2. Reference the template by name or ID in this API call 3. Pass dynamic data through recipient customFields 4. SendPost merges data with template and sends Common Use Cases: | Template Type | Dynamic Data | |---------------|--------------| | Welcome Email | firstName, accountType, loginUrl | | Order Receipt | orderNumber, items, total, shippingAddress | | Password Reset | resetLink, expiryTime, userName | | Weekly Digest | articleList, unreadCount, userName | Example Request: json { \u0026quot;from\u0026quot;: { \u0026quot;email\u0026quot;: \u0026quot;orders@yourstore.com\u0026quot; }, \u0026quot;to\u0026quot;: [{ \u0026quot;email\u0026quot;: \u0026quot;customer@example.com\u0026quot;, \u0026quot;customFields\u0026quot;: { \u0026quot;firstName\u0026quot;: \u0026quot;Sarah\u0026quot;, \u0026quot;orderNumber\u0026quot;: \u0026quot;ORD-2024-001\u0026quot;, \u0026quot;totalAmount\u0026quot;: \u0026quot;$149.99\u0026quot; } }], \u0026quot;template\u0026quot;: \u0026quot;order-confirmation-v2\u0026quot; } Note: Template variables not provided in customFields will render as empty strings.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://sendx-43e2b6a9.mintlify.site/_mintlify/api/og/v2?division=Email\u0026amp;title=Send+Email+With+Template\u0026amp;description=Send+emails+using+pre-configured+templates+stored+in+SendPost.+Templates+separate+email+content+from+code%2C+enabling%3A%0A%0A**Benefits%3A**%0A-+Update+email+content+witho\u0026amp;theme=36b9a144c81c41c7c881e1e9\u0026amp;signature=5a92f7869352927ee7f44ada3ade30c2e9b04f104023ffd4aa463a326432878c\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/sendx-43e2b6a9/gASVnBX9Wp6ly5V-/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"SendPost Docs\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#5750EC\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.sendpost.io/api-reference/email/send-email-with-template\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/api-reference/email/send-email-with-template.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.sendpost.io/#organization\",\"name\":\"SendPost Docs\",\"url\":\"https://docs.sendpost.io\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/sendx-43e2b6a9/xWJ6M32vFagLUxJg/logo/sendpost.svg?fit=max\u0026auto=format\u0026n=xWJ6M32vFagLUxJg\u0026q=85\u0026s=fc1d92fba901bca2cbab1ee394bc02ed\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.sendpost.io#website\",\"name\":\"SendPost Docs\",\"url\":\"https://docs.sendpost.io\",\"publisher\":{\"@id\":\"https://docs.sendpost.io/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.sendpost.io/api-reference/email/send-email-with-template#webpage\",\"url\":\"https://docs.sendpost.io/api-reference/email/send-email-with-template\",\"name\":\"Send Email With Template\",\"description\":\"Send emails using pre-configured templates stored in SendPost. Templates separate email content from code, enabling: Benefits: - Update email content without code deployments - Marketing teams can manage templates independently - Consistent branding across all applications - A/B test different template versions How It Works: 1. Create templates in the SendPost dashboard with Handlebars variables 2. Reference the template by name or ID in this API call 3. Pass dynamic data through recipient customFields 4. SendPost merges data with template and sends Common Use Cases: | Template Type | Dynamic Data | |---------------|--------------| | Welcome Email | firstName, accountType, loginUrl | | Order Receipt | orderNumber, items, total, shippingAddress | | Password Reset | resetLink, expiryTime, userName | | Weekly Digest | articleList, unreadCount, userName | Example Request: json { \\\"from\\\": { \\\"email\\\": \\\"orders@yourstore.com\\\" }, \\\"to\\\": [{ \\\"email\\\": \\\"customer@example.com\\\", \\\"customFields\\\": { \\\"firstName\\\": \\\"Sarah\\\", \\\"orderNumber\\\": \\\"ORD-2024-001\\\", \\\"totalAmount\\\": \\\"$149.99\\\" } }], \\\"template\\\": \\\"order-confirmation-v2\\\" } Note: Template variables not provided in customFields will render as empty strings.\",\"dateModified\":\"2026-09-22T12:24:27.658Z\",\"isPartOf\":{\"@id\":\"https://docs.sendpost.io#website\"},\"breadcrumb\":{\"@id\":\"https://docs.sendpost.io/api-reference/email/send-email-with-template#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.sendpost.io/api-reference/email/send-email-with-template#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Email\",\"item\":\"https://docs.sendpost.io/api-reference/email/send-email\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Send Email With Template\",\"item\":\"https://docs.sendpost.io/api-reference/email/send-email-with-template\"}]},{\"@type\":[\"TechArticle\",\"APIReference\"],\"@id\":\"https://docs.sendpost.io/api-reference/email/send-email-with-template#apireference\",\"headline\":\"Send Email With Template\",\"name\":\"Send Email With Template\",\"description\":\"Send emails using pre-configured templates stored in SendPost. Templates separate email content from code, enabling: Benefits: - Update email content without code deployments - Marketing teams can manage templates independently - Consistent branding across all applications - A/B test different template versions How It Works: 1. Create templates in the SendPost dashboard with Handlebars variables 2. Reference the template by name or ID in this API call 3. Pass dynamic data through recipient customFields 4. SendPost merges data with template and sends Common Use Cases: | Template Type | Dynamic Data | |---------------|--------------| | Welcome Email | firstName, accountType, loginUrl | | Order Receipt | orderNumber, items, total, shippingAddress | | Password Reset | resetLink, expiryTime, userName | | Weekly Digest | articleList, unreadCount, userName | Example Request: json { \\\"from\\\": { \\\"email\\\": \\\"orders@yourstore.com\\\" }, \\\"to\\\": [{ \\\"email\\\": \\\"customer@example.com\\\", \\\"customFields\\\": { \\\"firstName\\\": \\\"Sarah\\\", \\\"orderNumber\\\": \\\"ORD-2024-001\\\", \\\"totalAmount\\\": \\\"$149.99\\\" } }], \\\"template\\\": \\\"order-confirmation-v2\\\" } Note: Template variables not provided in customFields will render as empty strings.\",\"url\":\"https://docs.sendpost.io/api-reference/email/send-email-with-template\",\"mainEntityOfPage\":{\"@id\":\"https://docs.sendpost.io/api-reference/email/send-email-with-template#webpage\"},\"dateModified\":\"2026-09-22T12:24:27.658Z\",\"publisher\":{\"@id\":\"https://docs.sendpost.io/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.sendpost.io#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"SendPost Docs\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"SendPost Docs","nav":{"global":{"anchors":[]},"tabs":[{"tab":"Welcome","pages":[{"title":"Welcome","href":""}]},{"tab":"API Reference","groups":[{"group":"API Reference","pages":[{"title":"Introduction","href":"/api-reference/introduction"},{"title":"API Versioning \u0026 Migration","href":"/api-reference/api-versioning"},{"title":"Changelog","href":"/api-reference/changelog"}]},{"group":"Email","pages":[{"openapi":"post /subaccount/email/","title":"Send Email","description":"Send transactional or marketing emails to one or multiple recipients. This is the primary endpoint for all email sending through SendPost.\n\n**Capabilities:**\n- **Single Email**: Send to one recipient with full personalization\n- **Batch Sending**: Send to up to 500 recipients in a single API call\n- **Personalization**: Use Handlebars templating (`{{variableName}}`) in subject, HTML body, and text body\n- **Attachments**: Include base64-encoded files (max 25MB total per request)\n- **Tracking**: Enable/disable open and click tracking per email\n- **IP Pool Routing**: Route emails through specific IP pools\n\n**Common Use Cases:**\n\n| Use Case | Example |\n|----------|---------|\n| Order Confirmation | Send receipt with order details after purchase |\n| Password Reset | Time-sensitive security email with reset link |\n| Welcome Email | Onboard new users with personalized greeting |\n| Shipping Notification | Update customers when orders ship |\n| Invoice/Receipt | Attach PDF invoices to billing emails |\n\n**Personalization Example:**\n```json\n{\n \"to\": [{\n \"email\": \"john@example.com\",\n \"customFields\": {\n \"firstName\": \"John\",\n \"orderTotal\": \"$99.99\"\n }\n }],\n \"subject\": \"Hi {{firstName}}, your order is confirmed!\",\n \"htmlBody\": \"\u003cp>Thanks {{firstName}}! Your total: {{orderTotal}}\u003c/p>\"\n}\n```\n\n**Test Email Addresses:**\n\nSendPost provides special test email addresses for testing webhooks and events without sending real emails:\n\n| Test Email | Behavior |\n|------------|----------|\n| `test@playwithsendpost.io` | Generates delivered event, then simulates opens and clicks after a few seconds |\n| `deliver@playwithsendpost.io` | Generates delivered event only (no opens/clicks) |\n| `hardbounce@playwithsendpost.io` | Always generates a hard bounce event |\n| `softbounce@playwithsendpost.io` | Always generates a soft bounce event |\n| `dropped@playwithsendpost.io` | Always generates a dropped event (SMTPDropped) |\n\n**Self-Test Email (Send to Yourself):**\n\nUse `hello@playwithsendpost.io` as the **from** address to send emails to yourself for testing:\n\n- **Sender**: Must be `hello@playwithsendpost.io`\n- **Recipient**: Must be your account owner email (the email you used to sign up)\n- **Behavior**: Real email delivery to your inbox (no domain verification required, no mock mode)\n- **Use Case**: Test your API integration by sending real emails to yourself without domain setup\n\n**Example:**\n```json\n{\n \"from\": {\"email\": \"hello@playwithsendpost.io\"},\n \"to\": [{\"email\": \"your-account-email@example.com\"}],\n \"subject\": \"Test Email to Myself\",\n \"htmlBody\": \"\u003cp>This is a test email to myself\u003c/p>\"\n}\n```\nThis will send a real email to your inbox that you can actually receive and open.\n\n**Note**: If you send to any email other than your account email, the request will be rejected with an error.\n\n**Using Test Emails:**\n- Simply send to any test email address like a normal recipient\n- Mock mode is automatically enabled for test emails\n- All events trigger webhooks normally\n- Events are marked as mock messages but follow the same structure as real events\n- Perfect for testing webhook integrations without using real email addresses\n\n**Example:**\n```json\n{\n \"to\": [{\"email\": \"test@playwithsendpost.io\"}],\n \"from\": {\"email\": \"sender@example.com\"},\n \"subject\": \"Test Email\",\n \"htmlBody\": \"\u003cp>This is a test\u003c/p>\"\n}\n```\nThis will generate: Sent → Delivered → Opened (after 2-5s) → Clicked (after 1-3s more)\n\n**Response:** Returns an array of responses, one per recipient, each containing:\n- `messageId` - Unique ID for tracking\n- `submittedAt` - Timestamp of acceptance\n- `errorCode` and `message` - Status information\n","href":"/api-reference/email/send-email"},{"openapi":"post /subaccount/email/template","title":"Send Email With Template","href":"/api-reference/email/send-email-with-template"}]},{"group":"Domain","pages":[{"openapi":"get /subaccount/domain/{domain_id}","title":"Get Domain","description":"Retrieve detailed information about a specific sending domain, including DNS record configuration and verification status.\n\n**Response includes:**\n- Domain name and ID\n- DKIM, Return-Path, Track, and DMARC DNS records to configure\n- Verification status for each record type\n- Failure reasons if verification failed\n- Domain registration date\n\n**Use Cases:**\n- Check verification status before sending emails\n- Retrieve DNS records during domain setup\n- Debug DNS configuration issues\n- Audit domain settings for compliance\n","href":"/api-reference/domain/get-a-specific-domain"},{"openapi":"delete /subaccount/domain/{domain_id}","title":"Delete Domain","href":"/api-reference/domain/delete-a-specific-domain"},{"openapi":"get /subaccount/domain","title":"List Domains","href":"/api-reference/domain/get-all-domains"},{"openapi":"post /subaccount/domain","title":"Create Domain","href":"/api-reference/domain/create-a-new-domain"}]},{"group":"Stats","pages":[{"openapi":"get /account/subaccount/stat/{subaccount_id}","title":"List Stats","href":"/api-reference/stats/get-all-stats"},{"openapi":"get /account/subaccount/stat/{subaccount_id}/aggregate","title":"Get Aggregate Stats","href":"/api-reference/stats/get-aggregate-stats"},{"openapi":"get /account/subaccount/stat/{subaccount_id}/group","title":"Get Group Aggregate Stats","href":"/api-reference/stats/get-aggregated-stats-by-group"}]},{"group":"Suppression","pages":[{"openapi":"get /subaccount/suppression","title":"List Suppressions","href":"/api-reference/suppression/get-all-suppressions"},{"openapi":"post /subaccount/suppression","title":"Create Suppressions","href":"/api-reference/suppression/create-new-suppressions"},{"openapi":"delete /subaccount/suppression","title":"Delete Suppressions","href":"/api-reference/suppression/delete-suppressions"}]},{"group":"IP","pages":[{"openapi":"get /account/ip/","title":"List IPs","href":"/api-reference/ip/get-all-ips"},{"openapi":"get /account/ip/{ip_id}","title":"Get IP","href":"/api-reference/ip/get-a-specific-ip"},{"openapi":"put /account/ip/{ip_id}","title":"Update IP","href":"/api-reference/ip/update-an-existing-ip"},{"openapi":"delete /account/ip/{ip_id}","title":"Delete IP","href":"/api-reference/ip/delete-a-specific-ip"},{"openapi":"put /account/ip/allocate","title":"Allocate IP","href":"/api-reference/ip/allocate-a-new-ip"}]},{"group":"Message","pages":[{"openapi":"get /account/message/{message_id}","title":"Get Message","href":"/api-reference/message/retrieve-a-specific-message"}]},{"group":"IPPools","pages":[{"title":"Routing Strategies and Metadata","href":"/api-reference/ippools/routing"},{"openapi":"get /account/ippool","title":"List IPPools","href":"/api-reference/ippools/get-all-ippools"},{"openapi":"post /account/ippool","title":"Create IPPool","href":"/api-reference/ippools/create-a-new-ippool"},{"openapi":"get /account/ippool/{ippool_id}","title":"Get IPPool","href":"/api-reference/ippools/get-a-specific-ippool"},{"openapi":"put /account/ippool/{ippool_id}","title":"Update IPPool","href":"/api-reference/ippools/update-an-existing-ippool"},{"openapi":"delete /account/ippool/{ippool_id}","title":"Delete IPPool","href":"/api-reference/ippools/delete-a-specific-ippool"}]},{"group":"Stats (A)","pages":[{"openapi":"get /account/stat","title":"List Account Stats","href":"/api-reference/stats-a/get-all-account-stats"},{"openapi":"get /account/stat/aggregate","title":"Get Account Aggregate Stats","href":"/api-reference/stats-a/get-account-aggregate-stats"},{"openapi":"get /account/stat/group","title":"List Account Group Stats","href":"/api-reference/stats-a/get-all-account-stats-by-group"},{"openapi":"get /account/stat/aggregate/group","title":"Get Account Group Aggregate Stats","href":"/api-reference/stats-a/get-account-aggregate-stats-by-group"}]},{"group":"Sub-Account","pages":[{"openapi":"get /account/subaccount/","title":"List Sub-Accounts","href":"/api-reference/sub-account/get-all-sub-accounts"},{"openapi":"post /account/subaccount/","title":"Create Sub-Account","href":"/api-reference/sub-account/create-a-new-sub-account"},{"openapi":"get /account/subaccount/{subaccount_id}","title":"Get Sub-Account","href":"/api-reference/sub-account/get-a-specific-sub-account"},{"openapi":"put /account/subaccount/{subaccount_id}","title":"Update Sub-Account","href":"/api-reference/sub-account/update-an-existing-sub-account"},{"openapi":"delete /account/subaccount/{subaccount_id}","title":"Delete Sub-Account","href":"/api-reference/sub-account/delete-a-specific-sub-account"}]},{"group":"Webhook","pages":[{"title":"Webhook Reference","href":"/api-reference/webhook/webhook-testing"},{"title":"Understanding Webhook Event Lifecycle","href":"/api-reference/webhook/understanding-webhook-event-lifecycle"},{"title":"Real-Time Validation Results","href":"/api-reference/webhook/validation-results"},{"title":"Webhook Signature Verification","href":"/api-reference/webhook/webhook-signature-verification"},{"openapi":"get /account/webhook","title":"List Webhooks","href":"/api-reference/webhook/get-all-webhooks"},{"openapi":"post /account/webhook","title":"Create Webhook","href":"/api-reference/webhook/create-a-new-webhook"},{"openapi":"get /account/webhook/{webhook_id}","title":"Get Webhook","href":"/api-reference/webhook/get-a-specific-webhook"},{"openapi":"put /account/webhook/{webhook_id}","title":"Update Webhook","href":"/api-reference/webhook/update-an-existing-webhook"},{"openapi":"delete /account/webhook/{webhook_id}","title":"Delete Webhook","href":"/api-reference/webhook/delete-a-specific-webhook"},{"openapi":"webhook SendPostWebhooks","title":"SendPost Webhook Object","href":"/api-reference/webhook/sendpost-webhook-object"}]}]}]},"basePath":"","title":"Send Email With Template - SendPost Docs","buildId":"dpl_42LwxxU1kGN114H4XzwGYXa9ZDah","deploymentId":"dpl_42LwxxU1kGN114H4XzwGYXa9ZDah","dynamics":["c2aa737661","2b790eda92","b0f84f53ff","a9bb46feb3"],"chunks":["OpenApiReferenceProvider-C-hEh3I2.js","utils-CnF4QiUD.js","cloneDeep-izs3Hzxb.js","_Uint8Array-BVIqJ90l.js","isObjectLike-C8vmzPEN.js","isArray-Dcu1dQ5t.js","utils-C7PVNbel.js","toString-BX-iyh8G.js","isSymbol-CSH9U2Gm.js","addUniqueKeysToSchema-8ytevL2A.js","snippetPresets-BT1alx3v.js","style-to-object-BY3JEAdk.js","v4-DIgz8zy6.js","conditional-requirements-CFM0id0Q.js","ApiExamples-BLXC0i_W.js","isEqual-BfaiBbcl.js","usePlaygroundInputsStore-CyLIGI9_.js","shallow-DC0lGVIW.js","getApiPlaygroundDisplay-CgDQ85tN.js","CodeSnippet-6-I-Gpv9.js","CodeSnippets-BAk1kDdu.js","Page-C945cI-W.js","getPastedJson-B276RuWN.js","icon-BqP8etTm.js","MethodPill-DM6sbxG1.js","DuplicateIcon-PyJglOaE.js","createIcon-CMeOMAc_.js","DynamicMarkdown-BoyYAA8K.js","SectionHeading-DAYv3gvZ.js","axios-vUo_bRtp.js","Markdown-BhTTmazV.js","clsx-CR-RHrVC.js","lib-DuNMoZ05.js","lib-B8HbPgcC.js","html-void-elements-mCSPHezU.js","dist-CBUH0-zX.js","katex-YMM-FMeD.js","marked.esm-CZWythHk.js","AssistantPageLink-BmARFYNC.js"]}