@cakemail-org/cakemail-cli 1.7.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 (198) 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 +41 -37
  6. package/audit-formats.js +128 -0
  7. package/cakemail.rb +20 -0
  8. package/dist/client.js +1 -1
  9. package/dist/client.js.map +1 -1
  10. package/dist/commands/account.js +1 -1
  11. package/dist/commands/account.js.map +1 -1
  12. package/dist/commands/attributes.js +1 -1
  13. package/dist/commands/attributes.js.map +1 -1
  14. package/dist/commands/campaigns.js +1 -1
  15. package/dist/commands/campaigns.js.map +1 -1
  16. package/dist/commands/contacts.js +1 -1
  17. package/dist/commands/contacts.js.map +1 -1
  18. package/dist/commands/emails.js +1 -1
  19. package/dist/commands/emails.js.map +1 -1
  20. package/dist/commands/interests.js +1 -1
  21. package/dist/commands/interests.js.map +1 -1
  22. package/dist/commands/lists.js +1 -1
  23. package/dist/commands/lists.js.map +1 -1
  24. package/dist/commands/logs.js +1 -1
  25. package/dist/commands/logs.js.map +1 -1
  26. package/dist/commands/reports.js +1 -1
  27. package/dist/commands/reports.js.map +1 -1
  28. package/dist/commands/segments.js +1 -1
  29. package/dist/commands/segments.js.map +1 -1
  30. package/dist/commands/senders.js +1 -1
  31. package/dist/commands/senders.js.map +1 -1
  32. package/dist/commands/suppressed.js +1 -1
  33. package/dist/commands/suppressed.js.map +1 -1
  34. package/dist/commands/tags.js +1 -1
  35. package/dist/commands/tags.js.map +1 -1
  36. package/dist/commands/templates.js +1 -1
  37. package/dist/commands/templates.js.map +1 -1
  38. package/dist/commands/transactional-templates.js +1 -1
  39. package/dist/commands/transactional-templates.js.map +1 -1
  40. package/dist/commands/webhooks.js +1 -1
  41. package/dist/commands/webhooks.js.map +1 -1
  42. package/dist/utils/config.js +2 -2
  43. package/dist/utils/config.js.map +1 -1
  44. package/dist/utils/errors.js +1 -1
  45. package/dist/utils/errors.js.map +1 -1
  46. package/dist/utils/progress.d.ts.map +1 -1
  47. package/dist/utils/progress.js +32 -4
  48. package/dist/utils/progress.js.map +1 -1
  49. package/dist/utils/spinner.d.ts +17 -0
  50. package/dist/utils/spinner.d.ts.map +1 -0
  51. package/dist/utils/spinner.js +43 -0
  52. package/dist/utils/spinner.js.map +1 -0
  53. package/docs/DOCUMENTATION-STANDARD.md +1068 -0
  54. package/docs/README.md +161 -0
  55. package/docs/developer/ARCHITECTURE.md +516 -0
  56. package/docs/developer/AUTH.md +204 -0
  57. package/docs/developer/CONTRIBUTING.md +227 -0
  58. package/docs/developer/DOCUMENTATION_SUMMARY.md +346 -0
  59. package/docs/developer/PROJECT_INDEX.md +365 -0
  60. package/docs/planning/API_COVERAGE.md +1045 -0
  61. package/docs/planning/BACKLOG.md +1159 -0
  62. package/docs/planning/PROFILE_SYSTEM_TASKS.md +287 -0
  63. package/docs/planning/UX_IMPLEMENTATION_PLAN.md +691 -0
  64. package/docs/planning/archive/RELEASE_CHECKLIST_v1.3.0.md +332 -0
  65. package/docs/planning/archive/RELEASE_v1.3.0.md +428 -0
  66. package/docs/planning/archive/cakemail-cli-ux-improvements.md +438 -0
  67. package/docs/planning/cakemail-profile-system-plan.md +1121 -0
  68. package/docs/testing/AI_USER_SIMULATION_DESIGN.md +1342 -0
  69. package/docs/testing/KENOGAMI_BIDIRECTIONAL_FLOW.md +1517 -0
  70. package/docs/testing/KENOGAMI_TRUTH_RECONCILIATION_SYSTEM.md +1369 -0
  71. package/docs/user-manual/.obsidian/app.json +1 -0
  72. package/docs/user-manual/.obsidian/appearance.json +1 -0
  73. package/docs/user-manual/.obsidian/core-plugins.json +33 -0
  74. package/docs/user-manual/.obsidian/workspace.json +167 -0
  75. package/docs/user-manual/01-getting-started/01-installation.md +214 -0
  76. package/docs/user-manual/01-getting-started/02-quick-start.md +432 -0
  77. package/docs/user-manual/01-getting-started/03-authentication.md +448 -0
  78. package/docs/user-manual/01-getting-started/04-configuration.md +430 -0
  79. package/docs/user-manual/01-getting-started/05-output-formats.md +447 -0
  80. package/docs/user-manual/02-core-concepts/01-accounts.md +514 -0
  81. package/docs/user-manual/02-core-concepts/02-profile-system.md +771 -0
  82. package/docs/user-manual/02-core-concepts/03-smart-defaults.md +485 -0
  83. package/docs/user-manual/02-core-concepts/04-authentication-methods.md +435 -0
  84. package/docs/user-manual/02-core-concepts/05-pagination-filtering.md +600 -0
  85. package/docs/user-manual/02-core-concepts/06-error-handling.md +718 -0
  86. package/docs/user-manual/02-core-concepts/07-api-coverage.md +483 -0
  87. package/docs/user-manual/03-email-operations/01-senders.md +490 -0
  88. package/docs/user-manual/03-email-operations/02-templates.md +444 -0
  89. package/docs/user-manual/03-email-operations/03-transactional-emails.md +706 -0
  90. package/docs/user-manual/03-email-operations/04-email-tracking.md +407 -0
  91. package/docs/user-manual/04-campaign-management/01-campaigns-basics.md +394 -0
  92. package/docs/user-manual/04-campaign-management/02-campaign-scheduling.md +630 -0
  93. package/docs/user-manual/04-campaign-management/03-campaign-testing.md +997 -0
  94. package/docs/user-manual/04-campaign-management/04-campaign-lifecycle.md +709 -0
  95. package/docs/user-manual/04-campaign-management/05-campaign-links.md +934 -0
  96. package/docs/user-manual/05-contact-management/01-lists.md +836 -0
  97. package/docs/user-manual/05-contact-management/02-contacts.md +1035 -0
  98. package/docs/user-manual/05-contact-management/03-custom-attributes.md +788 -0
  99. package/docs/user-manual/05-contact-management/04-segments.md +1028 -0
  100. package/docs/user-manual/05-contact-management/05-contact-import-export.md +1031 -0
  101. package/docs/user-manual/06-analytics-reporting/01-campaign-analytics.md +867 -0
  102. package/docs/user-manual/06-analytics-reporting/02-account-reports.md +227 -0
  103. package/docs/user-manual/07-integrations/01-webhooks-integration.md +259 -0
  104. package/docs/user-manual/07-integrations/02-automation.md +326 -0
  105. package/docs/user-manual/08-advanced-usage/01-scripting-patterns.md +672 -0
  106. package/docs/user-manual/08-advanced-usage/02-bulk-operations.md +932 -0
  107. package/docs/user-manual/08-advanced-usage/03-ci-cd-integration.md +892 -0
  108. package/docs/user-manual/08-advanced-usage/04-performance-optimization.md +766 -0
  109. package/docs/user-manual/09-command-reference/01-config.md +776 -0
  110. package/docs/user-manual/09-command-reference/02-account.md +652 -0
  111. package/docs/user-manual/09-command-reference/03-lists.md +958 -0
  112. package/docs/user-manual/09-command-reference/04-contacts.md +1408 -0
  113. package/docs/user-manual/09-command-reference/05-attributes.md +617 -0
  114. package/docs/user-manual/09-command-reference/06-segments.md +894 -0
  115. package/docs/user-manual/09-command-reference/07-senders.md +803 -0
  116. package/docs/user-manual/09-command-reference/08-templates.md +818 -0
  117. package/docs/user-manual/09-command-reference/09-campaigns.md +1250 -0
  118. package/docs/user-manual/09-command-reference/10-emails.md +807 -0
  119. package/docs/user-manual/09-command-reference/11-reports.md +1135 -0
  120. package/docs/user-manual/09-command-reference/12-webhooks.md +773 -0
  121. package/docs/user-manual/09-command-reference/13-suppressed.md +797 -0
  122. package/docs/user-manual/09-command-reference/14-interests.md +630 -0
  123. package/docs/user-manual/09-command-reference/15-tags.md +584 -0
  124. package/docs/user-manual/09-command-reference/16-logs.md +656 -0
  125. package/docs/user-manual/09-command-reference/17-transactional-templates.md +850 -0
  126. package/docs/user-manual/10-troubleshooting/01-common-errors.md +457 -0
  127. package/docs/user-manual/10-troubleshooting/02-authentication-issues.md +558 -0
  128. package/docs/user-manual/10-troubleshooting/03-connection-problems.md +634 -0
  129. package/docs/user-manual/10-troubleshooting/04-debugging.md +725 -0
  130. package/docs/user-manual/11-appendix/04-faq.md +484 -0
  131. package/docs/user-manual/11-appendix/05-glossary.md +250 -0
  132. package/docs/user-manual/README.md +0 -0
  133. package/package.json +13 -61
  134. package/src/cli.ts +125 -0
  135. package/src/client.ts +16 -0
  136. package/src/commands/account.ts +267 -0
  137. package/src/commands/accounts.ts +78 -0
  138. package/src/commands/actions.ts +249 -0
  139. package/src/commands/attributes.ts +139 -0
  140. package/src/commands/campaign-blueprints.ts +106 -0
  141. package/src/commands/campaigns.ts +469 -0
  142. package/src/commands/config.ts +77 -0
  143. package/src/commands/contacts.ts +612 -0
  144. package/src/commands/custom-attributes.ts +127 -0
  145. package/src/commands/dkims.ts +117 -0
  146. package/src/commands/domains.ts +82 -0
  147. package/src/commands/email-apis.ts +569 -0
  148. package/src/commands/emails.ts +197 -0
  149. package/src/commands/forms.ts +283 -0
  150. package/src/commands/interests.ts +155 -0
  151. package/src/commands/links.ts +38 -0
  152. package/src/commands/lists.ts +406 -0
  153. package/src/commands/logos.ts +71 -0
  154. package/src/commands/logs.ts +386 -0
  155. package/src/commands/reports.ts +306 -0
  156. package/src/commands/segments.ts +158 -0
  157. package/src/commands/senders.ts +204 -0
  158. package/src/commands/sub-accounts.ts +271 -0
  159. package/src/commands/suppressed-emails.ts +234 -0
  160. package/src/commands/suppressed.ts +198 -0
  161. package/src/commands/system-emails.ts +85 -0
  162. package/src/commands/tags.ts +146 -0
  163. package/src/commands/tasks.ts +116 -0
  164. package/src/commands/templates.ts +189 -0
  165. package/src/commands/tokens.ts +83 -0
  166. package/src/commands/transactional-emails.ts +374 -0
  167. package/src/commands/transactional-templates.ts +385 -0
  168. package/src/commands/users.ts +506 -0
  169. package/src/commands/webhooks.ts +172 -0
  170. package/src/commands/workflow-blueprints.ts +123 -0
  171. package/src/commands/workflows.ts +265 -0
  172. package/src/types/profile.ts +93 -0
  173. package/src/utils/auth.ts +272 -0
  174. package/src/utils/config-file.ts +96 -0
  175. package/src/utils/config.ts +134 -0
  176. package/src/utils/confirm.ts +32 -0
  177. package/src/utils/defaults.ts +99 -0
  178. package/src/utils/errors.ts +116 -0
  179. package/src/utils/interactive.ts +91 -0
  180. package/src/utils/list-defaults.ts +74 -0
  181. package/src/utils/output.ts +190 -0
  182. package/src/utils/progress.ts +320 -0
  183. package/src/utils/spinner.ts +22 -0
  184. package/tests/IMPLEMENTATION_STATUS.md +258 -0
  185. package/tests/PTY_SETUP.md +118 -0
  186. package/tests/PTY_TESTING_GUIDE.md +507 -0
  187. package/tests/README.md +244 -0
  188. package/tests/fixtures/api-responses/campaigns.json +34 -0
  189. package/tests/fixtures/test-config.json +13 -0
  190. package/tests/helpers/cli-runner.ts +128 -0
  191. package/tests/helpers/mock-server.ts +301 -0
  192. package/tests/helpers/pty-runner.ts +181 -0
  193. package/tests/integration/campaigns-real-api.test.ts +196 -0
  194. package/tests/integration/setup-integration.ts +50 -0
  195. package/tests/pty/campaigns.test.ts +241 -0
  196. package/tests/setup.ts +34 -0
  197. package/tsconfig.json +15 -0
  198. package/vitest.config.ts +28 -0
