@cakemail-org/cakemail-cli 1.5.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (234) hide show
  1. package/.claude/settings.local.json +12 -0
  2. package/.env.example +40 -0
  3. package/.env.test.example +45 -0
  4. package/CHANGELOG.md +1031 -0
  5. package/README.md +319 -15
  6. package/audit-formats.js +128 -0
  7. package/cakemail.rb +20 -0
  8. package/dist/cli.js +27 -10
  9. package/dist/cli.js.map +1 -1
  10. package/dist/client.d.ts +2 -0
  11. package/dist/client.d.ts.map +1 -1
  12. package/dist/client.js +16 -6
  13. package/dist/client.js.map +1 -1
  14. package/dist/commands/account.js +1 -1
  15. package/dist/commands/account.js.map +1 -1
  16. package/dist/commands/attributes.js +1 -1
  17. package/dist/commands/attributes.js.map +1 -1
  18. package/dist/commands/campaigns.d.ts.map +1 -1
  19. package/dist/commands/campaigns.js +103 -8
  20. package/dist/commands/campaigns.js.map +1 -1
  21. package/dist/commands/config.d.ts.map +1 -1
  22. package/dist/commands/config.js +63 -4
  23. package/dist/commands/config.js.map +1 -1
  24. package/dist/commands/contacts.d.ts.map +1 -1
  25. package/dist/commands/contacts.js +91 -12
  26. package/dist/commands/contacts.js.map +1 -1
  27. package/dist/commands/emails.js +1 -1
  28. package/dist/commands/emails.js.map +1 -1
  29. package/dist/commands/interests.d.ts +5 -0
  30. package/dist/commands/interests.d.ts.map +1 -0
  31. package/dist/commands/interests.js +172 -0
  32. package/dist/commands/interests.js.map +1 -0
  33. package/dist/commands/lists.d.ts.map +1 -1
  34. package/dist/commands/lists.js +6 -8
  35. package/dist/commands/lists.js.map +1 -1
  36. package/dist/commands/logs.d.ts +5 -0
  37. package/dist/commands/logs.d.ts.map +1 -0
  38. package/dist/commands/logs.js +237 -0
  39. package/dist/commands/logs.js.map +1 -0
  40. package/dist/commands/reports.js +1 -1
  41. package/dist/commands/reports.js.map +1 -1
  42. package/dist/commands/segments.js +1 -1
  43. package/dist/commands/segments.js.map +1 -1
  44. package/dist/commands/senders.d.ts.map +1 -1
  45. package/dist/commands/senders.js +11 -8
  46. package/dist/commands/senders.js.map +1 -1
  47. package/dist/commands/suppressed.js +1 -1
  48. package/dist/commands/suppressed.js.map +1 -1
  49. package/dist/commands/tags.d.ts +5 -0
  50. package/dist/commands/tags.d.ts.map +1 -0
  51. package/dist/commands/tags.js +124 -0
  52. package/dist/commands/tags.js.map +1 -0
  53. package/dist/commands/templates.js +1 -1
  54. package/dist/commands/templates.js.map +1 -1
  55. package/dist/commands/transactional-templates.d.ts +5 -0
  56. package/dist/commands/transactional-templates.d.ts.map +1 -0
  57. package/dist/commands/transactional-templates.js +354 -0
  58. package/dist/commands/transactional-templates.js.map +1 -0
  59. package/dist/commands/webhooks.js +1 -1
  60. package/dist/commands/webhooks.js.map +1 -1
  61. package/dist/utils/auth.d.ts +8 -1
  62. package/dist/utils/auth.d.ts.map +1 -1
  63. package/dist/utils/auth.js +39 -11
  64. package/dist/utils/auth.js.map +1 -1
  65. package/dist/utils/config-file.d.ts +7 -0
  66. package/dist/utils/config-file.d.ts.map +1 -1
  67. package/dist/utils/config-file.js +15 -0
  68. package/dist/utils/config-file.js.map +1 -1
  69. package/dist/utils/config.d.ts +2 -0
  70. package/dist/utils/config.d.ts.map +1 -1
  71. package/dist/utils/config.js +12 -4
  72. package/dist/utils/config.js.map +1 -1
  73. package/dist/utils/errors.js +1 -1
  74. package/dist/utils/errors.js.map +1 -1
  75. package/dist/utils/list-defaults.d.ts +33 -0
  76. package/dist/utils/list-defaults.d.ts.map +1 -0
  77. package/dist/utils/list-defaults.js +52 -0
  78. package/dist/utils/list-defaults.js.map +1 -0
  79. package/dist/utils/output.d.ts.map +1 -1
  80. package/dist/utils/output.js +36 -13
  81. package/dist/utils/output.js.map +1 -1
  82. package/dist/utils/progress.d.ts.map +1 -1
  83. package/dist/utils/progress.js +32 -4
  84. package/dist/utils/progress.js.map +1 -1
  85. package/dist/utils/spinner.d.ts +17 -0
  86. package/dist/utils/spinner.d.ts.map +1 -0
  87. package/dist/utils/spinner.js +43 -0
  88. package/dist/utils/spinner.js.map +1 -0
  89. package/docs/DOCUMENTATION-STANDARD.md +1068 -0
  90. package/docs/README.md +161 -0
  91. package/docs/developer/ARCHITECTURE.md +516 -0
  92. package/docs/developer/AUTH.md +204 -0
  93. package/docs/developer/CONTRIBUTING.md +227 -0
  94. package/docs/developer/DOCUMENTATION_SUMMARY.md +346 -0
  95. package/docs/developer/PROJECT_INDEX.md +365 -0
  96. package/docs/planning/API_COVERAGE.md +1045 -0
  97. package/docs/planning/BACKLOG.md +1159 -0
  98. package/docs/planning/PROFILE_SYSTEM_TASKS.md +287 -0
  99. package/docs/planning/UX_IMPLEMENTATION_PLAN.md +691 -0
  100. package/docs/planning/archive/RELEASE_CHECKLIST_v1.3.0.md +332 -0
  101. package/docs/planning/archive/RELEASE_v1.3.0.md +428 -0
  102. package/docs/planning/archive/cakemail-cli-ux-improvements.md +438 -0
  103. package/docs/planning/cakemail-profile-system-plan.md +1121 -0
  104. package/docs/testing/AI_USER_SIMULATION_DESIGN.md +1342 -0
  105. package/docs/testing/KENOGAMI_BIDIRECTIONAL_FLOW.md +1517 -0
  106. package/docs/testing/KENOGAMI_TRUTH_RECONCILIATION_SYSTEM.md +1369 -0
  107. package/docs/user-manual/.obsidian/app.json +1 -0
  108. package/docs/user-manual/.obsidian/appearance.json +1 -0
  109. package/docs/user-manual/.obsidian/core-plugins.json +33 -0
  110. package/docs/user-manual/.obsidian/workspace.json +167 -0
  111. package/docs/user-manual/01-getting-started/01-installation.md +214 -0
  112. package/docs/user-manual/01-getting-started/02-quick-start.md +432 -0
  113. package/docs/user-manual/01-getting-started/03-authentication.md +448 -0
  114. package/docs/user-manual/01-getting-started/04-configuration.md +430 -0
  115. package/docs/user-manual/01-getting-started/05-output-formats.md +447 -0
  116. package/docs/user-manual/02-core-concepts/01-accounts.md +514 -0
  117. package/docs/user-manual/02-core-concepts/02-profile-system.md +771 -0
  118. package/docs/user-manual/02-core-concepts/03-smart-defaults.md +485 -0
  119. package/docs/user-manual/02-core-concepts/04-authentication-methods.md +435 -0
  120. package/docs/user-manual/02-core-concepts/05-pagination-filtering.md +600 -0
  121. package/docs/user-manual/02-core-concepts/06-error-handling.md +718 -0
  122. package/docs/user-manual/02-core-concepts/07-api-coverage.md +483 -0
  123. package/docs/user-manual/03-email-operations/01-senders.md +490 -0
  124. package/docs/user-manual/03-email-operations/02-templates.md +444 -0
  125. package/docs/user-manual/03-email-operations/03-transactional-emails.md +706 -0
  126. package/docs/user-manual/03-email-operations/04-email-tracking.md +407 -0
  127. package/docs/user-manual/04-campaign-management/01-campaigns-basics.md +394 -0
  128. package/docs/user-manual/04-campaign-management/02-campaign-scheduling.md +630 -0
  129. package/docs/user-manual/04-campaign-management/03-campaign-testing.md +997 -0
  130. package/docs/user-manual/04-campaign-management/04-campaign-lifecycle.md +709 -0
  131. package/docs/user-manual/04-campaign-management/05-campaign-links.md +934 -0
  132. package/docs/user-manual/05-contact-management/01-lists.md +836 -0
  133. package/docs/user-manual/05-contact-management/02-contacts.md +1035 -0
  134. package/docs/user-manual/05-contact-management/03-custom-attributes.md +788 -0
  135. package/docs/user-manual/05-contact-management/04-segments.md +1028 -0
  136. package/docs/user-manual/05-contact-management/05-contact-import-export.md +1031 -0
  137. package/docs/user-manual/06-analytics-reporting/01-campaign-analytics.md +867 -0
  138. package/docs/user-manual/06-analytics-reporting/02-account-reports.md +227 -0
  139. package/docs/user-manual/07-integrations/01-webhooks-integration.md +259 -0
  140. package/docs/user-manual/07-integrations/02-automation.md +326 -0
  141. package/docs/user-manual/08-advanced-usage/01-scripting-patterns.md +672 -0
  142. package/docs/user-manual/08-advanced-usage/02-bulk-operations.md +932 -0
  143. package/docs/user-manual/08-advanced-usage/03-ci-cd-integration.md +892 -0
  144. package/docs/user-manual/08-advanced-usage/04-performance-optimization.md +766 -0
  145. package/docs/user-manual/09-command-reference/01-config.md +776 -0
  146. package/docs/user-manual/09-command-reference/02-account.md +652 -0
  147. package/docs/user-manual/09-command-reference/03-lists.md +958 -0
  148. package/docs/user-manual/09-command-reference/04-contacts.md +1408 -0
  149. package/docs/user-manual/09-command-reference/05-attributes.md +617 -0
  150. package/docs/user-manual/09-command-reference/06-segments.md +894 -0
  151. package/docs/user-manual/09-command-reference/07-senders.md +803 -0
  152. package/docs/user-manual/09-command-reference/08-templates.md +818 -0
  153. package/docs/user-manual/09-command-reference/09-campaigns.md +1250 -0
  154. package/docs/user-manual/09-command-reference/10-emails.md +807 -0
  155. package/docs/user-manual/09-command-reference/11-reports.md +1135 -0
  156. package/docs/user-manual/09-command-reference/12-webhooks.md +773 -0
  157. package/docs/user-manual/09-command-reference/13-suppressed.md +797 -0
  158. package/docs/user-manual/09-command-reference/14-interests.md +630 -0
  159. package/docs/user-manual/09-command-reference/15-tags.md +584 -0
  160. package/docs/user-manual/09-command-reference/16-logs.md +656 -0
  161. package/docs/user-manual/09-command-reference/17-transactional-templates.md +850 -0
  162. package/docs/user-manual/10-troubleshooting/01-common-errors.md +457 -0
  163. package/docs/user-manual/10-troubleshooting/02-authentication-issues.md +558 -0
  164. package/docs/user-manual/10-troubleshooting/03-connection-problems.md +634 -0
  165. package/docs/user-manual/10-troubleshooting/04-debugging.md +725 -0
  166. package/docs/user-manual/11-appendix/04-faq.md +484 -0
  167. package/docs/user-manual/11-appendix/05-glossary.md +250 -0
  168. package/docs/user-manual/README.md +0 -0
  169. package/package.json +13 -47
  170. package/src/cli.ts +125 -0
  171. package/src/client.ts +16 -0
  172. package/src/commands/account.ts +267 -0
  173. package/src/commands/accounts.ts +78 -0
  174. package/src/commands/actions.ts +249 -0
  175. package/src/commands/attributes.ts +139 -0
  176. package/src/commands/campaign-blueprints.ts +106 -0
  177. package/src/commands/campaigns.ts +469 -0
  178. package/src/commands/config.ts +77 -0
  179. package/src/commands/contacts.ts +612 -0
  180. package/src/commands/custom-attributes.ts +127 -0
  181. package/src/commands/dkims.ts +117 -0
  182. package/src/commands/domains.ts +82 -0
  183. package/src/commands/email-apis.ts +569 -0
  184. package/src/commands/emails.ts +197 -0
  185. package/src/commands/forms.ts +283 -0
  186. package/src/commands/interests.ts +155 -0
  187. package/src/commands/links.ts +38 -0
  188. package/src/commands/lists.ts +406 -0
  189. package/src/commands/logos.ts +71 -0
  190. package/src/commands/logs.ts +386 -0
  191. package/src/commands/reports.ts +306 -0
  192. package/src/commands/segments.ts +158 -0
  193. package/src/commands/senders.ts +204 -0
  194. package/src/commands/sub-accounts.ts +271 -0
  195. package/src/commands/suppressed-emails.ts +234 -0
  196. package/src/commands/suppressed.ts +198 -0
  197. package/src/commands/system-emails.ts +85 -0
  198. package/src/commands/tags.ts +146 -0
  199. package/src/commands/tasks.ts +116 -0
  200. package/src/commands/templates.ts +189 -0
  201. package/src/commands/tokens.ts +83 -0
  202. package/src/commands/transactional-emails.ts +374 -0
  203. package/src/commands/transactional-templates.ts +385 -0
  204. package/src/commands/users.ts +506 -0
  205. package/src/commands/webhooks.ts +172 -0
  206. package/src/commands/workflow-blueprints.ts +123 -0
  207. package/src/commands/workflows.ts +265 -0
  208. package/src/types/profile.ts +93 -0
  209. package/src/utils/auth.ts +272 -0
  210. package/src/utils/config-file.ts +96 -0
  211. package/src/utils/config.ts +134 -0
  212. package/src/utils/confirm.ts +32 -0
  213. package/src/utils/defaults.ts +99 -0
  214. package/src/utils/errors.ts +116 -0
  215. package/src/utils/interactive.ts +91 -0
  216. package/src/utils/list-defaults.ts +74 -0
  217. package/src/utils/output.ts +190 -0
  218. package/src/utils/progress.ts +320 -0
  219. package/src/utils/spinner.ts +22 -0
  220. package/tests/IMPLEMENTATION_STATUS.md +258 -0
  221. package/tests/PTY_SETUP.md +118 -0
  222. package/tests/PTY_TESTING_GUIDE.md +507 -0
  223. package/tests/README.md +244 -0
  224. package/tests/fixtures/api-responses/campaigns.json +34 -0
  225. package/tests/fixtures/test-config.json +13 -0
  226. package/tests/helpers/cli-runner.ts +128 -0
  227. package/tests/helpers/mock-server.ts +301 -0
  228. package/tests/helpers/pty-runner.ts +181 -0
  229. package/tests/integration/campaigns-real-api.test.ts +196 -0
  230. package/tests/integration/setup-integration.ts +50 -0
  231. package/tests/pty/campaigns.test.ts +241 -0
  232. package/tests/setup.ts +34 -0
  233. package/tsconfig.json +15 -0
  234. package/vitest.config.ts +28 -0
