@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,435 @@
1
+ # Authentication Methods
2
+
3
+ A deep dive into the two authentication methods supported by the Cakemail CLI: Access Tokens and Email/Password.
4
+
5
+ ## Overview
6
+
7
+ The Cakemail CLI supports two authentication methods:
8
+
9
+ 1. **Access Token** - API-only authentication using a long-lived token
10
+ 2. **Email & Password** - Interactive authentication using account credentials
11
+
12
+ Each method has different use cases, security characteristics, and workflows.
13
+
14
+ ---
15
+
16
+ ## Access Token Authentication
17
+
18
+ ### What is an Access Token?
19
+
20
+ An access token is a secure, long-lived credential that grants API access without requiring your email and password. Think of it as an API key specific to your account.
21
+
22
+ ### How It Works
23
+
24
+ 1. You generate a token in the Cakemail dashboard
25
+ 2. The token is stored in your environment or `.env` file
26
+ 3. The CLI uses the token to authenticate API requests
27
+ 4. No password is ever transmitted or stored locally
28
+
29
+ ### Generating an Access Token
30
+
31
+ **Step 1: Log in to Cakemail Dashboard**
32
+ - Visit [app.cakemail.com](https://app.cakemail.com)
33
+ - Log in with your email and password
34
+
35
+ **Step 2: Navigate to API Settings**
36
+ - Go to **Settings** → **API Access**
37
+ - Click **Generate New Token**
38
+
39
+ **Step 3: Copy and Store the Token**
40
+ - Copy the token immediately (you won't see it again)
41
+ - Store it securely in your `.env` file or password manager
42
+
43
+ **Step 4: Configure the CLI**
44
+
45
+ Add to your `.env` file:
46
+ ```bash
47
+ CAKEMAIL_ACCESS_TOKEN=your_token_here
48
+ ```
49
+
50
+ Or set as environment variable:
51
+ ```bash
52
+ export CAKEMAIL_ACCESS_TOKEN=your_token_here
53
+ ```
54
+
55
+ ### Using Access Tokens
56
+
57
+ **Verify Token Works:**
58
+ ```bash
59
+ cakemail account test
60
+ ```
61
+
62
+ **Make API Calls:**
63
+ ```bash
64
+ # Token is automatically used for all commands
65
+ cakemail campaigns list
66
+ cakemail contacts list 123
67
+ ```
68
+
69
+ ### Token Characteristics
70
+
71
+ | Property | Details |
72
+ |----------|---------|
73
+ | **Lifetime** | Long-lived (until revoked) |
74
+ | **Scope** | Full API access to your account |
75
+ | **Revocable** | Yes, via dashboard |
76
+ | **Visible** | Only once (at generation) |
77
+ | **Renewable** | No, must generate new token |
78
+
79
+ ### When to Use Access Tokens
80
+
81
+ **✅ Use for:**
82
+ - **CI/CD pipelines** - Automated deployments and testing
83
+ - **Production scripts** - Scheduled jobs and automation
84
+ - **Server environments** - Background processes
85
+ - **Shared team access** - Team members with API-only needs
86
+ - **Long-running processes** - Scripts that run for extended periods
87
+
88
+ **❌ Don't use for:**
89
+ - **Personal laptops** (if shared) - Use email/password for better security
90
+ - **Multiple environments** - Use separate tokens per environment
91
+ - **Temporary access** - Email/password is better for short-term use
92
+
93
+ ---
94
+
95
+ ## Email & Password Authentication
96
+
97
+ ### What is Email/Password Auth?
98
+
99
+ Traditional authentication using your Cakemail account email and password. The CLI exchanges your credentials for a session token that expires after some time.
100
+
101
+ ### How It Works
102
+
103
+ 1. You provide your email and password
104
+ 2. The CLI authenticates with the Cakemail API
105
+ 3. A session token is generated (invisible to you)
106
+ 4. The session token is used for subsequent requests
107
+ 5. Session expires after a period of inactivity
108
+
109
+ ### Setting Up Email/Password
110
+
111
+ **Option 1: Environment Variables**
112
+
113
+ ```bash
114
+ export CAKEMAIL_EMAIL=your@email.com
115
+ export CAKEMAIL_PASSWORD=your_password
116
+ ```
117
+
118
+ **Option 2: `.env` File**
119
+
120
+ ```bash
121
+ # .env
122
+ CAKEMAIL_EMAIL=your@email.com
123
+ CAKEMAIL_PASSWORD=your_password
124
+ ```
125
+
126
+ **Option 3: Interactive Prompts**
127
+
128
+ Simply run a command without credentials:
129
+ ```bash
130
+ cakemail campaigns list
131
+ ```
132
+
133
+ You'll be prompted:
134
+ ```
135
+ ? Email: your@email.com
136
+ ? Password: ********
137
+ ```
138
+
139
+ ### Using Email/Password
140
+
141
+ **Test Credentials:**
142
+ ```bash
143
+ cakemail account test
144
+ ```
145
+
146
+ **Make API Calls:**
147
+ ```bash
148
+ # Credentials are automatically used
149
+ cakemail campaigns list
150
+ cakemail contacts list 123
151
+ ```
152
+
153
+ ### Session Characteristics
154
+
155
+ | Property | Details |
156
+ |----------|---------|
157
+ | **Lifetime** | Session-based (hours) |
158
+ | **Scope** | Full account access |
159
+ | **Revocable** | Only by changing password |
160
+ | **Visible** | Password stored in `.env` or environment |
161
+ | **Renewable** | Automatic (re-authenticates as needed) |
162
+
163
+ ### When to Use Email/Password
164
+
165
+ **✅ Use for:**
166
+ - **Interactive CLI use** - Daily terminal work
167
+ - **Personal machines** - Your own laptop/desktop
168
+ - **Development** - Local development and testing
169
+ - **Short-term use** - Temporary access or one-off tasks
170
+ - **Multiple accounts** - Easier to switch between accounts
171
+
172
+ **❌ Don't use for:**
173
+ - **CI/CD pipelines** - Use access tokens instead
174
+ - **Shared servers** - Password in plaintext is risky
175
+ - **Team sharing** - Use access tokens with proper scoping
176
+ - **Public repositories** - Never commit passwords
177
+
178
+ ---
179
+
180
+ ## Comparison
181
+
182
+ ### Side-by-Side Comparison
183
+
184
+ | Feature | Access Token | Email/Password |
185
+ |---------|--------------|----------------|
186
+ | **Setup complexity** | Medium (requires dashboard) | Low (just credentials) |
187
+ | **Security** | High (revocable, API-only) | Medium (requires password) |
188
+ | **Best for automation** | ✅ Yes | ❌ No |
189
+ | **Best for interactive** | ✅ Yes | ✅ Yes |
190
+ | **Rotation** | Must regenerate | Change password |
191
+ | **Granular permissions** | ❌ No (future feature) | ❌ No |
192
+ | **Multi-factor auth** | ✅ Supported | ✅ Supported |
193
+ | **Session expiry** | Never | Hours |
194
+ | **Credential visibility** | Token only | Email + password |
195
+
196
+ ### Security Comparison
197
+
198
+ | Aspect | Access Token | Email/Password |
199
+ |--------|--------------|----------------|
200
+ | **Compromise impact** | API access only | Full account access |
201
+ | **Revocation** | Instant (via dashboard) | Change password |
202
+ | **Credential exposure** | Token only | Email + password |
203
+ | **Audit trail** | Token-specific logs | General account logs |
204
+ | **Recommended for production** | ✅ Yes | ⚠️ With caution |
205
+
206
+ ---
207
+
208
+ ## Switching Authentication Methods
209
+
210
+ ### From Email/Password to Access Token
211
+
212
+ **Step 1: Generate Token** (see above)
213
+
214
+ **Step 2: Update `.env` File**
215
+
216
+ Replace:
217
+ ```bash
218
+ CAKEMAIL_EMAIL=your@email.com
219
+ CAKEMAIL_PASSWORD=your_password
220
+ ```
221
+
222
+ With:
223
+ ```bash
224
+ CAKEMAIL_ACCESS_TOKEN=your_token_here
225
+ ```
226
+
227
+ **Step 3: Test**
228
+ ```bash
229
+ cakemail account test
230
+ ```
231
+
232
+ ### From Access Token to Email/Password
233
+
234
+ **Step 1: Update `.env` File**
235
+
236
+ Replace:
237
+ ```bash
238
+ CAKEMAIL_ACCESS_TOKEN=your_token_here
239
+ ```
240
+
241
+ With:
242
+ ```bash
243
+ CAKEMAIL_EMAIL=your@email.com
244
+ CAKEMAIL_PASSWORD=your_password
245
+ ```
246
+
247
+ **Step 2: Test**
248
+ ```bash
249
+ cakemail account test
250
+ ```
251
+
252
+ ---
253
+
254
+ ## Best Practices
255
+
256
+ ### 1. Use Access Tokens for Automation
257
+
258
+ **✅ Do:**
259
+ ```bash
260
+ # CI/CD .env file
261
+ CAKEMAIL_ACCESS_TOKEN=prod_token_here
262
+ ```
263
+
264
+ **❌ Don't:**
265
+ ```bash
266
+ # CI/CD .env file
267
+ CAKEMAIL_EMAIL=admin@example.com
268
+ CAKEMAIL_PASSWORD=secret123
269
+ ```
270
+
271
+ ### 2. Rotate Tokens Regularly
272
+
273
+ Generate new tokens periodically:
274
+ - Every 90 days for production
275
+ - Every 30 days for development
276
+ - Immediately if compromised
277
+
278
+ **Rotation Process:**
279
+ 1. Generate new token in dashboard
280
+ 2. Update `.env` file with new token
281
+ 3. Test that new token works
282
+ 4. Revoke old token in dashboard
283
+
284
+ ### 3. Use Different Tokens per Environment
285
+
286
+ **Development:**
287
+ ```bash
288
+ # .env.development
289
+ CAKEMAIL_ACCESS_TOKEN=dev_token_here
290
+ ```
291
+
292
+ **Production:**
293
+ ```bash
294
+ # .env.production
295
+ CAKEMAIL_ACCESS_TOKEN=prod_token_here
296
+ ```
297
+
298
+ ### 4. Never Commit Credentials
299
+
300
+ **Always add to `.gitignore`:**
301
+ ```bash
302
+ echo '.env' >> .gitignore
303
+ echo '.env.local' >> .gitignore
304
+ echo '.env.*.local' >> .gitignore
305
+ ```
306
+
307
+ **Provide a template instead:**
308
+ ```bash
309
+ # .env.example
310
+ # Choose one authentication method:
311
+
312
+ # Method 1: Access Token (recommended for automation)
313
+ # CAKEMAIL_ACCESS_TOKEN=your_token_here
314
+
315
+ # Method 2: Email/Password (recommended for interactive use)
316
+ # CAKEMAIL_EMAIL=your@email.com
317
+ # CAKEMAIL_PASSWORD=your_password
318
+ ```
319
+
320
+ ### 5. Use Secrets Managers in CI/CD
321
+
322
+ Store credentials in your CI/CD platform's secrets manager:
323
+
324
+ **GitHub Actions:**
325
+ ```yaml
326
+ env:
327
+ CAKEMAIL_ACCESS_TOKEN: ${{ secrets.CAKEMAIL_TOKEN }}
328
+ ```
329
+
330
+ **GitLab CI:**
331
+ ```yaml
332
+ variables:
333
+ CAKEMAIL_ACCESS_TOKEN: $CI_CAKEMAIL_TOKEN
334
+ ```
335
+
336
+ **CircleCI:**
337
+ ```yaml
338
+ environment:
339
+ CAKEMAIL_ACCESS_TOKEN: ${CAKEMAIL_TOKEN}
340
+ ```
341
+
342
+ ---
343
+
344
+ ## Authentication Priority
345
+
346
+ When multiple authentication methods are configured, the CLI uses this priority:
347
+
348
+ 1. **Access Token** (highest priority)
349
+ 2. **Email/Password**
350
+ 3. **Interactive Prompts** (lowest priority)
351
+
352
+ **Example:**
353
+ ```bash
354
+ # .env file
355
+ CAKEMAIL_ACCESS_TOKEN=token_here
356
+ CAKEMAIL_EMAIL=user@example.com
357
+ CAKEMAIL_PASSWORD=password_here
358
+ ```
359
+
360
+ The CLI will use the **access token** and ignore email/password.
361
+
362
+ **Override with CLI Flags:**
363
+ ```bash
364
+ # Use specific token for this command
365
+ cakemail --access-token different_token campaigns list
366
+
367
+ # Use specific email/password for this command
368
+ cakemail --email user@example.com --password pass123 campaigns list
369
+ ```
370
+
371
+ ---
372
+
373
+ ## Troubleshooting
374
+
375
+ ### "Invalid credentials" with Access Token
376
+
377
+ **Possible Causes:**
378
+ 1. Token was revoked in dashboard
379
+ 2. Token is malformed or incomplete
380
+ 3. Account was disabled
381
+
382
+ **Solutions:**
383
+ 1. Generate new token in dashboard
384
+ 2. Verify token is complete (no spaces or newlines)
385
+ 3. Check account status in dashboard
386
+
387
+ ### "Invalid credentials" with Email/Password
388
+
389
+ **Possible Causes:**
390
+ 1. Password is incorrect
391
+ 2. Account was suspended
392
+ 3. Email typo in `.env` file
393
+
394
+ **Solutions:**
395
+ 1. Reset password in Cakemail dashboard
396
+ 2. Check for typos in email address
397
+ 3. Verify account is active
398
+
399
+ ### Authentication Works but Commands Fail
400
+
401
+ **Possible Cause:** Account-level permissions issue
402
+
403
+ **Solution:**
404
+ 1. Verify account has necessary permissions
405
+ 2. Check if account is in trial/limited mode
406
+ 3. Contact Cakemail support
407
+
408
+ ### Token Expired Suddenly
409
+
410
+ **Cause:** Tokens generally don't expire, but can be revoked
411
+
412
+ **Solutions:**
413
+ 1. Check if token was revoked in dashboard
414
+ 2. Generate new token
415
+ 3. Update `.env` file
416
+
417
+ ---
418
+
419
+ ## Security Checklist
420
+
421
+ Use this checklist to ensure your authentication is secure:
422
+
423
+ - [ ] Credentials stored in `.env` file (not in code)
424
+ - [ ] `.env` file added to `.gitignore`
425
+ - [ ] Access tokens used for automation/CI/CD
426
+ - [ ] Different tokens for dev/staging/production
427
+ - [ ] Tokens rotated every 90 days (production)
428
+ - [ ] Old tokens revoked after rotation
429
+ - [ ] No credentials in shell history
430
+ - [ ] `.env` file has restricted permissions (`chmod 600 .env`)
431
+ - [ ] Team members have individual tokens (not shared)
432
+ - [ ] Secrets manager used in CI/CD
433
+
434
+ ---
435
+