@@ -0,0 +1,652 @@
1
+ # Account Commands
2
+
3
+ Manage account authentication, switch between accounts, and view account details.
4
+
5
+ ## Overview
6
+
7
+ Account commands allow you to:
8
+ - View current account information
9
+ - List all accessible accounts (including sub-accounts)
10
+ - Switch between parent and sub-accounts
11
+ - Test credential validity
12
+ - Logout and remove stored credentials
13
+
14
+ These commands are essential for multi-tenant setups where you manage multiple Cakemail accounts or sub-accounts.
15
+
16
+ ## Commands
17
+
18
+ - [account show](#account-show) - Display current account details
19
+ - [account list](#account-list) - List all accessible accounts
20
+ - [account use](#account-use) - Switch active account
21
+ - [account test](#account-test) - Validate credentials
22
+ - [account logout](#account-logout) - Remove credentials
23
+
24
+ ---
25
+
26
+ ## account show
27
+
28
+ Display detailed information about the currently active account.
29
+
30
+ ### Usage
31
+
32
+ ```bash
33
+ cakemail account show
34
+ ```
35
+
36
+ ### Examples
37
+
38
+ **Show current account:**
39
+
40
+ ```bash
41
+ $ cakemail account show
42
+ ```
43
+
44
+ **Output:**
45
+ ```
46
+ ℹ Current account context: 456
47
+ {
48
+ "id": "456",
49
+ "name": "My Company",
50
+ "email": "admin@example.com",
51
+ "plan": "professional",
52
+ "contact_limit": 10000,
53
+ "contacts_used": 6789,
54
+ "email_limit": 100000,
55
+ "emails_sent_this_month": 45678,
56
+ "created_at": "2023-01-15T10:30:00Z",
57
+ "status": "active"
58
+ }
59
+ ```
60
+
61
+ **Extract account ID:**
62
+
63
+ ```bash
64
+ $ cakemail account show -f json | jq -r '.data.id'
65
+ ```
66
+
67
+ **Output:**
68
+ ```
69
+ 456
70
+ ```
71
+
72
+ **Check account limits:**
73
+
74
+ ```bash
75
+ $ cakemail account show -f json | jq '{contacts: {limit: .data.contact_limit, used: .data.contacts_used}, emails: {limit: .data.email_limit, used: .data.emails_sent_this_month}}'
76
+ ```
77
+
78
+ **Output:**
79
+ ```json
80
+ {
81
+ "contacts": {
82
+ "limit": 10000,
83
+ "used": 6789
84
+ },
85
+ "emails": {
86
+ "limit": 100000,
87
+ "used": 45678
88
+ }
89
+ }
90
+ ```
91
+
92
+ ### Notes
93
+
94
+ - Shows account currently set in `.env` file
95
+ - Displays usage limits and current usage
96
+ - Includes account plan and status
97
+ - Use to verify which account you're operating on
98
+
99
+ ### Related Commands
100
+
101
+ - [account list](#account-list) - View all accessible accounts
102
+ - [account use](#account-use) - Switch to different account
103
+ - [reports account](/en/cli/command-reference/reports#reports-account) - Account analytics
104
+
105
+ ---
106
+
107
+ ## account list
108
+
109
+ List all accounts you have access to, including parent and sub-accounts.
110
+
111
+ ### Usage
112
+
113
+ ```bash
114
+ cakemail account list [options]
115
+ ```
116
+
117
+ ### Options
118
+
119
+ - `-r, --recursive` - Include nested sub-accounts (default: true)
120
+
121
+ ### Examples
122
+
123
+ **List all accessible accounts:**
124
+
125
+ ```bash
126
+ $ cakemail account list
127
+ ```
128
+
129
+ **Output:**
130
+ ```
131
+ Available accounts:
132
+
133
+ • My Company (ID: 456) (current)
134
+ Client A (ID: 457)
135
+ Client B (ID: 458)
136
+ Client C (ID: 459)
137
+
138
+ ℹ Total accessible accounts: 4
139
+ ```
140
+
141
+ **List only direct sub-accounts:**
142
+
143
+ ```bash
144
+ $ cakemail account list --no-recursive
145
+ ```
146
+
147
+ **Output:**
148
+ ```
149
+ Available accounts:
150
+
151
+ • My Company (ID: 456) (current)
152
+ Client A (ID: 457)
153
+ Client B (ID: 458)
154
+
155
+ ℹ Total accessible accounts: 3
156
+ ```
157
+
158
+ ### Account Hierarchy
159
+
160
+ ```
161
+ Main Account (456)
162
+ ├── Sub-Account A (457)
163
+ ├── Sub-Account B (458)
164
+ │ └── Nested Sub-Account (460) [shown with --recursive]
165
+ └── Sub-Account C (459)
166
+ ```
167
+
168
+ ### Notes
169
+
170
+ - Current account marked with `•` (green dot)
171
+ - Includes main account and all sub-accounts
172
+ - `--recursive` shows nested sub-accounts
173
+ - Account IDs used with [account use](#account-use)
174
+
175
+ ### Related Commands
176
+
177
+ - [account use](#account-use) - Switch to listed account
178
+ - [account show](#account-show) - View current account details
179
+
180
+ ---
181
+
182
+ ## account use
183
+
184
+ Switch the active account context to operate on a different account.
185
+
186
+ ### Usage
187
+
188
+ ```bash
189
+ cakemail account use <id>
190
+ ```
191
+
192
+ ### Arguments
193
+
194
+ - `id` - Account ID to switch to (required)
195
+
196
+ ### Examples
197
+
198
+ **Switch to sub-account:**
199
+
200
+ ```bash
201
+ $ cakemail account use 457
202
+ ```
203
+
204
+ **Output:**
205
+ ```
206
+ ✓ Now using: Client A (ID: 457)
207
+ ```
208
+
209
+ **Verify switch:**
210
+
211
+ ```bash
212
+ $ cakemail account show
213
+ ```
214
+
215
+ **Output:**
216
+ ```
217
+ ℹ Current account context: 457
218
+ {
219
+ "id": "457",
220
+ "name": "Client A"
221
+ }
222
+ ```
223
+
224
+ **Switch back to main account:**
225
+
226
+ ```bash
227
+ $ cakemail account use 456
228
+ ```
229
+
230
+ **Output:**
231
+ ```
232
+ ✓ Now using: My Company (ID: 456)
233
+ ```
234
+
235
+ **Switch to nested sub-account:**
236
+
237
+ ```bash
238
+ $ cakemail account use 460
239
+ ```
240
+
241
+ ### How It Works
242
+
243
+ 1. Verifies account exists and you have access
244
+ 2. Updates `CAKEMAIL_CURRENT_ACCOUNT_ID` in `.env` file
245
+ 3. All subsequent commands operate on new account context
246
+ 4. Persists across CLI sessions
247
+
248
+ ### Use Cases
249
+
250
+ **Agency managing multiple clients:**
251
+ ```bash
252
+ # Work on Client A's campaigns
253
+ $ cakemail account use 457
254
+ $ cakemail campaigns list
255
+
256
+ # Switch to Client B
257
+ $ cakemail account use 458
258
+ $ cakemail campaigns list
259
+
260
+ # Switch back to agency account
261
+ $ cakemail account use 456
262
+ ```
263
+
264
+ **Multi-brand company:**
265
+ ```bash
266
+ # Manage Brand A
267
+ $ cakemail account use 457
268
+ $ cakemail lists list
269
+
270
+ # Manage Brand B
271
+ $ cakemail account use 458
272
+ $ cakemail lists list
273
+ ```
274
+
275
+ ### Notes
276
+
277
+ - Account switch persists in `.env` file
278
+ - Must have access to target account
279
+ - All commands use switched account until changed again
280
+ - Does not affect authentication (uses same credentials)
281
+
282
+ ### Related Commands
283
+
284
+ - [account list](#account-list) - Find account IDs
285
+ - [account show](#account-show) - Verify current account
286
+
287
+ ---
288
+
289
+ ## account test
290
+
291
+ Validate that your stored credentials are working correctly.
292
+
293
+ ### Usage
294
+
295
+ ```bash
296
+ cakemail account test
297
+ ```
298
+
299
+ ### Examples
300
+
301
+ **Test credentials:**
302
+
303
+ ```bash
304
+ $ cakemail account test
305
+ ```
306
+
307
+ **Output (success):**
308
+ ```
309
+ ✓ Credentials are valid
310
+
311
+ Authenticated as: admin@example.com
312
+ Account: My Company
313
+ ```
314
+
315
+ **Output (failure):**
316
+ ```
317
+ ✗ Invalid credentials
318
+ ```
319
+
320
+ ### Use Cases
321
+
322
+ 1. **After authentication** - Verify login worked
323
+ 2. **Troubleshooting** - Check if credentials expired
324
+ 3. **Before automation** - Ensure credentials valid before running scripts
325
+ 4. **Account verification** - Confirm you're authenticated to correct account
326
+
327
+ ### Notes
328
+
329
+ - Tests credentials stored in `.env` file
330
+ - Requires `CAKEMAIL_EMAIL` and `CAKEMAIL_PASSWORD` in `.env`
331
+ - Quick way to verify authentication status
332
+ - Shows account name if credentials valid
333
+
334
+ ### Related Commands
335
+
336
+ - [account show](#account-show) - View account details
337
+ - [account logout](#account-logout) - Remove invalid credentials
338
+
339
+ ---
340
+
341
+ ## account logout
342
+
343
+ Remove stored credentials from `.env` file (logout).
344
+
345
+ ### Usage
346
+
347
+ ```bash
348
+ cakemail account logout [options]
349
+ ```
350
+
351
+ ### Options
352
+
353
+ - `-f, --force` - Skip confirmation prompt (use in scripts)
354
+
355
+ ### Examples
356
+
357
+ **Logout with confirmation:**
358
+
359
+ ```bash
360
+ $ cakemail account logout
361
+ ```
362
+
363
+ **Output:**
364
+ ```
365
+ ⚠ Log out and remove credentials?
366
+
367
+ The following will happen:
368
+ • Credentials will be removed from .env file
369
+ • You will need to re-authenticate
370
+
371
+ Type 'yes' to confirm: yes
372
+
373
+ ✓ Logged out successfully
374
+ ℹ Credentials removed from .env file
375
+ ```
376
+
377
+ **Force logout without confirmation:**
378
+
379
+ ```bash
380
+ $ cakemail account logout --force
381
+ ```
382
+
383
+ **Output:**
384
+ ```
385
+ ✓ Logged out successfully
386
+ ℹ Credentials removed from .env file
387
+ ```
388
+
389
+ ### What Gets Removed
390
+
391
+ The following environment variables are deleted from `.env`:
392
+ - `CAKEMAIL_EMAIL`
393
+ - `CAKEMAIL_PASSWORD`
394
+ - `CAKEMAIL_ACCESS_TOKEN`
395
+ - `CAKEMAIL_CURRENT_ACCOUNT_ID`
396
+
397
+ ### Use Cases
398
+
399
+ 1. **Security** - Remove credentials when done
400
+ 2. **Switch users** - Logout before different user authenticates
401
+ 3. **Credential rotation** - Logout before updating credentials
402
+ 4. **Shared machines** - Logout on shared/public computers
403
+
404
+ ### Notes
405
+
406
+ - Credentials removed from `.env` file only
407
+ - Does not affect Cakemail account itself
408
+ - Need to re-authenticate for future commands
409
+ - Confirmation required unless `--force` is used
410
+
411
+ ### Related Commands
412
+
413
+ - [config init](/en/cli/command-reference/config#config-init) - Re-authenticate after logout
414
+ - [account test](#account-test) - Test credentials before logout
415
+
416
+ ---
417
+
418
+ ## Common Workflows
419
+
420
+ ### Workflow 1: Agency Multi-Client Management
421
+
422
+ ```bash
423
+ # List all client accounts
424
+ $ cakemail account list
425
+
426
+ # Work on Client A
427
+ $ cakemail account use 457
428
+ $ cakemail campaigns list
429
+ $ cakemail campaigns create -n "Client A Newsletter" -l 123 -s 101
430
+
431
+ # Switch to Client B
432
+ $ cakemail account use 458
433
+ $ cakemail campaigns list
434
+ $ cakemail campaigns create -n "Client B Promo" -l 124 -s 102
435
+
436
+ # Return to agency account for reporting
437
+ $ cakemail account use 456
438
+ $ cakemail reports account
439
+ ```
440
+
441
+ ### Workflow 2: Credential Verification
442
+
443
+ ```bash
444
+ # Test credentials
445
+ $ cakemail account test
446
+
447
+ # View account details
448
+ $ cakemail account show
449
+
450
+ # Check access to sub-accounts
451
+ $ cakemail account list
452
+
453
+ # Try switching accounts
454
+ $ cakemail account use 457
455
+ $ cakemail account show
456
+ ```
457
+
458
+ ### Workflow 3: Account Switching Script
459
+
460
+ ```bash
461
+ #!/bin/bash
462
+ # Script to run reports across all accounts
463
+
464
+ ACCOUNTS=(456 457 458 459)
465
+
466
+ for account_id in "${ACCOUNTS[@]}"; do
467
+ echo "Switching to account $account_id..."
468
+ cakemail account use $account_id
469
+
470
+ echo "Generating report..."
471
+ cakemail reports account > "report-$account_id.json"
472
+
473
+ echo "Report saved for account $account_id"
474
+ done
475
+
476
+ # Switch back to main account
477
+ cakemail account use 456
478
+ ```
479
+
480
+ ### Workflow 4: Secure Logout
481
+
482
+ ```bash
483
+ # Check current account
484
+ $ cakemail account show
485
+
486
+ # Verify credentials before logout
487
+ $ cakemail account test
488
+
489
+ # Logout
490
+ $ cakemail account logout
491
+
492
+ # Verify logout
493
+ $ cakemail account test
494
+ # Output: No credentials found in .env file
495
+
496
+ # Re-authenticate when needed
497
+ $ cakemail config init
498
+ ```
499
+
500
+ ### Workflow 5: Account Audit
501
+
502
+ ```bash
503
+ # List all accounts
504
+ $ cakemail account list
505
+
506
+ # Check main account details
507
+ $ cakemail account show
508
+
509
+ # Iterate through sub-accounts
510
+ for id in 457 458 459; do
511
+ echo "Checking account $id..."
512
+ cakemail account use $id
513
+ cakemail account show -f json | jq '{id, name, contacts_used, emails_sent_this_month}'
514
+ done
515
+
516
+ # Return to main account
517
+ $ cakemail account use 456
518
+ ```
519
+
520
+ ## Best Practices
521
+
522
+ 1. **Verify Context**: Always check current account before operations
523
+ 2. **Document IDs**: Keep list of account IDs and their purposes
524
+ 3. **Script Safely**: Use `account use` in scripts to ensure correct context
525
+ 4. **Logout When Done**: Remove credentials on shared/public machines
526
+ 5. **Test Regularly**: Verify credentials work before automation runs
527
+ 6. **Use Account Names**: Name sub-accounts clearly for easy identification
528
+ 7. **Monitor Usage**: Regular check account limits and usage
529
+ 8. **Audit Access**: Periodically review which accounts you have access to
530
+
531
+ ## Troubleshooting
532
+
533
+ ### Error: "No credentials found in .env file"
534
+
535
+ Credentials not configured.
536
+
537
+ **Solution:**
538
+ ```bash
539
+ # Initialize CLI and authenticate
540
+ $ cakemail config init
541
+
542
+ # Or set credentials manually in .env
543
+ CAKEMAIL_EMAIL=your@email.com
544
+ CAKEMAIL_PASSWORD=yourpassword
545
+
546
+ # Test credentials
547
+ $ cakemail account test
548
+ ```
549
+
550
+ ### Error: "Account not found or not accessible"
551
+
552
+ Trying to switch to account you don't have access to.
553
+
554
+ **Solution:**
555
+ ```bash
556
+ # List accessible accounts
557
+ $ cakemail account list
558
+
559
+ # Use valid account ID from list
560
+ $ cakemail account use 457
561
+ ```
562
+
563
+ ### Error: "Invalid credentials"
564
+
565
+ Credentials expired or incorrect.
566
+
567
+ **Solution:**
568
+ ```bash
569
+ # Logout
570
+ $ cakemail account logout --force
571
+
572
+ # Re-authenticate
573
+ $ cakemail config init
574
+
575
+ # Test new credentials
576
+ $ cakemail account test
577
+ ```
578
+
579
+ ### Commands Operating on Wrong Account
580
+
581
+ Forgot to switch account context.
582
+
583
+ **Solution:**
584
+ ```bash
585
+ # Check current account
586
+ $ cakemail account show
587
+
588
+ # Switch to correct account
589
+ $ cakemail account use 458
590
+
591
+ # Verify switch
592
+ $ cakemail account show
593
+
594
+ # Run commands
595
+ $ cakemail campaigns list
596
+ ```
597
+
598
+ ### Cannot Switch Accounts
599
+
600
+ May not have multi-account access.
601
+
602
+ **Solution:**
603
+ ```bash
604
+ # List accounts to verify
605
+ $ cakemail account list
606
+
607
+ # If only one account shown:
608
+ # - You may not have sub-accounts
609
+ # - Contact Cakemail support for multi-account access
610
+ # - Verify you're using correct credentials
611
+ ```
612
+
613
+ ### .env File Not Updating
614
+
615
+ File permissions or path issues.
616
+
617
+ **Solution:**
618
+ ```bash
619
+ # Check .env file exists
620
+ $ ls -la .env
621
+
622
+ # Verify write permissions
623
+ $ chmod 644 .env
624
+
625
+ # Try manual edit if needed
626
+ $ vi .env
627
+ # Add: CAKEMAIL_CURRENT_ACCOUNT_ID=457
628
+
629
+ # Test account switch
630
+ $ cakemail account show
631
+ ```
632
+
633
+ ### Sub-Accounts Not Showing
634
+
635
+ Recursive flag may be needed.
636
+
637
+ **Solution:**
638
+ ```bash
639
+ # List with recursive flag (default)
640
+ $ cakemail account list -r
641
+
642
+ # Check if you have sub-account access
643
+ # Contact Cakemail support if needed
644
+ ```
645
+
646
+ ---
647
+
648
+ **Related Documentation:**
649
+ - [Config Commands](/en/cli/command-reference/config/) - CLI configuration and initialization
650
+ - [Reports Commands](/en/cli/command-reference/reports/) - Account analytics
651
+ - [Lists Commands](/en/cli/command-reference/lists/) - Manage lists across accounts
652
+ - [Campaigns Commands](/en/cli/command-reference/campaigns/) - Create campaigns in specific accounts