@@ -0,0 +1,850 @@
1
+ # Transactional Templates Commands
2
+
3
+ Manage transactional email templates.
4
+
5
+ ## Overview
6
+
7
+ Transactional templates are reusable email templates for sending automated, personalized emails like order confirmations, password resets, welcome emails, and notifications. Unlike campaign templates, these are designed for one-to-one triggered emails.
8
+
9
+ **Available Commands:**
10
+ - [`transactional-templates list`](#transactional-templates-list) - List all templates
11
+ - [`transactional-templates show`](#transactional-templates-show) - Show template details
12
+ - [`transactional-templates create`](#transactional-templates-create) - Create new template
13
+ - [`transactional-templates update`](#transactional-templates-update) - Update template
14
+ - [`transactional-templates delete`](#transactional-templates-delete) - Delete template
15
+ - [`transactional-templates send`](#transactional-templates-send) - Send template to recipient
16
+ - [`transactional-templates test`](#transactional-templates-test) - Send test email
17
+ - [`transactional-templates render`](#transactional-templates-render) - Render template preview
18
+
19
+ **Key Features:**
20
+ - Variable substitution `{{variable_name}}`
21
+ - HTML and plain text versions
22
+ - Contact or email recipient
23
+ - Auto-detection support (list-scoped)
24
+ - Profile-aware delete confirmations
25
+
26
+ **Use Cases:**
27
+ - Order confirmations
28
+ - Password reset emails
29
+ - Welcome emails
30
+ - Account notifications
31
+ - Shipping updates
32
+ - Invoice receipts
33
+
34
+ ---
35
+
36
+ ## transactional-templates list
37
+
38
+ List all transactional templates.
39
+
40
+ ### Usage
41
+
42
+ ```bash
43
+ cakemail transactional-templates list [list-id] [options]
44
+ ```
45
+
46
+ ### Arguments
47
+
48
+ - `[list-id]` - List ID (optional - auto-detects if only one list exists)
49
+
50
+ ### Options
51
+
52
+ - `-p, --page <number>` - Page number
53
+ - `--per-page <number>` - Results per page
54
+ - `--sort <sort>` - Sort order (e.g., `+name`, `-created_on`)
55
+ - `--filter <filter>` - Filter templates
56
+
57
+ ### Examples
58
+
59
+ **List all templates (auto-detect):**
60
+ ```bash
61
+ $ cakemail transactional-templates list
62
+ ```
63
+
64
+ **Output:**
65
+ ```
66
+ ✓ Auto-detected list: 123 (Main List)
67
+
68
+ ┌────┬──────────────────────┬─────────────┬─────────────────────┐
69
+ │ ID │ Name │ Sender │ Created │
70
+ ├────┼──────────────────────┼─────────────┼─────────────────────┤
71
+ │ 1 │ Order Confirmation │ Shop (456) │ 2025-09-15 10:23:11 │
72
+ │ 2 │ Password Reset │ System(789) │ 2025-09-20 14:05:42 │
73
+ │ 3 │ Welcome Email │ Team (456) │ 2025-10-01 08:15:33 │
74
+ └────┴──────────────────────┴─────────────┴─────────────────────┘
75
+ ```
76
+
77
+ **List for specific list:**
78
+ ```bash
79
+ $ cakemail transactional-templates list 123
80
+ ```
81
+
82
+ **Sorted by name:**
83
+ ```bash
84
+ $ cakemail transactional-templates list --sort +name
85
+ ```
86
+
87
+ **JSON output:**
88
+ ```bash
89
+ $ cakemail -f json transactional-templates list
90
+ ```
91
+
92
+ **Output:**
93
+ ```json
94
+ {
95
+ "data": [
96
+ {
97
+ "id": 1,
98
+ "name": "Order Confirmation",
99
+ "subject": "Your order #{{order_id}}",
100
+ "sender_id": 456,
101
+ "created_on": "2025-09-15T10:23:11Z"
102
+ }
103
+ ]
104
+ }
105
+ ```
106
+
107
+ ---
108
+
109
+ ## transactional-templates show
110
+
111
+ Show details for a specific template.
112
+
113
+ ### Usage
114
+
115
+ ```bash
116
+ cakemail transactional-templates show [list-id] <template-id>
117
+ ```
118
+
119
+ ### Arguments
120
+
121
+ - `[list-id]` - List ID (optional - auto-detects if only one list exists)
122
+ - `<template-id>` - Template ID (required)
123
+
124
+ ### Examples
125
+
126
+ **Show template (auto-detect list):**
127
+ ```bash
128
+ $ cakemail transactional-templates show 1
129
+ ```
130
+
131
+ **Output:**
132
+ ```
133
+ Template: Order Confirmation (ID: 1)
134
+
135
+ Details:
136
+ Subject: Your order #{{order_id}}
137
+ Sender: Shop <shop@company.com> (456)
138
+ Created: 2025-09-15 10:23:11
139
+ Last Updated: 2025-10-01 15:22:33
140
+
141
+ Variables:
142
+ - {{order_id}}
143
+ - {{customer_name}}
144
+ - {{order_total}}
145
+ - {{order_items}}
146
+
147
+ Content:
148
+ HTML: 2,456 characters
149
+ Text: 1,234 characters
150
+ ```
151
+
152
+ **Show with specific list:**
153
+ ```bash
154
+ $ cakemail transactional-templates show 123 1
155
+ ```
156
+
157
+ **JSON output:**
158
+ ```bash
159
+ $ cakemail -f json transactional-templates show 1
160
+ ```
161
+
162
+ **Output:**
163
+ ```json
164
+ {
165
+ "id": 1,
166
+ "name": "Order Confirmation",
167
+ "subject": "Your order #{{order_id}}",
168
+ "html": "<html>...</html>",
169
+ "text": "Plain text version...",
170
+ "sender_id": 456,
171
+ "variables": ["order_id", "customer_name", "order_total"],
172
+ "created_on": "2025-09-15T10:23:11Z",
173
+ "updated_on": "2025-10-01T15:22:33Z"
174
+ }
175
+ ```
176
+
177
+ ---
178
+
179
+ ## transactional-templates create
180
+
181
+ Create a new transactional template.
182
+
183
+ ### Usage
184
+
185
+ ```bash
186
+ cakemail transactional-templates create [list-id] [options]
187
+ ```
188
+
189
+ ### Arguments
190
+
191
+ - `[list-id]` - List ID (optional - auto-detects if only one list exists)
192
+
193
+ ### Options
194
+
195
+ - `-n, --name <name>` - Template name (required)
196
+ - `-s, --subject <subject>` - Email subject with variables (required)
197
+ - `--html <html>` - HTML content (required)
198
+ - `--text <text>` - Plain text content (optional)
199
+ - `--sender-id <id>` - Sender ID (required)
200
+
201
+ ### Examples
202
+
203
+ **Create basic template:**
204
+ ```bash
205
+ $ cakemail transactional-templates create \
206
+ --name "Order Confirmation" \
207
+ --subject "Your order #{{order_id}}" \
208
+ --html "<h1>Thank you {{customer_name}}!</h1>" \
209
+ --sender-id 456
210
+ ```
211
+
212
+ **Output:**
213
+ ```
214
+ ✓ Auto-detected list: 123 (Main List)
215
+ ✓ Template created successfully
216
+
217
+ Template: Order Confirmation
218
+ ID: 4
219
+ Subject: Your order #{{order_id}}
220
+ Variables detected: order_id, customer_name
221
+ ```
222
+
223
+ **Create with HTML and text:**
224
+ ```bash
225
+ $ cakemail transactional-templates create \
226
+ --name "Welcome Email" \
227
+ --subject "Welcome to {{company_name}}" \
228
+ --html "<h1>Welcome {{first_name}}!</h1><p>Thanks for signing up.</p>" \
229
+ --text "Welcome {{first_name}}! Thanks for signing up." \
230
+ --sender-id 456
231
+ ```
232
+
233
+ **Create from files:**
234
+ ```bash
235
+ $ cakemail transactional-templates create \
236
+ --name "Invoice" \
237
+ --subject "Invoice #{{invoice_id}}" \
238
+ --html "$(cat templates/invoice.html)" \
239
+ --text "$(cat templates/invoice.txt)" \
240
+ --sender-id 456
241
+ ```
242
+
243
+ **JSON output:**
244
+ ```bash
245
+ $ cakemail -f json transactional-templates create \
246
+ --name "Receipt" \
247
+ --subject "Receipt #{{receipt_id}}" \
248
+ --html "<html>...</html>" \
249
+ --sender-id 456
250
+ ```
251
+
252
+ **Output:**
253
+ ```json
254
+ {
255
+ "id": 5,
256
+ "name": "Receipt",
257
+ "subject": "Receipt #{{receipt_id}}",
258
+ "html": "<html>...</html>",
259
+ "sender_id": 456,
260
+ "created_on": "2025-10-11T15:30:00Z"
261
+ }
262
+ ```
263
+
264
+ ### Variable Syntax
265
+
266
+ Use double curly braces for variables:
267
+ - `{{variable_name}}` - Simple variable
268
+ - `{{first_name}}` - Contact field
269
+ - `{{order_id}}` - Custom variable
270
+ - `{{company.name}}` - Nested object (if supported)
271
+
272
+ **Example:**
273
+ ```html
274
+ <h1>Hello {{first_name}} {{last_name}}</h1>
275
+ <p>Your order #{{order_id}} for ${{order_total}} is confirmed.</p>
276
+ ```
277
+
278
+ ---
279
+
280
+ ## transactional-templates update
281
+
282
+ Update an existing template.
283
+
284
+ ### Usage
285
+
286
+ ```bash
287
+ cakemail transactional-templates update [list-id] <template-id> [options]
288
+ ```
289
+
290
+ ### Arguments
291
+
292
+ - `[list-id]` - List ID (optional - auto-detects if only one list exists)
293
+ - `<template-id>` - Template ID (required)
294
+
295
+ ### Options
296
+
297
+ - `-n, --name <name>` - New template name (optional)
298
+ - `-s, --subject <subject>` - New subject (optional)
299
+ - `--html <html>` - New HTML content (optional)
300
+ - `--text <text>` - New plain text content (optional)
301
+ - `--sender-id <id>` - New sender ID (optional)
302
+
303
+ ### Examples
304
+
305
+ **Update subject:**
306
+ ```bash
307
+ $ cakemail transactional-templates update 1 \
308
+ --subject "Order #{{order_id}} Confirmed"
309
+ ```
310
+
311
+ **Output:**
312
+ ```
313
+ ✓ Template updated successfully
314
+
315
+ Template: Order Confirmation (1)
316
+ Subject: Order #{{order_id}} Confirmed (updated)
317
+ Last Updated: just now
318
+ ```
319
+
320
+ **Update HTML content:**
321
+ ```bash
322
+ $ cakemail transactional-templates update 1 \
323
+ --html "<h1>Updated template</h1>"
324
+ ```
325
+
326
+ **Update from file:**
327
+ ```bash
328
+ $ cakemail transactional-templates update 1 \
329
+ --html "$(cat templates/order-v2.html)"
330
+ ```
331
+
332
+ **Update multiple fields:**
333
+ ```bash
334
+ $ cakemail transactional-templates update 1 \
335
+ --name "Order Confirmation v2" \
336
+ --subject "Your {{company_name}} Order" \
337
+ --html "$(cat new-template.html)"
338
+ ```
339
+
340
+ ---
341
+
342
+ ## transactional-templates delete
343
+
344
+ Delete a transactional template.
345
+
346
+ ### Usage
347
+
348
+ ```bash
349
+ cakemail transactional-templates delete [list-id] <template-id> [options]
350
+ ```
351
+
352
+ ### Arguments
353
+
354
+ - `[list-id]` - List ID (optional - auto-detects if only one list exists)
355
+ - `<template-id>` - Template ID (required)
356
+
357
+ ### Options
358
+
359
+ - `-f, --force` - Skip confirmation prompt
360
+
361
+ ### Examples
362
+
363
+ **Delete with confirmation:**
364
+ ```bash
365
+ $ cakemail transactional-templates delete 1
366
+ ```
367
+
368
+ **Output:**
369
+ ```
370
+ ✓ Auto-detected list: 123 (Main List)
371
+
372
+ ⚠ Delete template 'Order Confirmation'?
373
+ Template ID: 1
374
+ This action cannot be undone
375
+ Integrations using this template will break
376
+
377
+ Delete template? (y/N): y
378
+
379
+ ✓ Template deleted successfully
380
+ ```
381
+
382
+ **Force delete:**
383
+ ```bash
384
+ $ cakemail transactional-templates delete 1 --force
385
+ ```
386
+
387
+ **Developer profile (no confirmation):**
388
+ ```bash
389
+ $ cakemail --profile developer transactional-templates delete 1
390
+ ```
391
+
392
+ ### Important Notes
393
+
394
+ **⚠️ Warning: This action is destructive**
395
+
396
+ When you delete a template:
397
+ - Template is permanently removed
398
+ - API calls using this template ID will fail
399
+ - Application integrations will break
400
+ - Cannot be undone
401
+
402
+ ---
403
+
404
+ ## transactional-templates send
405
+
406
+ Send a template to a recipient.
407
+
408
+ ### Usage
409
+
410
+ ```bash
411
+ cakemail transactional-templates send [list-id] <template-id> [options]
412
+ ```
413
+
414
+ ### Arguments
415
+
416
+ - `[list-id]` - List ID (optional - auto-detects if only one list exists)
417
+ - `<template-id>` - Template ID (required)
418
+
419
+ ### Options
420
+
421
+ **Recipient (one required):**
422
+ - `-e, --email <email>` - Recipient email address
423
+ - `-c, --contact-id <id>` - Contact ID from list
424
+
425
+ **Content:**
426
+ - `-v, --variables <json>` - Variables as JSON object (optional)
427
+
428
+ ### Examples
429
+
430
+ **Send to email address:**
431
+ ```bash
432
+ $ cakemail transactional-templates send 1 \
433
+ --email user@example.com \
434
+ --variables '{"order_id":"12345","order_total":"$99.99"}'
435
+ ```
436
+
437
+ **Output:**
438
+ ```
439
+ ✓ Template sent successfully
440
+
441
+ Sent to: user@example.com
442
+ Template: Order Confirmation (1)
443
+ Variables: order_id, order_total
444
+ Email ID: abc-123-def
445
+ ```
446
+
447
+ **Send to contact:**
448
+ ```bash
449
+ $ cakemail transactional-templates send 1 \
450
+ --contact-id 456 \
451
+ --variables '{"order_id":"67890"}'
452
+ ```
453
+
454
+ **Output:**
455
+ ```
456
+ ✓ Template sent successfully
457
+
458
+ Sent to: john@example.com (Contact 456)
459
+ Template: Order Confirmation (1)
460
+ Email ID: xyz-789-ghi
461
+ ```
462
+
463
+ **No variables:**
464
+ ```bash
465
+ $ cakemail transactional-templates send 2 \
466
+ --email user@example.com
467
+ ```
468
+
469
+ **JSON output:**
470
+ ```bash
471
+ $ cakemail -f json transactional-templates send 1 \
472
+ --email user@example.com \
473
+ --variables '{"order_id":"12345"}'
474
+ ```
475
+
476
+ **Output:**
477
+ ```json
478
+ {
479
+ "email_id": "abc-123-def",
480
+ "template_id": 1,
481
+ "recipient": "user@example.com",
482
+ "status": "queued",
483
+ "sent_at": "2025-10-11T15:30:00Z"
484
+ }
485
+ ```
486
+
487
+ ### Variable Substitution
488
+
489
+ Variables passed via `--variables` replace template placeholders:
490
+
491
+ **Template subject:** `Your order #{{order_id}}`
492
+ **Variables:** `{"order_id":"12345"}`
493
+ **Result:** `Your order #12345`
494
+
495
+ **Template HTML:** `<h1>Hello {{name}}!</h1>`
496
+ **Variables:** `{"name":"John"}`
497
+ **Result:** `<h1>Hello John!</h1>`
498
+
499
+ ### Contact vs Email
500
+
501
+ **Use `--contact-id` when:**
502
+ - Recipient is in your list
503
+ - You want to use contact fields (first_name, last_name, etc.)
504
+ - You want to track history
505
+
506
+ **Use `--email` when:**
507
+ - Recipient is not in your list
508
+ - One-off transactional email
509
+ - External system integration
510
+
511
+ ---
512
+
513
+ ## transactional-templates test
514
+
515
+ Send a test email with sample variables.
516
+
517
+ ### Usage
518
+
519
+ ```bash
520
+ cakemail transactional-templates test [list-id] <template-id> [options]
521
+ ```
522
+
523
+ ### Arguments
524
+
525
+ - `[list-id]` - List ID (optional - auto-detects if only one list exists)
526
+ - `<template-id>` - Template ID (required)
527
+
528
+ ### Options
529
+
530
+ - `-e, --email <email>` - Test recipient email (required)
531
+ - `-v, --variables <json>` - Test variables as JSON (optional)
532
+
533
+ ### Examples
534
+
535
+ **Send test:**
536
+ ```bash
537
+ $ cakemail transactional-templates test 1 \
538
+ --email test@example.com \
539
+ --variables '{"order_id":"TEST-123","customer_name":"Test User"}'
540
+ ```
541
+
542
+ **Output:**
543
+ ```
544
+ ✓ Test email sent successfully
545
+
546
+ Sent to: test@example.com
547
+ Template: Order Confirmation (1)
548
+ Variables: order_id, customer_name
549
+ Status: delivered
550
+ ```
551
+
552
+ **Test without variables:**
553
+ ```bash
554
+ $ cakemail transactional-templates test 1 \
555
+ --email test@example.com
556
+ ```
557
+
558
+ **Output:**
559
+ ```
560
+ ✓ Test email sent
561
+
562
+ Note: Template variables were not replaced
563
+ Subject: Your order #{{order_id}}
564
+
565
+ Send with --variables for realistic test
566
+ ```
567
+
568
+ ### Use Cases
569
+
570
+ **Development testing:**
571
+ ```bash
572
+ # Test with realistic data
573
+ cakemail transactional-templates test 1 \
574
+ --email dev@company.com \
575
+ --variables '{"order_id":"DEV-001","total":"$99.99"}'
576
+ ```
577
+
578
+ **QA review:**
579
+ ```bash
580
+ # Test all templates before launch
581
+ cakemail transactional-templates test 1 --email qa@company.com
582
+ cakemail transactional-templates test 2 --email qa@company.com
583
+ cakemail transactional-templates test 3 --email qa@company.com
584
+ ```
585
+
586
+ ---
587
+
588
+ ## transactional-templates render
589
+
590
+ Render template HTML with variables (preview without sending).
591
+
592
+ ### Usage
593
+
594
+ ```bash
595
+ cakemail transactional-templates render [list-id] <template-id> [options]
596
+ ```
597
+
598
+ ### Arguments
599
+
600
+ - `[list-id]` - List ID (optional - auto-detects if only one list exists)
601
+ - `<template-id>` - Template ID (required)
602
+
603
+ ### Options
604
+
605
+ - `-c, --contact-id <id>` - Use contact data for personalization (optional)
606
+ - `-v, --variables <json>` - Variables for substitution (optional)
607
+
608
+ ### Examples
609
+
610
+ **Render with variables:**
611
+ ```bash
612
+ $ cakemail transactional-templates render 1 \
613
+ --variables '{"order_id":"12345","customer_name":"John Doe"}'
614
+ ```
615
+
616
+ **Output:**
617
+ ```
618
+ ✓ Template rendered successfully
619
+
620
+ Subject: Your order #12345
621
+
622
+ HTML Preview:
623
+ <html>
624
+ <h1>Thank you John Doe!</h1>
625
+ <p>Your order #12345 is confirmed.</p>
626
+ </html>
627
+
628
+ Text Preview:
629
+ Thank you John Doe!
630
+ Your order #12345 is confirmed.
631
+ ```
632
+
633
+ **Render with contact:**
634
+ ```bash
635
+ $ cakemail transactional-templates render 1 --contact-id 456
636
+ ```
637
+
638
+ **Output (uses contact fields):**
639
+ ```
640
+ ✓ Template rendered with contact data
641
+
642
+ Contact: john@example.com (456)
643
+ first_name: John
644
+ last_name: Doe
645
+
646
+ Subject: Your order #{{order_id}}
647
+
648
+ HTML: <h1>Hello John Doe!</h1>...
649
+ ```
650
+
651
+ **JSON output:**
652
+ ```bash
653
+ $ cakemail -f json transactional-templates render 1 \
654
+ --variables '{"order_id":"12345"}'
655
+ ```
656
+
657
+ **Output:**
658
+ ```json
659
+ {
660
+ "template_id": 1,
661
+ "subject": "Your order #12345",
662
+ "html": "<html><h1>Thank you!</h1>...</html>",
663
+ "text": "Thank you! Your order #12345...",
664
+ "variables_used": ["order_id"]
665
+ }
666
+ ```
667
+
668
+ ### Use Cases
669
+
670
+ **Preview before sending:**
671
+ ```bash
672
+ # Check how template looks with real data
673
+ cakemail transactional-templates render 1 \
674
+ --variables '{"order_id":"12345","total":"$99.99"}' \
675
+ > preview.html
676
+
677
+ # Open in browser
678
+ open preview.html
679
+ ```
680
+
681
+ **Debug variable issues:**
682
+ ```bash
683
+ # See which variables are replaced
684
+ cakemail transactional-templates render 1 --variables '{}'
685
+ ```
686
+
687
+ ---
688
+
689
+ ## Common Workflows
690
+
691
+ ### Workflow 1: Create and Test Template
692
+
693
+ ```bash
694
+ # 1. Create template
695
+ cakemail transactional-templates create \
696
+ --name "Order Confirmation" \
697
+ --subject "Order #{{order_id}} Confirmed" \
698
+ --html "$(cat template.html)" \
699
+ --sender-id 456
700
+
701
+ # 2. Render preview
702
+ cakemail transactional-templates render 1 \
703
+ --variables '{"order_id":"TEST-001"}'
704
+
705
+ # 3. Send test
706
+ cakemail transactional-templates test 1 \
707
+ --email test@company.com \
708
+ --variables '{"order_id":"TEST-001"}'
709
+
710
+ # 4. Send real email
711
+ cakemail transactional-templates send 1 \
712
+ --email customer@example.com \
713
+ --variables '{"order_id":"12345"}'
714
+ ```
715
+
716
+ ---
717
+
718
+ ### Workflow 2: Template Development Cycle
719
+
720
+ ```bash
721
+ # Edit template locally
722
+ vim templates/welcome.html
723
+
724
+ # Update template
725
+ cakemail transactional-templates update 2 \
726
+ --html "$(cat templates/welcome.html)"
727
+
728
+ # Preview changes
729
+ cakemail transactional-templates render 2 \
730
+ --variables '{"first_name":"Test"}'
731
+
732
+ # Test
733
+ cakemail transactional-templates test 2 \
734
+ --email dev@company.com \
735
+ --variables '{"first_name":"Developer"}'
736
+ ```
737
+
738
+ ---
739
+
740
+ ### Workflow 3: Bulk Template Setup
741
+
742
+ ```bash
743
+ #!/bin/bash
744
+ # Setup all transactional templates
745
+
746
+ # Order confirmation
747
+ cakemail transactional-templates create \
748
+ --name "Order Confirmation" \
749
+ --subject "Order #{{order_id}}" \
750
+ --html "$(cat order-confirm.html)" \
751
+ --sender-id 456
752
+
753
+ # Password reset
754
+ cakemail transactional-templates create \
755
+ --name "Password Reset" \
756
+ --subject "Reset your password" \
757
+ --html "$(cat password-reset.html)" \
758
+ --sender-id 789
759
+
760
+ # Welcome email
761
+ cakemail transactional-templates create \
762
+ --name "Welcome" \
763
+ --subject "Welcome to {{company_name}}" \
764
+ --html "$(cat welcome.html)" \
765
+ --sender-id 456
766
+ ```
767
+
768
+ ---
769
+
770
+ ## Best Practices
771
+
772
+ ### 1. Always Include Plain Text Version
773
+
774
+ ```bash
775
+ cakemail transactional-templates create \
776
+ --name "Order Confirmation" \
777
+ --html "<h1>Order Confirmed</h1>" \
778
+ --text "Order Confirmed" \ # ✅ Good
779
+ --sender-id 456
780
+ ```
781
+
782
+ ### 2. Use Descriptive Variable Names
783
+
784
+ **Good:**
785
+ - `{{first_name}}`
786
+ - `{{order_id}}`
787
+ - `{{reset_link}}`
788
+
789
+ **Avoid:**
790
+ - `{{var1}}`
791
+ - `{{x}}`
792
+ - `{{temp}}`
793
+
794
+ ### 3. Test with Realistic Data
795
+
796
+ ```bash
797
+ # Test with actual data format
798
+ cakemail transactional-templates test 1 \
799
+ --email test@example.com \
800
+ --variables '{"order_total":"$1,234.56","date":"Oct 11, 2025"}'
801
+ ```
802
+
803
+ ### 4. Version Your Templates
804
+
805
+ Maintain template versions in source control:
806
+ ```
807
+ templates/
808
+ order-confirmation-v1.html
809
+ order-confirmation-v2.html
810
+ password-reset.html
811
+ ```
812
+
813
+ ---
814
+
815
+ ## Troubleshooting
816
+
817
+ ### Variable Not Replaced
818
+
819
+ **Problem:** Template shows `{{variable_name}}` instead of value
820
+
821
+ **Solutions:**
822
+ 1. Check variable name spelling
823
+ 2. Ensure variable passed in `--variables`
824
+ 3. Use correct JSON format: `'{"key":"value"}'`
825
+
826
+ ---
827
+
828
+ ### Send Failed
829
+
830
+ **Problem:** Email not sent
831
+
832
+ **Solutions:**
833
+ 1. Verify sender is confirmed: `cakemail senders get 456`
834
+ 2. Check recipient email is valid
835
+ 3. Ensure template exists: `cakemail transactional-templates show 1`
836
+ 4. Check for API errors in output
837
+
838
+ ---
839
+
840
+ ### Template Not Found
841
+
842
+ **Problem:** `Error: Template 1 not found`
843
+
844
+ **Solutions:**
845
+ 1. List templates: `cakemail transactional-templates list`
846
+ 2. Check list ID is correct
847
+ 3. Verify template wasn't deleted
848
+
849
+ ---
850
+