@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.
- package/.claude/settings.local.json +12 -0
- package/.env.example +40 -0
- package/.env.test.example +45 -0
- package/CHANGELOG.md +1031 -0
- package/README.md +319 -15
- package/audit-formats.js +128 -0
- package/cakemail.rb +20 -0
- package/dist/cli.js +27 -10
- package/dist/cli.js.map +1 -1
- package/dist/client.d.ts +2 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +16 -6
- package/dist/client.js.map +1 -1
- package/dist/commands/account.js +1 -1
- package/dist/commands/account.js.map +1 -1
- package/dist/commands/attributes.js +1 -1
- package/dist/commands/attributes.js.map +1 -1
- package/dist/commands/campaigns.d.ts.map +1 -1
- package/dist/commands/campaigns.js +103 -8
- package/dist/commands/campaigns.js.map +1 -1
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +63 -4
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/contacts.d.ts.map +1 -1
- package/dist/commands/contacts.js +91 -12
- package/dist/commands/contacts.js.map +1 -1
- package/dist/commands/emails.js +1 -1
- package/dist/commands/emails.js.map +1 -1
- package/dist/commands/interests.d.ts +5 -0
- package/dist/commands/interests.d.ts.map +1 -0
- package/dist/commands/interests.js +172 -0
- package/dist/commands/interests.js.map +1 -0
- package/dist/commands/lists.d.ts.map +1 -1
- package/dist/commands/lists.js +6 -8
- package/dist/commands/lists.js.map +1 -1
- package/dist/commands/logs.d.ts +5 -0
- package/dist/commands/logs.d.ts.map +1 -0
- package/dist/commands/logs.js +237 -0
- package/dist/commands/logs.js.map +1 -0
- package/dist/commands/reports.js +1 -1
- package/dist/commands/reports.js.map +1 -1
- package/dist/commands/segments.js +1 -1
- package/dist/commands/segments.js.map +1 -1
- package/dist/commands/senders.d.ts.map +1 -1
- package/dist/commands/senders.js +11 -8
- package/dist/commands/senders.js.map +1 -1
- package/dist/commands/suppressed.js +1 -1
- package/dist/commands/suppressed.js.map +1 -1
- package/dist/commands/tags.d.ts +5 -0
- package/dist/commands/tags.d.ts.map +1 -0
- package/dist/commands/tags.js +124 -0
- package/dist/commands/tags.js.map +1 -0
- package/dist/commands/templates.js +1 -1
- package/dist/commands/templates.js.map +1 -1
- package/dist/commands/transactional-templates.d.ts +5 -0
- package/dist/commands/transactional-templates.d.ts.map +1 -0
- package/dist/commands/transactional-templates.js +354 -0
- package/dist/commands/transactional-templates.js.map +1 -0
- package/dist/commands/webhooks.js +1 -1
- package/dist/commands/webhooks.js.map +1 -1
- package/dist/utils/auth.d.ts +8 -1
- package/dist/utils/auth.d.ts.map +1 -1
- package/dist/utils/auth.js +39 -11
- package/dist/utils/auth.js.map +1 -1
- package/dist/utils/config-file.d.ts +7 -0
- package/dist/utils/config-file.d.ts.map +1 -1
- package/dist/utils/config-file.js +15 -0
- package/dist/utils/config-file.js.map +1 -1
- package/dist/utils/config.d.ts +2 -0
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +12 -4
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/errors.js +1 -1
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/list-defaults.d.ts +33 -0
- package/dist/utils/list-defaults.d.ts.map +1 -0
- package/dist/utils/list-defaults.js +52 -0
- package/dist/utils/list-defaults.js.map +1 -0
- package/dist/utils/output.d.ts.map +1 -1
- package/dist/utils/output.js +36 -13
- package/dist/utils/output.js.map +1 -1
- package/dist/utils/progress.d.ts.map +1 -1
- package/dist/utils/progress.js +32 -4
- package/dist/utils/progress.js.map +1 -1
- package/dist/utils/spinner.d.ts +17 -0
- package/dist/utils/spinner.d.ts.map +1 -0
- package/dist/utils/spinner.js +43 -0
- package/dist/utils/spinner.js.map +1 -0
- package/docs/DOCUMENTATION-STANDARD.md +1068 -0
- package/docs/README.md +161 -0
- package/docs/developer/ARCHITECTURE.md +516 -0
- package/docs/developer/AUTH.md +204 -0
- package/docs/developer/CONTRIBUTING.md +227 -0
- package/docs/developer/DOCUMENTATION_SUMMARY.md +346 -0
- package/docs/developer/PROJECT_INDEX.md +365 -0
- package/docs/planning/API_COVERAGE.md +1045 -0
- package/docs/planning/BACKLOG.md +1159 -0
- package/docs/planning/PROFILE_SYSTEM_TASKS.md +287 -0
- package/docs/planning/UX_IMPLEMENTATION_PLAN.md +691 -0
- package/docs/planning/archive/RELEASE_CHECKLIST_v1.3.0.md +332 -0
- package/docs/planning/archive/RELEASE_v1.3.0.md +428 -0
- package/docs/planning/archive/cakemail-cli-ux-improvements.md +438 -0
- package/docs/planning/cakemail-profile-system-plan.md +1121 -0
- package/docs/testing/AI_USER_SIMULATION_DESIGN.md +1342 -0
- package/docs/testing/KENOGAMI_BIDIRECTIONAL_FLOW.md +1517 -0
- package/docs/testing/KENOGAMI_TRUTH_RECONCILIATION_SYSTEM.md +1369 -0
- package/docs/user-manual/.obsidian/app.json +1 -0
- package/docs/user-manual/.obsidian/appearance.json +1 -0
- package/docs/user-manual/.obsidian/core-plugins.json +33 -0
- package/docs/user-manual/.obsidian/workspace.json +167 -0
- package/docs/user-manual/01-getting-started/01-installation.md +214 -0
- package/docs/user-manual/01-getting-started/02-quick-start.md +432 -0
- package/docs/user-manual/01-getting-started/03-authentication.md +448 -0
- package/docs/user-manual/01-getting-started/04-configuration.md +430 -0
- package/docs/user-manual/01-getting-started/05-output-formats.md +447 -0
- package/docs/user-manual/02-core-concepts/01-accounts.md +514 -0
- package/docs/user-manual/02-core-concepts/02-profile-system.md +771 -0
- package/docs/user-manual/02-core-concepts/03-smart-defaults.md +485 -0
- package/docs/user-manual/02-core-concepts/04-authentication-methods.md +435 -0
- package/docs/user-manual/02-core-concepts/05-pagination-filtering.md +600 -0
- package/docs/user-manual/02-core-concepts/06-error-handling.md +718 -0
- package/docs/user-manual/02-core-concepts/07-api-coverage.md +483 -0
- package/docs/user-manual/03-email-operations/01-senders.md +490 -0
- package/docs/user-manual/03-email-operations/02-templates.md +444 -0
- package/docs/user-manual/03-email-operations/03-transactional-emails.md +706 -0
- package/docs/user-manual/03-email-operations/04-email-tracking.md +407 -0
- package/docs/user-manual/04-campaign-management/01-campaigns-basics.md +394 -0
- package/docs/user-manual/04-campaign-management/02-campaign-scheduling.md +630 -0
- package/docs/user-manual/04-campaign-management/03-campaign-testing.md +997 -0
- package/docs/user-manual/04-campaign-management/04-campaign-lifecycle.md +709 -0
- package/docs/user-manual/04-campaign-management/05-campaign-links.md +934 -0
- package/docs/user-manual/05-contact-management/01-lists.md +836 -0
- package/docs/user-manual/05-contact-management/02-contacts.md +1035 -0
- package/docs/user-manual/05-contact-management/03-custom-attributes.md +788 -0
- package/docs/user-manual/05-contact-management/04-segments.md +1028 -0
- package/docs/user-manual/05-contact-management/05-contact-import-export.md +1031 -0
- package/docs/user-manual/06-analytics-reporting/01-campaign-analytics.md +867 -0
- package/docs/user-manual/06-analytics-reporting/02-account-reports.md +227 -0
- package/docs/user-manual/07-integrations/01-webhooks-integration.md +259 -0
- package/docs/user-manual/07-integrations/02-automation.md +326 -0
- package/docs/user-manual/08-advanced-usage/01-scripting-patterns.md +672 -0
- package/docs/user-manual/08-advanced-usage/02-bulk-operations.md +932 -0
- package/docs/user-manual/08-advanced-usage/03-ci-cd-integration.md +892 -0
- package/docs/user-manual/08-advanced-usage/04-performance-optimization.md +766 -0
- package/docs/user-manual/09-command-reference/01-config.md +776 -0
- package/docs/user-manual/09-command-reference/02-account.md +652 -0
- package/docs/user-manual/09-command-reference/03-lists.md +958 -0
- package/docs/user-manual/09-command-reference/04-contacts.md +1408 -0
- package/docs/user-manual/09-command-reference/05-attributes.md +617 -0
- package/docs/user-manual/09-command-reference/06-segments.md +894 -0
- package/docs/user-manual/09-command-reference/07-senders.md +803 -0
- package/docs/user-manual/09-command-reference/08-templates.md +818 -0
- package/docs/user-manual/09-command-reference/09-campaigns.md +1250 -0
- package/docs/user-manual/09-command-reference/10-emails.md +807 -0
- package/docs/user-manual/09-command-reference/11-reports.md +1135 -0
- package/docs/user-manual/09-command-reference/12-webhooks.md +773 -0
- package/docs/user-manual/09-command-reference/13-suppressed.md +797 -0
- package/docs/user-manual/09-command-reference/14-interests.md +630 -0
- package/docs/user-manual/09-command-reference/15-tags.md +584 -0
- package/docs/user-manual/09-command-reference/16-logs.md +656 -0
- package/docs/user-manual/09-command-reference/17-transactional-templates.md +850 -0
- package/docs/user-manual/10-troubleshooting/01-common-errors.md +457 -0
- package/docs/user-manual/10-troubleshooting/02-authentication-issues.md +558 -0
- package/docs/user-manual/10-troubleshooting/03-connection-problems.md +634 -0
- package/docs/user-manual/10-troubleshooting/04-debugging.md +725 -0
- package/docs/user-manual/11-appendix/04-faq.md +484 -0
- package/docs/user-manual/11-appendix/05-glossary.md +250 -0
- package/docs/user-manual/README.md +0 -0
- package/package.json +13 -47
- package/src/cli.ts +125 -0
- package/src/client.ts +16 -0
- package/src/commands/account.ts +267 -0
- package/src/commands/accounts.ts +78 -0
- package/src/commands/actions.ts +249 -0
- package/src/commands/attributes.ts +139 -0
- package/src/commands/campaign-blueprints.ts +106 -0
- package/src/commands/campaigns.ts +469 -0
- package/src/commands/config.ts +77 -0
- package/src/commands/contacts.ts +612 -0
- package/src/commands/custom-attributes.ts +127 -0
- package/src/commands/dkims.ts +117 -0
- package/src/commands/domains.ts +82 -0
- package/src/commands/email-apis.ts +569 -0
- package/src/commands/emails.ts +197 -0
- package/src/commands/forms.ts +283 -0
- package/src/commands/interests.ts +155 -0
- package/src/commands/links.ts +38 -0
- package/src/commands/lists.ts +406 -0
- package/src/commands/logos.ts +71 -0
- package/src/commands/logs.ts +386 -0
- package/src/commands/reports.ts +306 -0
- package/src/commands/segments.ts +158 -0
- package/src/commands/senders.ts +204 -0
- package/src/commands/sub-accounts.ts +271 -0
- package/src/commands/suppressed-emails.ts +234 -0
- package/src/commands/suppressed.ts +198 -0
- package/src/commands/system-emails.ts +85 -0
- package/src/commands/tags.ts +146 -0
- package/src/commands/tasks.ts +116 -0
- package/src/commands/templates.ts +189 -0
- package/src/commands/tokens.ts +83 -0
- package/src/commands/transactional-emails.ts +374 -0
- package/src/commands/transactional-templates.ts +385 -0
- package/src/commands/users.ts +506 -0
- package/src/commands/webhooks.ts +172 -0
- package/src/commands/workflow-blueprints.ts +123 -0
- package/src/commands/workflows.ts +265 -0
- package/src/types/profile.ts +93 -0
- package/src/utils/auth.ts +272 -0
- package/src/utils/config-file.ts +96 -0
- package/src/utils/config.ts +134 -0
- package/src/utils/confirm.ts +32 -0
- package/src/utils/defaults.ts +99 -0
- package/src/utils/errors.ts +116 -0
- package/src/utils/interactive.ts +91 -0
- package/src/utils/list-defaults.ts +74 -0
- package/src/utils/output.ts +190 -0
- package/src/utils/progress.ts +320 -0
- package/src/utils/spinner.ts +22 -0
- package/tests/IMPLEMENTATION_STATUS.md +258 -0
- package/tests/PTY_SETUP.md +118 -0
- package/tests/PTY_TESTING_GUIDE.md +507 -0
- package/tests/README.md +244 -0
- package/tests/fixtures/api-responses/campaigns.json +34 -0
- package/tests/fixtures/test-config.json +13 -0
- package/tests/helpers/cli-runner.ts +128 -0
- package/tests/helpers/mock-server.ts +301 -0
- package/tests/helpers/pty-runner.ts +181 -0
- package/tests/integration/campaigns-real-api.test.ts +196 -0
- package/tests/integration/setup-integration.ts +50 -0
- package/tests/pty/campaigns.test.ts +241 -0
- package/tests/setup.ts +34 -0
- package/tsconfig.json +15 -0
- package/vitest.config.ts +28 -0
|
@@ -0,0 +1,773 @@
|
|
|
1
|
+
# Webhook Commands
|
|
2
|
+
|
|
3
|
+
Manage webhooks for real-time event notifications from Cakemail.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Webhook commands allow you to:
|
|
8
|
+
- Create webhooks to receive event notifications
|
|
9
|
+
- Subscribe to specific email events
|
|
10
|
+
- Update webhook URLs and event subscriptions
|
|
11
|
+
- Archive/unarchive webhooks
|
|
12
|
+
- Secure webhooks with secret keys
|
|
13
|
+
- Integrate Cakemail with external systems
|
|
14
|
+
|
|
15
|
+
Webhooks provide real-time HTTP callbacks when events occur (email sent, opened, clicked, bounced, etc.), enabling you to build integrations and automate workflows.
|
|
16
|
+
|
|
17
|
+
## Commands
|
|
18
|
+
|
|
19
|
+
- [webhooks list](#webhooks-list) - List all webhooks
|
|
20
|
+
- [webhooks get](#webhooks-get) - Get webhook details
|
|
21
|
+
- [webhooks create](#webhooks-create) - Create a new webhook
|
|
22
|
+
- [webhooks update](#webhooks-update) - Update webhook configuration
|
|
23
|
+
- [webhooks archive](#webhooks-archive) - Archive a webhook
|
|
24
|
+
- [webhooks unarchive](#webhooks-unarchive) - Unarchive a webhook
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## webhooks list
|
|
29
|
+
|
|
30
|
+
List all webhooks in your account.
|
|
31
|
+
|
|
32
|
+
### Usage
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
cakemail webhooks list [options]
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Options
|
|
39
|
+
|
|
40
|
+
- `-l, --limit <number>` - Limit number of results per page
|
|
41
|
+
- `-p, --page <number>` - Page number (default: 1)
|
|
42
|
+
|
|
43
|
+
### Examples
|
|
44
|
+
|
|
45
|
+
**List all webhooks:**
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
$ cakemail webhooks list
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**Output:**
|
|
52
|
+
```
|
|
53
|
+
┌────────┬──────────────────────┬──────────────────────────────┬────────────┐
|
|
54
|
+
│ ID │ Name │ URL │ Status │
|
|
55
|
+
├────────┼──────────────────────┼──────────────────────────────┼────────────┤
|
|
56
|
+
│ 301 │ Email Events │ https://api.example.com/hook │ active │
|
|
57
|
+
│ 302 │ Bounce Handler │ https://app.example.com/... │ active │
|
|
58
|
+
│ 303 │ Old Integration │ https://old.example.com/... │ archived │
|
|
59
|
+
└────────┴──────────────────────┴──────────────────────────────┴────────────┘
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**List with pagination:**
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
$ cakemail webhooks list -l 10 -p 1
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**Export webhooks as JSON:**
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
$ cakemail webhooks list -f json > webhooks.json
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**Output:**
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"data": [
|
|
78
|
+
{
|
|
79
|
+
"id": 301,
|
|
80
|
+
"name": "Email Events",
|
|
81
|
+
"url": "https://api.example.com/webhook",
|
|
82
|
+
"events": ["email.sent", "email.opened", "email.clicked"],
|
|
83
|
+
"status": "active",
|
|
84
|
+
"created_at": "2024-01-15T10:30:00Z"
|
|
85
|
+
}
|
|
86
|
+
],
|
|
87
|
+
"count": 3
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Find active webhooks:**
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
$ cakemail webhooks list -f json | jq '.data[] | select(.status == "active")'
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Notes
|
|
98
|
+
|
|
99
|
+
- Active webhooks receive event notifications
|
|
100
|
+
- Archived webhooks do not receive notifications
|
|
101
|
+
- Each webhook shows subscribed events
|
|
102
|
+
- Use pagination for accounts with many webhooks
|
|
103
|
+
|
|
104
|
+
### Related Commands
|
|
105
|
+
|
|
106
|
+
- [webhooks get](#webhooks-get) - View webhook details
|
|
107
|
+
- [webhooks create](#webhooks-create) - Add new webhook
|
|
108
|
+
- [webhooks archive](#webhooks-archive) - Disable webhook
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## webhooks get
|
|
113
|
+
|
|
114
|
+
Get detailed information about a specific webhook.
|
|
115
|
+
|
|
116
|
+
### Usage
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
cakemail webhooks get <id>
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Arguments
|
|
123
|
+
|
|
124
|
+
- `id` - Webhook ID (required)
|
|
125
|
+
|
|
126
|
+
### Examples
|
|
127
|
+
|
|
128
|
+
**Get webhook details:**
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
$ cakemail webhooks get 301
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Output:**
|
|
135
|
+
```
|
|
136
|
+
{
|
|
137
|
+
"id": 301,
|
|
138
|
+
"name": "Email Events",
|
|
139
|
+
"url": "https://api.example.com/webhook",
|
|
140
|
+
"events": [
|
|
141
|
+
"email.sent",
|
|
142
|
+
"email.opened",
|
|
143
|
+
"email.clicked",
|
|
144
|
+
"email.bounced"
|
|
145
|
+
],
|
|
146
|
+
"secret": "whsec_abc123...",
|
|
147
|
+
"status": "active",
|
|
148
|
+
"created_at": "2024-01-15T10:30:00Z",
|
|
149
|
+
"updated_at": "2024-02-10T14:20:00Z",
|
|
150
|
+
"last_triggered_at": "2024-03-15T10:30:00Z"
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
**Extract webhook URL:**
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
$ cakemail webhooks get 301 -f json | jq -r '.url'
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**Output:**
|
|
161
|
+
```
|
|
162
|
+
https://api.example.com/webhook
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
**View subscribed events:**
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
$ cakemail webhooks get 301 -f json | jq '.events'
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
**Output:**
|
|
172
|
+
```json
|
|
173
|
+
["email.sent", "email.opened", "email.clicked", "email.bounced"]
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**Check webhook status:**
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
$ cakemail webhooks get 301 -f json | jq -r '.status'
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
**Output:**
|
|
183
|
+
```
|
|
184
|
+
active
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Notes
|
|
188
|
+
|
|
189
|
+
- Shows complete webhook configuration
|
|
190
|
+
- Secret displayed (store securely)
|
|
191
|
+
- Last triggered timestamp shows recent activity
|
|
192
|
+
- Status indicates if webhook is receiving events
|
|
193
|
+
|
|
194
|
+
### Related Commands
|
|
195
|
+
|
|
196
|
+
- [webhooks list](#webhooks-list) - Find webhook IDs
|
|
197
|
+
- [webhooks update](#webhooks-update) - Modify webhook
|
|
198
|
+
- [webhooks archive](#webhooks-archive) - Disable webhook
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## webhooks create
|
|
203
|
+
|
|
204
|
+
Create a new webhook to receive event notifications.
|
|
205
|
+
|
|
206
|
+
### Usage
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
cakemail webhooks create [options]
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Options
|
|
213
|
+
|
|
214
|
+
**Required:**
|
|
215
|
+
- `-u, --url <url>` - Webhook endpoint URL (must be HTTPS)
|
|
216
|
+
- `-e, --events <events>` - Comma-separated event types
|
|
217
|
+
|
|
218
|
+
**Optional:**
|
|
219
|
+
- `-n, --name <name>` - Webhook name for identification
|
|
220
|
+
- `-s, --secret <secret>` - Secret key for signature verification
|
|
221
|
+
|
|
222
|
+
### Examples
|
|
223
|
+
|
|
224
|
+
**Create webhook for email events:**
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
$ cakemail webhooks create \
|
|
228
|
+
-u "https://api.example.com/webhook" \
|
|
229
|
+
-e "email.sent,email.opened,email.clicked" \
|
|
230
|
+
-n "Email Events"
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
**Output:**
|
|
234
|
+
```
|
|
235
|
+
✓ Webhook created: 301
|
|
236
|
+
{
|
|
237
|
+
"id": 301,
|
|
238
|
+
"name": "Email Events",
|
|
239
|
+
"url": "https://api.example.com/webhook",
|
|
240
|
+
"events": ["email.sent", "email.opened", "email.clicked"],
|
|
241
|
+
"status": "active"
|
|
242
|
+
}
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
**Create webhook with secret:**
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
$ cakemail webhooks create \
|
|
249
|
+
-u "https://api.example.com/secure-webhook" \
|
|
250
|
+
-e "email.sent,email.bounced" \
|
|
251
|
+
-n "Secure Webhook" \
|
|
252
|
+
-s "my_secret_key_12345"
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
**Output:**
|
|
256
|
+
```
|
|
257
|
+
✓ Webhook created: 302
|
|
258
|
+
{
|
|
259
|
+
"id": 302,
|
|
260
|
+
"name": "Secure Webhook",
|
|
261
|
+
"url": "https://api.example.com/secure-webhook",
|
|
262
|
+
"secret": "my_secret_key_12345",
|
|
263
|
+
"events": ["email.sent", "email.bounced"]
|
|
264
|
+
}
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
**Create bounce handler webhook:**
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
$ cakemail webhooks create \
|
|
271
|
+
-u "https://app.example.com/bounces" \
|
|
272
|
+
-e "email.bounced,email.complained" \
|
|
273
|
+
-n "Bounce Handler"
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
**Create campaign webhook:**
|
|
277
|
+
|
|
278
|
+
```bash
|
|
279
|
+
$ cakemail webhooks create \
|
|
280
|
+
-u "https://analytics.example.com/campaigns" \
|
|
281
|
+
-e "campaign.sent,campaign.completed" \
|
|
282
|
+
-n "Campaign Analytics"
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### Available Events
|
|
286
|
+
|
|
287
|
+
**Email Events:**
|
|
288
|
+
- `email.sent` - Email successfully sent
|
|
289
|
+
- `email.delivered` - Email delivered to recipient
|
|
290
|
+
- `email.opened` - Email opened by recipient
|
|
291
|
+
- `email.clicked` - Link clicked in email
|
|
292
|
+
- `email.bounced` - Email bounced (hard or soft)
|
|
293
|
+
- `email.complained` - Recipient marked as spam
|
|
294
|
+
- `email.unsubscribed` - Recipient unsubscribed
|
|
295
|
+
|
|
296
|
+
**Campaign Events:**
|
|
297
|
+
- `campaign.sent` - Campaign sent
|
|
298
|
+
- `campaign.completed` - Campaign sending completed
|
|
299
|
+
|
|
300
|
+
**Contact Events:**
|
|
301
|
+
- `contact.subscribed` - Contact subscribed to list
|
|
302
|
+
- `contact.unsubscribed` - Contact unsubscribed from list
|
|
303
|
+
|
|
304
|
+
### Webhook Payload
|
|
305
|
+
|
|
306
|
+
When an event occurs, Cakemail sends HTTP POST to your URL:
|
|
307
|
+
|
|
308
|
+
```json
|
|
309
|
+
{
|
|
310
|
+
"event": "email.opened",
|
|
311
|
+
"timestamp": "2024-03-15T10:30:00Z",
|
|
312
|
+
"data": {
|
|
313
|
+
"email_id": "email_abc123",
|
|
314
|
+
"recipient": "user@example.com",
|
|
315
|
+
"campaign_id": 790,
|
|
316
|
+
"list_id": 123
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
### Notes
|
|
322
|
+
|
|
323
|
+
- URL must be HTTPS (HTTP not supported)
|
|
324
|
+
- URL must be publicly accessible
|
|
325
|
+
- Secret used to verify request authenticity (recommended)
|
|
326
|
+
- Multiple webhooks can subscribe to same events
|
|
327
|
+
- Webhooks activated immediately upon creation
|
|
328
|
+
- Failed deliveries retried with exponential backoff
|
|
329
|
+
|
|
330
|
+
### Related Commands
|
|
331
|
+
|
|
332
|
+
- [webhooks get](#webhooks-get) - View created webhook
|
|
333
|
+
- [webhooks update](#webhooks-update) - Modify configuration
|
|
334
|
+
- [webhooks list](#webhooks-list) - View all webhooks
|
|
335
|
+
|
|
336
|
+
---
|
|
337
|
+
|
|
338
|
+
## webhooks update
|
|
339
|
+
|
|
340
|
+
Update an existing webhook's configuration.
|
|
341
|
+
|
|
342
|
+
### Usage
|
|
343
|
+
|
|
344
|
+
```bash
|
|
345
|
+
cakemail webhooks update <id> [options]
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
### Arguments
|
|
349
|
+
|
|
350
|
+
- `id` - Webhook ID (required)
|
|
351
|
+
|
|
352
|
+
### Options
|
|
353
|
+
|
|
354
|
+
- `-u, --url <url>` - New webhook URL
|
|
355
|
+
- `-e, --events <events>` - New comma-separated event list (replaces existing)
|
|
356
|
+
- `-n, --name <name>` - New webhook name
|
|
357
|
+
- `-s, --secret <secret>` - New secret key
|
|
358
|
+
|
|
359
|
+
### Examples
|
|
360
|
+
|
|
361
|
+
**Update webhook URL:**
|
|
362
|
+
|
|
363
|
+
```bash
|
|
364
|
+
$ cakemail webhooks update 301 -u "https://api.example.com/new-webhook"
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
**Output:**
|
|
368
|
+
```
|
|
369
|
+
✓ Webhook 301 updated
|
|
370
|
+
{
|
|
371
|
+
"id": 301,
|
|
372
|
+
"url": "https://api.example.com/new-webhook"
|
|
373
|
+
}
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
**Update subscribed events:**
|
|
377
|
+
|
|
378
|
+
```bash
|
|
379
|
+
$ cakemail webhooks update 301 -e "email.sent,email.opened,email.clicked,email.bounced"
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
**Output:**
|
|
383
|
+
```
|
|
384
|
+
✓ Webhook 301 updated
|
|
385
|
+
{
|
|
386
|
+
"id": 301,
|
|
387
|
+
"events": ["email.sent", "email.opened", "email.clicked", "email.bounced"]
|
|
388
|
+
}
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
**Update webhook name:**
|
|
392
|
+
|
|
393
|
+
```bash
|
|
394
|
+
$ cakemail webhooks update 301 -n "Main Email Events Handler"
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
**Update secret key:**
|
|
398
|
+
|
|
399
|
+
```bash
|
|
400
|
+
$ cakemail webhooks update 301 -s "new_secret_key_67890"
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
**Update multiple fields:**
|
|
404
|
+
|
|
405
|
+
```bash
|
|
406
|
+
$ cakemail webhooks update 301 \
|
|
407
|
+
-u "https://api.example.com/webhook-v2" \
|
|
408
|
+
-e "email.sent,email.bounced" \
|
|
409
|
+
-n "Email Events v2" \
|
|
410
|
+
-s "secure_key_2024"
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
**Output:**
|
|
414
|
+
```
|
|
415
|
+
✓ Webhook 301 updated
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
### Notes
|
|
419
|
+
|
|
420
|
+
- Only provided fields are updated (partial updates)
|
|
421
|
+
- Events list is replaced entirely (not merged)
|
|
422
|
+
- Changing URL requires endpoint to be accessible
|
|
423
|
+
- New secret applies to future webhook calls
|
|
424
|
+
- Webhook ID remains the same
|
|
425
|
+
|
|
426
|
+
### Related Commands
|
|
427
|
+
|
|
428
|
+
- [webhooks get](#webhooks-get) - View current configuration
|
|
429
|
+
- [webhooks create](#webhooks-create) - Create new webhook
|
|
430
|
+
- [webhooks archive](#webhooks-archive) - Disable webhook
|
|
431
|
+
|
|
432
|
+
---
|
|
433
|
+
|
|
434
|
+
## webhooks archive
|
|
435
|
+
|
|
436
|
+
Archive a webhook to stop receiving event notifications.
|
|
437
|
+
|
|
438
|
+
### Usage
|
|
439
|
+
|
|
440
|
+
```bash
|
|
441
|
+
cakemail webhooks archive <id>
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
### Arguments
|
|
445
|
+
|
|
446
|
+
- `id` - Webhook ID (required)
|
|
447
|
+
|
|
448
|
+
### Examples
|
|
449
|
+
|
|
450
|
+
**Archive webhook:**
|
|
451
|
+
|
|
452
|
+
```bash
|
|
453
|
+
$ cakemail webhooks archive 303
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
**Output:**
|
|
457
|
+
```
|
|
458
|
+
✓ Webhook 303 archived
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
**Verify archive status:**
|
|
462
|
+
|
|
463
|
+
```bash
|
|
464
|
+
$ cakemail webhooks get 303 -f json | jq -r '.status'
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
**Output:**
|
|
468
|
+
```
|
|
469
|
+
archived
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
### Notes
|
|
473
|
+
|
|
474
|
+
- Archived webhooks stop receiving events immediately
|
|
475
|
+
- Webhook configuration is preserved
|
|
476
|
+
- Can be unarchived later
|
|
477
|
+
- Use instead of deletion to preserve configuration
|
|
478
|
+
- No events sent to archived webhooks
|
|
479
|
+
|
|
480
|
+
### Related Commands
|
|
481
|
+
|
|
482
|
+
- [webhooks unarchive](#webhooks-unarchive) - Reactivate webhook
|
|
483
|
+
- [webhooks list](#webhooks-list) - View webhook status
|
|
484
|
+
- [webhooks get](#webhooks-get) - Check archive status
|
|
485
|
+
|
|
486
|
+
---
|
|
487
|
+
|
|
488
|
+
## webhooks unarchive
|
|
489
|
+
|
|
490
|
+
Unarchive a webhook to resume receiving event notifications.
|
|
491
|
+
|
|
492
|
+
### Usage
|
|
493
|
+
|
|
494
|
+
```bash
|
|
495
|
+
cakemail webhooks unarchive <id>
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
### Arguments
|
|
499
|
+
|
|
500
|
+
- `id` - Webhook ID (required)
|
|
501
|
+
|
|
502
|
+
### Examples
|
|
503
|
+
|
|
504
|
+
**Unarchive webhook:**
|
|
505
|
+
|
|
506
|
+
```bash
|
|
507
|
+
$ cakemail webhooks unarchive 303
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
**Output:**
|
|
511
|
+
```
|
|
512
|
+
✓ Webhook 303 unarchived
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
**Verify active status:**
|
|
516
|
+
|
|
517
|
+
```bash
|
|
518
|
+
$ cakemail webhooks get 303 -f json | jq -r '.status'
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
**Output:**
|
|
522
|
+
```
|
|
523
|
+
active
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
### Notes
|
|
527
|
+
|
|
528
|
+
- Webhook resumes receiving events immediately
|
|
529
|
+
- All configuration preserved during archive
|
|
530
|
+
- Events that occurred while archived are not retroactively sent
|
|
531
|
+
- Use to temporarily pause webhook without losing configuration
|
|
532
|
+
|
|
533
|
+
### Related Commands
|
|
534
|
+
|
|
535
|
+
- [webhooks archive](#webhooks-archive) - Disable webhook
|
|
536
|
+
- [webhooks get](#webhooks-get) - Check status
|
|
537
|
+
- [webhooks update](#webhooks-update) - Modify after unarchive
|
|
538
|
+
|
|
539
|
+
---
|
|
540
|
+
|
|
541
|
+
## Common Workflows
|
|
542
|
+
|
|
543
|
+
### Workflow 1: Setup Email Event Webhook
|
|
544
|
+
|
|
545
|
+
```bash
|
|
546
|
+
# Create webhook for email tracking
|
|
547
|
+
$ cakemail webhooks create \
|
|
548
|
+
-u "https://api.example.com/email-events" \
|
|
549
|
+
-e "email.sent,email.opened,email.clicked,email.bounced" \
|
|
550
|
+
-n "Email Tracker" \
|
|
551
|
+
-s "secure_secret_key_123"
|
|
552
|
+
|
|
553
|
+
# Note webhook ID (e.g., 301)
|
|
554
|
+
|
|
555
|
+
# Verify configuration
|
|
556
|
+
$ cakemail webhooks get 301
|
|
557
|
+
|
|
558
|
+
# Test webhook endpoint (ensure it's responding)
|
|
559
|
+
# Send test campaign and monitor webhook calls
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
### Workflow 2: Update Webhook Events
|
|
563
|
+
|
|
564
|
+
```bash
|
|
565
|
+
# View current events
|
|
566
|
+
$ cakemail webhooks get 301 -f json | jq '.events'
|
|
567
|
+
|
|
568
|
+
# Add more events
|
|
569
|
+
$ cakemail webhooks update 301 \
|
|
570
|
+
-e "email.sent,email.opened,email.clicked,email.bounced,email.complained,email.unsubscribed"
|
|
571
|
+
|
|
572
|
+
# Verify update
|
|
573
|
+
$ cakemail webhooks get 301 -f json | jq '.events'
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
### Workflow 3: Rotate Webhook Secret
|
|
577
|
+
|
|
578
|
+
```bash
|
|
579
|
+
# Update secret key
|
|
580
|
+
$ cakemail webhooks update 301 -s "new_secure_key_456"
|
|
581
|
+
|
|
582
|
+
# Update application with new secret
|
|
583
|
+
# Deploy application changes
|
|
584
|
+
|
|
585
|
+
# Verify webhook still working
|
|
586
|
+
# Monitor webhook calls
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
### Workflow 4: Temporarily Disable Webhook
|
|
590
|
+
|
|
591
|
+
```bash
|
|
592
|
+
# Archive webhook (e.g., during maintenance)
|
|
593
|
+
$ cakemail webhooks archive 301
|
|
594
|
+
|
|
595
|
+
# Perform maintenance...
|
|
596
|
+
|
|
597
|
+
# Reactivate webhook
|
|
598
|
+
$ cakemail webhooks unarchive 301
|
|
599
|
+
|
|
600
|
+
# Verify active
|
|
601
|
+
$ cakemail webhooks get 301 -f json | jq '.status'
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
### Workflow 5: Webhook Audit
|
|
605
|
+
|
|
606
|
+
```bash
|
|
607
|
+
# List all webhooks
|
|
608
|
+
$ cakemail webhooks list
|
|
609
|
+
|
|
610
|
+
# Check each webhook status
|
|
611
|
+
for id in 301 302 303; do
|
|
612
|
+
echo "Webhook $id:"
|
|
613
|
+
cakemail webhooks get $id -f json | jq '{name, url, status, last_triggered: .last_triggered_at}'
|
|
614
|
+
done
|
|
615
|
+
|
|
616
|
+
# Archive unused webhooks
|
|
617
|
+
$ cakemail webhooks archive 303
|
|
618
|
+
```
|
|
619
|
+
|
|
620
|
+
## Best Practices
|
|
621
|
+
|
|
622
|
+
1. **Use HTTPS**: Always use HTTPS endpoints (required)
|
|
623
|
+
2. **Verify Signatures**: Use webhook secret to verify request authenticity
|
|
624
|
+
3. **Idempotency**: Handle duplicate webhook calls (use event IDs)
|
|
625
|
+
4. **Fast Response**: Respond quickly (< 5 seconds) to prevent timeouts
|
|
626
|
+
5. **Background Processing**: Queue webhook data for async processing
|
|
627
|
+
6. **Error Handling**: Return 200 OK even if processing fails
|
|
628
|
+
7. **Retry Logic**: Implement exponential backoff for failed processes
|
|
629
|
+
8. **Monitor Failures**: Track webhook delivery failures
|
|
630
|
+
9. **Secret Rotation**: Regularly rotate webhook secrets
|
|
631
|
+
10. **Test Endpoints**: Test webhook URLs before creating
|
|
632
|
+
|
|
633
|
+
## Troubleshooting
|
|
634
|
+
|
|
635
|
+
### Error: "Webhook URL is invalid"
|
|
636
|
+
|
|
637
|
+
URL format validation failed.
|
|
638
|
+
|
|
639
|
+
**Solution:**
|
|
640
|
+
```bash
|
|
641
|
+
# Ensure HTTPS (not HTTP)
|
|
642
|
+
$ cakemail webhooks create \
|
|
643
|
+
-u "https://api.example.com/webhook" \
|
|
644
|
+
-e "email.sent" \
|
|
645
|
+
-n "Test"
|
|
646
|
+
|
|
647
|
+
# Not valid: http://api.example.com/webhook (HTTP)
|
|
648
|
+
# Not valid: api.example.com/webhook (missing protocol)
|
|
649
|
+
```
|
|
650
|
+
|
|
651
|
+
### Webhook Not Receiving Events
|
|
652
|
+
|
|
653
|
+
Multiple possible causes.
|
|
654
|
+
|
|
655
|
+
**Solution:**
|
|
656
|
+
```bash
|
|
657
|
+
# Check webhook status
|
|
658
|
+
$ cakemail webhooks get 301 -f json | jq '.status'
|
|
659
|
+
|
|
660
|
+
# If archived, unarchive
|
|
661
|
+
$ cakemail webhooks unarchive 301
|
|
662
|
+
|
|
663
|
+
# Verify URL is accessible
|
|
664
|
+
$ curl -X POST https://api.example.com/webhook -d '{"test": true}'
|
|
665
|
+
|
|
666
|
+
# Check webhook logs in your application
|
|
667
|
+
# Verify firewall allows Cakemail IPs
|
|
668
|
+
# Check events are actually occurring (send test email)
|
|
669
|
+
```
|
|
670
|
+
|
|
671
|
+
### Webhook Requests Failing
|
|
672
|
+
|
|
673
|
+
Endpoint returning errors.
|
|
674
|
+
|
|
675
|
+
**Solution:**
|
|
676
|
+
```bash
|
|
677
|
+
# Check your endpoint logs
|
|
678
|
+
# Common issues:
|
|
679
|
+
# - Authentication failures
|
|
680
|
+
# - Timeout (must respond < 5 seconds)
|
|
681
|
+
# - Invalid response format
|
|
682
|
+
|
|
683
|
+
# Test endpoint manually
|
|
684
|
+
$ curl -X POST https://api.example.com/webhook \
|
|
685
|
+
-H "Content-Type: application/json" \
|
|
686
|
+
-d '{"event":"email.sent","data":{}}'
|
|
687
|
+
|
|
688
|
+
# Ensure endpoint returns 200 OK
|
|
689
|
+
```
|
|
690
|
+
|
|
691
|
+
### Duplicate Webhook Events
|
|
692
|
+
|
|
693
|
+
Same event received multiple times.
|
|
694
|
+
|
|
695
|
+
**Solution:**
|
|
696
|
+
```bash
|
|
697
|
+
# Implement idempotency using event IDs
|
|
698
|
+
# Example webhook handler:
|
|
699
|
+
|
|
700
|
+
# Store processed event IDs
|
|
701
|
+
# if event_id in processed_ids:
|
|
702
|
+
# return 200 # Already processed
|
|
703
|
+
#
|
|
704
|
+
# process_event(event)
|
|
705
|
+
# store_event_id(event_id)
|
|
706
|
+
# return 200
|
|
707
|
+
|
|
708
|
+
# Cakemail retries failed webhooks
|
|
709
|
+
# Use event ID to detect duplicates
|
|
710
|
+
```
|
|
711
|
+
|
|
712
|
+
### Webhook Secret Verification Failing
|
|
713
|
+
|
|
714
|
+
Signature validation errors.
|
|
715
|
+
|
|
716
|
+
**Solution:**
|
|
717
|
+
```bash
|
|
718
|
+
# Get current secret
|
|
719
|
+
$ cakemail webhooks get 301 -f json | jq -r '.secret'
|
|
720
|
+
|
|
721
|
+
# Verify secret matches in application
|
|
722
|
+
# Update application if needed
|
|
723
|
+
|
|
724
|
+
# Rotate secret if compromised
|
|
725
|
+
$ cakemail webhooks update 301 -s "new_secret_key"
|
|
726
|
+
|
|
727
|
+
# Update application configuration
|
|
728
|
+
```
|
|
729
|
+
|
|
730
|
+
### Events Not Triggering Webhook
|
|
731
|
+
|
|
732
|
+
Webhook created but no calls received.
|
|
733
|
+
|
|
734
|
+
**Solution:**
|
|
735
|
+
```bash
|
|
736
|
+
# Verify webhook is active
|
|
737
|
+
$ cakemail webhooks get 301 -f json | jq '.status'
|
|
738
|
+
|
|
739
|
+
# Check subscribed events
|
|
740
|
+
$ cakemail webhooks get 301 -f json | jq '.events'
|
|
741
|
+
|
|
742
|
+
# Ensure events are occurring
|
|
743
|
+
# - Send test email for email.sent
|
|
744
|
+
# - Open email for email.opened
|
|
745
|
+
# - Click link for email.clicked
|
|
746
|
+
|
|
747
|
+
# Check last_triggered_at
|
|
748
|
+
$ cakemail webhooks get 301 -f json | jq '.last_triggered_at'
|
|
749
|
+
```
|
|
750
|
+
|
|
751
|
+
### Webhook URL Changed
|
|
752
|
+
|
|
753
|
+
Need to update endpoint URL.
|
|
754
|
+
|
|
755
|
+
**Solution:**
|
|
756
|
+
```bash
|
|
757
|
+
# Update URL
|
|
758
|
+
$ cakemail webhooks update 301 -u "https://new-api.example.com/webhook"
|
|
759
|
+
|
|
760
|
+
# Verify new URL is accessible
|
|
761
|
+
$ curl https://new-api.example.com/webhook
|
|
762
|
+
|
|
763
|
+
# Test with event
|
|
764
|
+
# Monitor new endpoint for webhook calls
|
|
765
|
+
```
|
|
766
|
+
|
|
767
|
+
---
|
|
768
|
+
|
|
769
|
+
**Related Documentation:**
|
|
770
|
+
- [Emails Commands](/en/cli/command-reference/emails/) - Send transactional emails
|
|
771
|
+
- [Campaigns Commands](/en/cli/command-reference/campaigns/) - Send marketing campaigns
|
|
772
|
+
- [Reports Commands](/en/cli/command-reference/reports/) - View email analytics
|
|
773
|
+
- [Suppressed Commands](/en/cli/command-reference/suppressed/) - Manage suppression list
|