Email Templates Sync
LeadCMS supports email template synchronisation through dedicated CLI commands. This lets you keep template files in source control and safely sync changes to and from your instance.
Commands overview
pull-email-templates– Pull remote templates into your localemailTemplatesDir.status-email-templates– Compare local templates with remote templates.push-email-templates– Push local template changes to LeadCMS.
By default, templates are stored in .leadcms/email-templates unless overridden with LEADCMS_EMAIL_TEMPLATES_DIR.
Pull email templates
Use this command to download templates from LeadCMS:
pnpm exec leadcms pull-email-templates
Useful options:
--id <template-id>– Pull only one template by ID.--reset– Clear local email template state and perform a fresh pull.
In multi‑remote mode, local email template files keep the default remote's id, createdAt, and updatedAt. When you pull from another remote, that remote's own values are stored in .leadcms/remotes/<name>/metadata.json.
Targeting a specific remote
All email template sync commands support --remote / -r:
npx leadcms pull-email-templates -r dev
npx leadcms status-email-templates -r prod
npx leadcms push-email-templates -r dev
When omitted, the SDK uses the configured defaultRemote.
Email template sync requires authentication for write operations. For pull/status, behavior depends on your instance permissions and API key setup.
Check template status
Before pushing, inspect changes:
pnpm exec leadcms status-email-templates
Options:
--id <template-id>– Show status for one template.--preview– Show more detailed metadata preview for each change.--delete– Include delete operations in output.
Push template changes
Push local template updates back to LeadCMS:
pnpm exec leadcms push-email-templates
Options:
--dry-run– Show what would be pushed without changing remote data.--force– Skip confirmation/conflict prompts where applicable.--delete– Delete remote templates that no longer exist locally.--id <template-id>– Push only one template by ID.--name <name>– Push only one template by name.
When pushing in multi‑remote mode, the SDK matches and updates templates using the selected remote's own metadata state, not whichever ID or timestamp happens to be present in the local file.
Recommended workflow
- Pull latest templates:
leadcms pull-email-templates - Edit local template files.
- Review changes:
leadcms status-email-templates --preview - Validate safely:
leadcms push-email-templates --dry-run - Apply changes:
leadcms push-email-templates
Best practices
- Pull before push to reduce conflicts.
- Use
--dry-runfor large template batches. - Use targeted pushes (
--idor--name) when debugging one template. - Use
--deletecarefully to avoid unintended removals.