resend-cli 1.2.1 → 1.2.2

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 (191) hide show
  1. package/biome.json +1 -1
  2. package/bun.lock +0 -3
  3. package/package.json +2 -3
  4. package/src/cli.ts +11 -1
  5. package/src/commands/auth/login.ts +35 -8
  6. package/src/commands/doctor.ts +33 -115
  7. package/src/commands/teams/remove.ts +5 -2
  8. package/src/commands/teams/switch.ts +3 -0
  9. package/src/lib/config.ts +37 -31
  10. package/src/lib/spinner.ts +17 -10
  11. package/src/lib/update-check.ts +172 -0
  12. package/tests/commands/auth/login.test.ts +37 -0
  13. package/tests/lib/config.test.ts +38 -7
  14. package/tests/lib/update-check.test.ts +169 -0
  15. package/.claude/worktrees/emails-list/.claude/settings.local.json +0 -5
  16. package/.claude/worktrees/emails-list/.github/scripts/pr-title-check.js +0 -34
  17. package/.claude/worktrees/emails-list/.github/workflows/ci.yml +0 -32
  18. package/.claude/worktrees/emails-list/.github/workflows/pr-title-check.yml +0 -13
  19. package/.claude/worktrees/emails-list/.github/workflows/release.yml +0 -93
  20. package/.claude/worktrees/emails-list/CHANGELOG.md +0 -31
  21. package/.claude/worktrees/emails-list/LICENSE +0 -21
  22. package/.claude/worktrees/emails-list/README.md +0 -424
  23. package/.claude/worktrees/emails-list/biome.json +0 -36
  24. package/.claude/worktrees/emails-list/bun.lock +0 -76
  25. package/.claude/worktrees/emails-list/bunfig.toml +0 -2
  26. package/.claude/worktrees/emails-list/install.ps1 +0 -140
  27. package/.claude/worktrees/emails-list/install.sh +0 -301
  28. package/.claude/worktrees/emails-list/package.json +0 -43
  29. package/.claude/worktrees/emails-list/renovate.json +0 -6
  30. package/.claude/worktrees/emails-list/src/cli.ts +0 -74
  31. package/.claude/worktrees/emails-list/src/commands/api-keys/create.ts +0 -114
  32. package/.claude/worktrees/emails-list/src/commands/api-keys/delete.ts +0 -47
  33. package/.claude/worktrees/emails-list/src/commands/api-keys/index.ts +0 -26
  34. package/.claude/worktrees/emails-list/src/commands/api-keys/list.ts +0 -35
  35. package/.claude/worktrees/emails-list/src/commands/api-keys/utils.ts +0 -8
  36. package/.claude/worktrees/emails-list/src/commands/auth/index.ts +0 -20
  37. package/.claude/worktrees/emails-list/src/commands/auth/login.ts +0 -207
  38. package/.claude/worktrees/emails-list/src/commands/auth/logout.ts +0 -105
  39. package/.claude/worktrees/emails-list/src/commands/broadcasts/create.ts +0 -196
  40. package/.claude/worktrees/emails-list/src/commands/broadcasts/delete.ts +0 -46
  41. package/.claude/worktrees/emails-list/src/commands/broadcasts/get.ts +0 -59
  42. package/.claude/worktrees/emails-list/src/commands/broadcasts/index.ts +0 -43
  43. package/.claude/worktrees/emails-list/src/commands/broadcasts/list.ts +0 -60
  44. package/.claude/worktrees/emails-list/src/commands/broadcasts/send.ts +0 -56
  45. package/.claude/worktrees/emails-list/src/commands/broadcasts/update.ts +0 -95
  46. package/.claude/worktrees/emails-list/src/commands/broadcasts/utils.ts +0 -35
  47. package/.claude/worktrees/emails-list/src/commands/contact-properties/create.ts +0 -118
  48. package/.claude/worktrees/emails-list/src/commands/contact-properties/delete.ts +0 -48
  49. package/.claude/worktrees/emails-list/src/commands/contact-properties/get.ts +0 -46
  50. package/.claude/worktrees/emails-list/src/commands/contact-properties/index.ts +0 -48
  51. package/.claude/worktrees/emails-list/src/commands/contact-properties/list.ts +0 -68
  52. package/.claude/worktrees/emails-list/src/commands/contact-properties/update.ts +0 -88
  53. package/.claude/worktrees/emails-list/src/commands/contact-properties/utils.ts +0 -17
  54. package/.claude/worktrees/emails-list/src/commands/contacts/add-segment.ts +0 -78
  55. package/.claude/worktrees/emails-list/src/commands/contacts/create.ts +0 -122
  56. package/.claude/worktrees/emails-list/src/commands/contacts/delete.ts +0 -49
  57. package/.claude/worktrees/emails-list/src/commands/contacts/get.ts +0 -53
  58. package/.claude/worktrees/emails-list/src/commands/contacts/index.ts +0 -58
  59. package/.claude/worktrees/emails-list/src/commands/contacts/list.ts +0 -57
  60. package/.claude/worktrees/emails-list/src/commands/contacts/remove-segment.ts +0 -48
  61. package/.claude/worktrees/emails-list/src/commands/contacts/segments.ts +0 -39
  62. package/.claude/worktrees/emails-list/src/commands/contacts/topics.ts +0 -45
  63. package/.claude/worktrees/emails-list/src/commands/contacts/update-topics.ts +0 -90
  64. package/.claude/worktrees/emails-list/src/commands/contacts/update.ts +0 -77
  65. package/.claude/worktrees/emails-list/src/commands/contacts/utils.ts +0 -119
  66. package/.claude/worktrees/emails-list/src/commands/doctor.ts +0 -298
  67. package/.claude/worktrees/emails-list/src/commands/domains/create.ts +0 -83
  68. package/.claude/worktrees/emails-list/src/commands/domains/delete.ts +0 -42
  69. package/.claude/worktrees/emails-list/src/commands/domains/get.ts +0 -47
  70. package/.claude/worktrees/emails-list/src/commands/domains/index.ts +0 -35
  71. package/.claude/worktrees/emails-list/src/commands/domains/list.ts +0 -53
  72. package/.claude/worktrees/emails-list/src/commands/domains/update.ts +0 -75
  73. package/.claude/worktrees/emails-list/src/commands/domains/utils.ts +0 -44
  74. package/.claude/worktrees/emails-list/src/commands/domains/verify.ts +0 -38
  75. package/.claude/worktrees/emails-list/src/commands/emails/batch.ts +0 -140
  76. package/.claude/worktrees/emails-list/src/commands/emails/index.ts +0 -28
  77. package/.claude/worktrees/emails-list/src/commands/emails/list.ts +0 -73
  78. package/.claude/worktrees/emails-list/src/commands/emails/receiving/attachment.ts +0 -55
  79. package/.claude/worktrees/emails-list/src/commands/emails/receiving/attachments.ts +0 -68
  80. package/.claude/worktrees/emails-list/src/commands/emails/receiving/get.ts +0 -58
  81. package/.claude/worktrees/emails-list/src/commands/emails/receiving/index.ts +0 -28
  82. package/.claude/worktrees/emails-list/src/commands/emails/receiving/list.ts +0 -59
  83. package/.claude/worktrees/emails-list/src/commands/emails/receiving/utils.ts +0 -38
  84. package/.claude/worktrees/emails-list/src/commands/emails/send.ts +0 -189
  85. package/.claude/worktrees/emails-list/src/commands/open.ts +0 -24
  86. package/.claude/worktrees/emails-list/src/commands/segments/create.ts +0 -50
  87. package/.claude/worktrees/emails-list/src/commands/segments/delete.ts +0 -47
  88. package/.claude/worktrees/emails-list/src/commands/segments/get.ts +0 -38
  89. package/.claude/worktrees/emails-list/src/commands/segments/index.ts +0 -36
  90. package/.claude/worktrees/emails-list/src/commands/segments/list.ts +0 -58
  91. package/.claude/worktrees/emails-list/src/commands/segments/utils.ts +0 -7
  92. package/.claude/worktrees/emails-list/src/commands/teams/index.ts +0 -10
  93. package/.claude/worktrees/emails-list/src/commands/teams/list.ts +0 -35
  94. package/.claude/worktrees/emails-list/src/commands/teams/remove.ts +0 -83
  95. package/.claude/worktrees/emails-list/src/commands/teams/switch.ts +0 -73
  96. package/.claude/worktrees/emails-list/src/commands/topics/create.ts +0 -73
  97. package/.claude/worktrees/emails-list/src/commands/topics/delete.ts +0 -47
  98. package/.claude/worktrees/emails-list/src/commands/topics/get.ts +0 -42
  99. package/.claude/worktrees/emails-list/src/commands/topics/index.ts +0 -42
  100. package/.claude/worktrees/emails-list/src/commands/topics/list.ts +0 -34
  101. package/.claude/worktrees/emails-list/src/commands/topics/update.ts +0 -59
  102. package/.claude/worktrees/emails-list/src/commands/topics/utils.ts +0 -16
  103. package/.claude/worktrees/emails-list/src/commands/webhooks/create.ts +0 -128
  104. package/.claude/worktrees/emails-list/src/commands/webhooks/delete.ts +0 -49
  105. package/.claude/worktrees/emails-list/src/commands/webhooks/get.ts +0 -42
  106. package/.claude/worktrees/emails-list/src/commands/webhooks/index.ts +0 -44
  107. package/.claude/worktrees/emails-list/src/commands/webhooks/list.ts +0 -55
  108. package/.claude/worktrees/emails-list/src/commands/webhooks/update.ts +0 -83
  109. package/.claude/worktrees/emails-list/src/commands/webhooks/utils.ts +0 -36
  110. package/.claude/worktrees/emails-list/src/commands/whoami.ts +0 -71
  111. package/.claude/worktrees/emails-list/src/lib/actions.ts +0 -157
  112. package/.claude/worktrees/emails-list/src/lib/client.ts +0 -34
  113. package/.claude/worktrees/emails-list/src/lib/config.ts +0 -211
  114. package/.claude/worktrees/emails-list/src/lib/files.ts +0 -15
  115. package/.claude/worktrees/emails-list/src/lib/help-text.ts +0 -38
  116. package/.claude/worktrees/emails-list/src/lib/output.ts +0 -54
  117. package/.claude/worktrees/emails-list/src/lib/pagination.ts +0 -36
  118. package/.claude/worktrees/emails-list/src/lib/prompts.ts +0 -149
  119. package/.claude/worktrees/emails-list/src/lib/spinner.ts +0 -93
  120. package/.claude/worktrees/emails-list/src/lib/table.ts +0 -57
  121. package/.claude/worktrees/emails-list/src/lib/tty.ts +0 -28
  122. package/.claude/worktrees/emails-list/src/lib/version.ts +0 -4
  123. package/.claude/worktrees/emails-list/tests/commands/api-keys/create.test.ts +0 -195
  124. package/.claude/worktrees/emails-list/tests/commands/api-keys/delete.test.ts +0 -156
  125. package/.claude/worktrees/emails-list/tests/commands/api-keys/list.test.ts +0 -133
  126. package/.claude/worktrees/emails-list/tests/commands/auth/login.test.ts +0 -119
  127. package/.claude/worktrees/emails-list/tests/commands/auth/logout.test.ts +0 -146
  128. package/.claude/worktrees/emails-list/tests/commands/broadcasts/create.test.ts +0 -447
  129. package/.claude/worktrees/emails-list/tests/commands/broadcasts/delete.test.ts +0 -182
  130. package/.claude/worktrees/emails-list/tests/commands/broadcasts/get.test.ts +0 -146
  131. package/.claude/worktrees/emails-list/tests/commands/broadcasts/list.test.ts +0 -196
  132. package/.claude/worktrees/emails-list/tests/commands/broadcasts/send.test.ts +0 -161
  133. package/.claude/worktrees/emails-list/tests/commands/broadcasts/update.test.ts +0 -283
  134. package/.claude/worktrees/emails-list/tests/commands/contact-properties/create.test.ts +0 -250
  135. package/.claude/worktrees/emails-list/tests/commands/contact-properties/delete.test.ts +0 -183
  136. package/.claude/worktrees/emails-list/tests/commands/contact-properties/get.test.ts +0 -144
  137. package/.claude/worktrees/emails-list/tests/commands/contact-properties/list.test.ts +0 -180
  138. package/.claude/worktrees/emails-list/tests/commands/contact-properties/update.test.ts +0 -216
  139. package/.claude/worktrees/emails-list/tests/commands/contacts/add-segment.test.ts +0 -188
  140. package/.claude/worktrees/emails-list/tests/commands/contacts/create.test.ts +0 -270
  141. package/.claude/worktrees/emails-list/tests/commands/contacts/delete.test.ts +0 -192
  142. package/.claude/worktrees/emails-list/tests/commands/contacts/get.test.ts +0 -148
  143. package/.claude/worktrees/emails-list/tests/commands/contacts/list.test.ts +0 -175
  144. package/.claude/worktrees/emails-list/tests/commands/contacts/remove-segment.test.ts +0 -166
  145. package/.claude/worktrees/emails-list/tests/commands/contacts/segments.test.ts +0 -167
  146. package/.claude/worktrees/emails-list/tests/commands/contacts/topics.test.ts +0 -163
  147. package/.claude/worktrees/emails-list/tests/commands/contacts/update-topics.test.ts +0 -247
  148. package/.claude/worktrees/emails-list/tests/commands/contacts/update.test.ts +0 -205
  149. package/.claude/worktrees/emails-list/tests/commands/doctor.test.ts +0 -165
  150. package/.claude/worktrees/emails-list/tests/commands/domains/create.test.ts +0 -192
  151. package/.claude/worktrees/emails-list/tests/commands/domains/delete.test.ts +0 -156
  152. package/.claude/worktrees/emails-list/tests/commands/domains/get.test.ts +0 -137
  153. package/.claude/worktrees/emails-list/tests/commands/domains/list.test.ts +0 -164
  154. package/.claude/worktrees/emails-list/tests/commands/domains/update.test.ts +0 -223
  155. package/.claude/worktrees/emails-list/tests/commands/domains/verify.test.ts +0 -117
  156. package/.claude/worktrees/emails-list/tests/commands/emails/batch.test.ts +0 -313
  157. package/.claude/worktrees/emails-list/tests/commands/emails/list.test.ts +0 -196
  158. package/.claude/worktrees/emails-list/tests/commands/emails/receiving/attachment.test.ts +0 -140
  159. package/.claude/worktrees/emails-list/tests/commands/emails/receiving/attachments.test.ts +0 -168
  160. package/.claude/worktrees/emails-list/tests/commands/emails/receiving/get.test.ts +0 -140
  161. package/.claude/worktrees/emails-list/tests/commands/emails/receiving/list.test.ts +0 -181
  162. package/.claude/worktrees/emails-list/tests/commands/emails/send.test.ts +0 -309
  163. package/.claude/worktrees/emails-list/tests/commands/segments/create.test.ts +0 -163
  164. package/.claude/worktrees/emails-list/tests/commands/segments/delete.test.ts +0 -182
  165. package/.claude/worktrees/emails-list/tests/commands/segments/get.test.ts +0 -137
  166. package/.claude/worktrees/emails-list/tests/commands/segments/list.test.ts +0 -173
  167. package/.claude/worktrees/emails-list/tests/commands/teams/list.test.ts +0 -63
  168. package/.claude/worktrees/emails-list/tests/commands/teams/remove.test.ts +0 -103
  169. package/.claude/worktrees/emails-list/tests/commands/teams/switch.test.ts +0 -96
  170. package/.claude/worktrees/emails-list/tests/commands/topics/create.test.ts +0 -191
  171. package/.claude/worktrees/emails-list/tests/commands/topics/delete.test.ts +0 -156
  172. package/.claude/worktrees/emails-list/tests/commands/topics/get.test.ts +0 -125
  173. package/.claude/worktrees/emails-list/tests/commands/topics/list.test.ts +0 -124
  174. package/.claude/worktrees/emails-list/tests/commands/topics/update.test.ts +0 -177
  175. package/.claude/worktrees/emails-list/tests/commands/webhooks/create.test.ts +0 -224
  176. package/.claude/worktrees/emails-list/tests/commands/webhooks/delete.test.ts +0 -156
  177. package/.claude/worktrees/emails-list/tests/commands/webhooks/get.test.ts +0 -125
  178. package/.claude/worktrees/emails-list/tests/commands/webhooks/list.test.ts +0 -177
  179. package/.claude/worktrees/emails-list/tests/commands/webhooks/update.test.ts +0 -206
  180. package/.claude/worktrees/emails-list/tests/commands/whoami.test.ts +0 -99
  181. package/.claude/worktrees/emails-list/tests/helpers.ts +0 -93
  182. package/.claude/worktrees/emails-list/tests/lib/client.test.ts +0 -71
  183. package/.claude/worktrees/emails-list/tests/lib/config.test.ts +0 -414
  184. package/.claude/worktrees/emails-list/tests/lib/files.test.ts +0 -65
  185. package/.claude/worktrees/emails-list/tests/lib/help-text.test.ts +0 -97
  186. package/.claude/worktrees/emails-list/tests/lib/output.test.ts +0 -127
  187. package/.claude/worktrees/emails-list/tests/lib/prompts.test.ts +0 -178
  188. package/.claude/worktrees/emails-list/tests/lib/spinner.test.ts +0 -146
  189. package/.claude/worktrees/emails-list/tests/lib/table.test.ts +0 -63
  190. package/.claude/worktrees/emails-list/tests/lib/tty.test.ts +0 -85
  191. package/.claude/worktrees/emails-list/tsconfig.json +0 -14
@@ -1,128 +0,0 @@
1
- import * as p from '@clack/prompts';
2
- import { Command } from '@commander-js/extra-typings';
3
- import type { WebhookEvent } from 'resend';
4
- import { runCreate } from '../../lib/actions';
5
- import type { GlobalOpts } from '../../lib/client';
6
- import { buildHelpText } from '../../lib/help-text';
7
- import { outputError } from '../../lib/output';
8
- import { cancelAndExit, requireText } from '../../lib/prompts';
9
- import { isInteractive } from '../../lib/tty';
10
- import { ALL_WEBHOOK_EVENTS } from './utils';
11
-
12
- export const createWebhookCommand = new Command('create')
13
- .description(
14
- 'Register a new webhook endpoint to receive real-time event notifications',
15
- )
16
- .option(
17
- '--endpoint <endpoint>',
18
- 'HTTPS URL to receive webhook events (required)',
19
- )
20
- .option(
21
- '--events <events...>',
22
- 'Event types to subscribe to. Use "all" as shorthand for all 17 events.',
23
- )
24
- .addHelpText(
25
- 'after',
26
- buildHelpText({
27
- context: `Webhooks deliver real-time event notifications to your HTTPS endpoint.
28
- Events fire per-recipient: a batch email to 3 recipients generates 3 email.sent events.
29
-
30
- --endpoint must use HTTPS.
31
-
32
- --events accepts space-separated event types or the special value "all":
33
- resend webhooks create --endpoint https://... --events email.sent email.delivered
34
- resend webhooks create --endpoint https://... --events all
35
-
36
- Available event types (17 total):
37
- Email: email.sent, email.delivered, email.delivery_delayed, email.bounced,
38
- email.complained, email.opened, email.clicked, email.failed,
39
- email.scheduled, email.suppressed, email.received
40
- Contact: contact.created, contact.updated, contact.deleted
41
- Domain: domain.created, domain.updated, domain.deleted
42
-
43
- The signing_secret in the response is shown ONCE — save it immediately to verify
44
- webhook payloads using Svix signature headers (svix-id, svix-timestamp, svix-signature).
45
- Use resend.webhooks.verify() in your application to validate incoming payloads.
46
-
47
- Non-interactive: --endpoint and --events are required.`,
48
- output: ` {"object":"webhook","id":"<uuid>","signing_secret":"<whsec_...>"}`,
49
- errorCodes: [
50
- 'auth_error',
51
- 'missing_endpoint',
52
- 'missing_events',
53
- 'create_error',
54
- ],
55
- examples: [
56
- 'resend webhooks create --endpoint https://app.example.com/hooks/resend --events all',
57
- 'resend webhooks create --endpoint https://app.example.com/hooks/resend --events email.sent email.bounced',
58
- 'resend webhooks create --endpoint https://app.example.com/hooks/resend --events all --json',
59
- ],
60
- }),
61
- )
62
- .action(async (opts, cmd) => {
63
- const globalOpts = cmd.optsWithGlobals() as GlobalOpts;
64
-
65
- const endpoint = await requireText(
66
- opts.endpoint,
67
- {
68
- message: 'Webhook endpoint URL',
69
- placeholder: 'https://your-app.com/webhooks/resend',
70
- validate: (v) => {
71
- if (!v) {
72
- return 'Endpoint URL is required';
73
- }
74
- if (!v.startsWith('https://')) {
75
- return 'Endpoint must use HTTPS';
76
- }
77
- return undefined;
78
- },
79
- },
80
- { message: 'Missing --endpoint flag.', code: 'missing_endpoint' },
81
- globalOpts,
82
- );
83
-
84
- let selectedEvents: WebhookEvent[];
85
-
86
- if (opts.events?.includes('all')) {
87
- selectedEvents = ALL_WEBHOOK_EVENTS;
88
- } else if (opts.events?.length) {
89
- selectedEvents = opts.events as WebhookEvent[];
90
- } else {
91
- if (!isInteractive()) {
92
- outputError(
93
- { message: 'Missing --events flag.', code: 'missing_events' },
94
- { json: globalOpts.json },
95
- );
96
- }
97
- const result = await p.multiselect({
98
- message: 'Select event types to subscribe to',
99
- options: ALL_WEBHOOK_EVENTS.map((e) => ({ value: e, label: e })),
100
- });
101
- if (p.isCancel(result)) {
102
- cancelAndExit('Cancelled.');
103
- }
104
- selectedEvents = result;
105
- }
106
-
107
- await runCreate(
108
- {
109
- spinner: {
110
- loading: 'Creating webhook...',
111
- success: 'Webhook created',
112
- fail: 'Failed to create webhook',
113
- },
114
- sdkCall: (resend) =>
115
- resend.webhooks.create({
116
- endpoint,
117
- events: selectedEvents,
118
- }),
119
- onInteractive: (d) => {
120
- console.log(`\nWebhook created`);
121
- console.log(`ID: ${d.id}`);
122
- console.log(`Signing Secret: ${d.signing_secret}`);
123
- console.log(`\nSave the signing secret — it is only shown once.`);
124
- },
125
- },
126
- globalOpts,
127
- );
128
- });
@@ -1,49 +0,0 @@
1
- import { Command } from '@commander-js/extra-typings';
2
- import { runDelete } from '../../lib/actions';
3
- import type { GlobalOpts } from '../../lib/client';
4
- import { buildHelpText } from '../../lib/help-text';
5
-
6
- export const deleteWebhookCommand = new Command('delete')
7
- .alias('rm')
8
- .description('Delete a webhook endpoint and stop all event deliveries to it')
9
- .argument('<id>', 'Webhook UUID')
10
- .option(
11
- '--yes',
12
- 'Skip the confirmation prompt (required in non-interactive mode)',
13
- )
14
- .addHelpText(
15
- 'after',
16
- buildHelpText({
17
- context: `Warning: Deleting a webhook immediately stops event delivery to the endpoint.
18
- In-flight events may still be attempted once before the deletion takes effect.
19
- To temporarily pause delivery without losing configuration, use:
20
- resend webhooks update <id> --status disabled
21
-
22
- Non-interactive: --yes is required to confirm deletion when stdin/stdout is not a TTY.`,
23
- output: ` {"object":"webhook","id":"<uuid>","deleted":true}`,
24
- errorCodes: ['auth_error', 'confirmation_required', 'delete_error'],
25
- examples: [
26
- 'resend webhooks delete wh_abc123 --yes',
27
- 'resend webhooks delete wh_abc123 --yes --json',
28
- ],
29
- }),
30
- )
31
- .action(async (id, opts, cmd) => {
32
- const globalOpts = cmd.optsWithGlobals() as GlobalOpts;
33
- await runDelete(
34
- id,
35
- !!opts.yes,
36
- {
37
- confirmMessage: `Delete webhook ${id}?\nEvents will no longer be delivered to this endpoint.`,
38
- spinner: {
39
- loading: 'Deleting webhook...',
40
- success: 'Webhook deleted',
41
- fail: 'Failed to delete webhook',
42
- },
43
- object: 'webhook',
44
- successMsg: 'Webhook deleted.',
45
- sdkCall: (resend) => resend.webhooks.remove(id),
46
- },
47
- globalOpts,
48
- );
49
- });
@@ -1,42 +0,0 @@
1
- import { Command } from '@commander-js/extra-typings';
2
- import { runGet } from '../../lib/actions';
3
- import type { GlobalOpts } from '../../lib/client';
4
- import { buildHelpText } from '../../lib/help-text';
5
-
6
- export const getWebhookCommand = new Command('get')
7
- .description('Retrieve a webhook endpoint configuration by ID')
8
- .argument('<id>', 'Webhook UUID')
9
- .addHelpText(
10
- 'after',
11
- buildHelpText({
12
- context: `Note: The signing_secret is not returned by the get endpoint.
13
- To rotate secrets, delete the webhook and recreate it.`,
14
- output: ` {"object":"webhook","id":"<uuid>","endpoint":"<url>","events":["<event>"],"status":"enabled|disabled","created_at":"<iso-date>","signing_secret":"<whsec_...>"}`,
15
- errorCodes: ['auth_error', 'fetch_error'],
16
- examples: [
17
- 'resend webhooks get wh_abc123',
18
- 'resend webhooks get wh_abc123 --json',
19
- ],
20
- }),
21
- )
22
- .action(async (id, _opts, cmd) => {
23
- const globalOpts = cmd.optsWithGlobals() as GlobalOpts;
24
- await runGet(
25
- {
26
- spinner: {
27
- loading: 'Fetching webhook...',
28
- success: 'Webhook fetched',
29
- fail: 'Failed to fetch webhook',
30
- },
31
- sdkCall: (resend) => resend.webhooks.get(id),
32
- onInteractive: (d) => {
33
- console.log(`\n${d.endpoint}`);
34
- console.log(`ID: ${d.id}`);
35
- console.log(`Status: ${d.status}`);
36
- console.log(`Events: ${(d.events ?? []).join(', ') || '(none)'}`);
37
- console.log(`Created: ${d.created_at}`);
38
- },
39
- },
40
- globalOpts,
41
- );
42
- });
@@ -1,44 +0,0 @@
1
- import { Command } from '@commander-js/extra-typings';
2
- import { buildHelpText } from '../../lib/help-text';
3
- import { createWebhookCommand } from './create';
4
- import { deleteWebhookCommand } from './delete';
5
- import { getWebhookCommand } from './get';
6
- import { listWebhooksCommand } from './list';
7
- import { updateWebhookCommand } from './update';
8
-
9
- export const webhooksCommand = new Command('webhooks')
10
- .description('Manage webhook endpoints for real-time event notifications')
11
- .addHelpText(
12
- 'after',
13
- buildHelpText({
14
- context: `Webhooks let you receive real-time event notifications from Resend at an HTTPS endpoint.
15
- Payloads are signed with Svix headers for verification.
16
-
17
- As of January 2026, webhook events fire per-recipient. A batch email to 3 recipients
18
- generates 3 email.sent events. The "to" field remains an array for backward compatibility
19
- but contains one entry per event.
20
-
21
- Event categories (17 total):
22
- Email: email.sent, email.delivered, email.delivery_delayed, email.bounced,
23
- email.complained, email.opened, email.clicked, email.failed,
24
- email.scheduled, email.suppressed, email.received
25
- Contact: contact.created, contact.updated, contact.deleted
26
- Domain: domain.created, domain.updated, domain.deleted
27
-
28
- Signature verification (Svix):
29
- Each delivery includes headers: svix-id, svix-timestamp, svix-signature
30
- Verify payloads in your application using: resend.webhooks.verify({ payload, headers, webhookSecret })`,
31
- examples: [
32
- 'resend webhooks list',
33
- 'resend webhooks create --endpoint https://app.example.com/hooks/resend --events all',
34
- 'resend webhooks get wh_abc123',
35
- 'resend webhooks update wh_abc123 --status disabled',
36
- 'resend webhooks delete wh_abc123 --yes',
37
- ],
38
- }),
39
- )
40
- .addCommand(createWebhookCommand)
41
- .addCommand(getWebhookCommand)
42
- .addCommand(listWebhooksCommand, { isDefault: true })
43
- .addCommand(updateWebhookCommand)
44
- .addCommand(deleteWebhookCommand);
@@ -1,55 +0,0 @@
1
- import { Command } from '@commander-js/extra-typings';
2
- import { runList } from '../../lib/actions';
3
- import type { GlobalOpts } from '../../lib/client';
4
- import { buildHelpText } from '../../lib/help-text';
5
- import {
6
- buildPaginationOpts,
7
- parseLimitOpt,
8
- printPaginationHint,
9
- } from '../../lib/pagination';
10
- import { renderWebhooksTable } from './utils';
11
-
12
- export const listWebhooksCommand = new Command('list')
13
- .alias('ls')
14
- .description('List all registered webhook endpoints')
15
- .option('--limit <n>', 'Maximum number of webhooks to return (1-100)', '10')
16
- .option('--after <cursor>', 'Return webhooks after this cursor (next page)')
17
- .option(
18
- '--before <cursor>',
19
- 'Return webhooks before this cursor (previous page)',
20
- )
21
- .addHelpText(
22
- 'after',
23
- buildHelpText({
24
- context: `Pagination: use --after or --before with a webhook ID as the cursor.
25
- Only one of --after or --before may be used at a time.
26
- The response includes has_more: true when additional pages exist.`,
27
- output: ` {"object":"list","data":[{"id":"<uuid>","endpoint":"<url>","events":["<event>"],"status":"enabled","created_at":"<iso-date>"}],"has_more":false}`,
28
- errorCodes: ['auth_error', 'invalid_limit', 'list_error'],
29
- examples: [
30
- 'resend webhooks list',
31
- 'resend webhooks list --limit 25 --json',
32
- 'resend webhooks list --after wh_abc123 --json',
33
- ],
34
- }),
35
- )
36
- .action(async (opts, cmd) => {
37
- const globalOpts = cmd.optsWithGlobals() as GlobalOpts;
38
- const limit = parseLimitOpt(opts.limit, globalOpts);
39
- const paginationOpts = buildPaginationOpts(limit, opts.after, opts.before);
40
- await runList(
41
- {
42
- spinner: {
43
- loading: 'Fetching webhooks...',
44
- success: 'Webhooks fetched',
45
- fail: 'Failed to list webhooks',
46
- },
47
- sdkCall: (resend) => resend.webhooks.list(paginationOpts),
48
- onInteractive: (list) => {
49
- console.log(renderWebhooksTable(list.data));
50
- printPaginationHint(list);
51
- },
52
- },
53
- globalOpts,
54
- );
55
- });
@@ -1,83 +0,0 @@
1
- import { Command, Option } from '@commander-js/extra-typings';
2
- import type { WebhookEvent } from 'resend';
3
- import { runWrite } from '../../lib/actions';
4
- import type { GlobalOpts } from '../../lib/client';
5
- import { buildHelpText } from '../../lib/help-text';
6
- import { outputError } from '../../lib/output';
7
- import { ALL_WEBHOOK_EVENTS } from './utils';
8
-
9
- export const updateWebhookCommand = new Command('update')
10
- .description(
11
- "Update a webhook's endpoint URL, event subscriptions, or enabled status",
12
- )
13
- .argument('<id>', 'Webhook UUID')
14
- .option('--endpoint <endpoint>', 'New HTTPS URL for this webhook')
15
- .option(
16
- '--events <events...>',
17
- 'Replace the full event subscription list. Use "all" for all 17 events.',
18
- )
19
- .addOption(
20
- new Option(
21
- '--status <status>',
22
- 'Enable or disable event delivery for this webhook',
23
- ).choices(['enabled', 'disabled'] as const),
24
- )
25
- .addHelpText(
26
- 'after',
27
- buildHelpText({
28
- context: `At least one of --endpoint, --events, or --status must be provided.
29
-
30
- --events replaces the entire event list (it is not additive).
31
- Use "all" as a shorthand for all 17 event types.
32
-
33
- --status controls whether events are delivered to this endpoint:
34
- enabled Events are delivered (default on creation)
35
- disabled Events are suppressed without deleting the webhook`,
36
- output: ` {"object":"webhook","id":"<uuid>"}`,
37
- errorCodes: ['auth_error', 'no_changes', 'update_error'],
38
- examples: [
39
- 'resend webhooks update wh_abc123 --endpoint https://new-app.example.com/hooks/resend',
40
- 'resend webhooks update wh_abc123 --events email.sent email.bounced',
41
- 'resend webhooks update wh_abc123 --events all',
42
- 'resend webhooks update wh_abc123 --status disabled',
43
- 'resend webhooks update wh_abc123 --endpoint https://new-app.example.com/hooks/resend --events all --json',
44
- ],
45
- }),
46
- )
47
- .action(async (id, opts, cmd) => {
48
- const globalOpts = cmd.optsWithGlobals() as GlobalOpts;
49
-
50
- if (!opts.endpoint && !opts.events?.length && !opts.status) {
51
- outputError(
52
- {
53
- message:
54
- 'Provide at least one option to update: --endpoint, --events, or --status.',
55
- code: 'no_changes',
56
- },
57
- { json: globalOpts.json },
58
- );
59
- }
60
-
61
- const selectedEvents = opts.events?.includes('all')
62
- ? ALL_WEBHOOK_EVENTS
63
- : (opts.events as WebhookEvent[] | undefined);
64
-
65
- await runWrite(
66
- {
67
- spinner: {
68
- loading: 'Updating webhook...',
69
- success: 'Webhook updated',
70
- fail: 'Failed to update webhook',
71
- },
72
- sdkCall: (resend) =>
73
- resend.webhooks.update(id, {
74
- ...(opts.endpoint && { endpoint: opts.endpoint }),
75
- ...(selectedEvents?.length && { events: selectedEvents }),
76
- ...(opts.status && { status: opts.status }),
77
- }),
78
- errorCode: 'update_error',
79
- successMsg: `Webhook updated: ${id}`,
80
- },
81
- globalOpts,
82
- );
83
- });
@@ -1,36 +0,0 @@
1
- import type { Webhook, WebhookEvent } from 'resend';
2
- import { renderTable } from '../../lib/table';
3
-
4
- export const ALL_WEBHOOK_EVENTS: WebhookEvent[] = [
5
- 'email.sent',
6
- 'email.delivered',
7
- 'email.delivery_delayed',
8
- 'email.bounced',
9
- 'email.complained',
10
- 'email.opened',
11
- 'email.clicked',
12
- 'email.failed',
13
- 'email.scheduled',
14
- 'email.suppressed',
15
- 'email.received',
16
- 'contact.created',
17
- 'contact.updated',
18
- 'contact.deleted',
19
- 'domain.created',
20
- 'domain.updated',
21
- 'domain.deleted',
22
- ];
23
-
24
- export function renderWebhooksTable(webhooks: Webhook[]): string {
25
- const rows = webhooks.map((w) => {
26
- const eventsStr = (w.events ?? []).join(', ');
27
- const events =
28
- eventsStr.length > 60 ? `${eventsStr.slice(0, 57)}...` : eventsStr;
29
- return [w.endpoint, events, w.status, w.id];
30
- });
31
- return renderTable(
32
- ['Endpoint', 'Events', 'Status', 'ID'],
33
- rows,
34
- '(no webhooks)',
35
- );
36
- }
@@ -1,71 +0,0 @@
1
- import { Command } from '@commander-js/extra-typings';
2
- import type { GlobalOpts } from '../lib/client';
3
- import { maskKey, resolveApiKey, resolveTeamName } from '../lib/config';
4
- import { buildHelpText } from '../lib/help-text';
5
- import { outputError, outputResult } from '../lib/output';
6
- import { isInteractive } from '../lib/tty';
7
-
8
- export const whoamiCommand = new Command('whoami')
9
- .description('Show current authentication status')
10
- .addHelpText(
11
- 'after',
12
- buildHelpText({
13
- setup: true,
14
- context: `Local only — no network calls.
15
- Shows which team is active and where the API key comes from.`,
16
- output: ` {"authenticated":true,"team":"production","api_key":"re_...abcd","source":"config"}
17
- {"authenticated":false}`,
18
- examples: [
19
- 'resend whoami',
20
- 'resend whoami --json',
21
- 'resend whoami --team production',
22
- ],
23
- }),
24
- )
25
- .action((_opts, cmd) => {
26
- const globalOpts = cmd.optsWithGlobals() as GlobalOpts;
27
- const teamName = globalOpts.team;
28
- const resolved = resolveApiKey(globalOpts.apiKey, teamName);
29
-
30
- if (!resolved) {
31
- if (globalOpts.json || !isInteractive()) {
32
- outputResult(
33
- { authenticated: false },
34
- { json: globalOpts.json, exitCode: 1 },
35
- );
36
- // outputResult with exitCode calls process.exit, but TS doesn't know
37
- return;
38
- }
39
- outputError(
40
- {
41
- message: 'Not authenticated.\nRun `resend login` to get started.',
42
- code: 'not_authenticated',
43
- },
44
- { json: false },
45
- );
46
- return;
47
- }
48
-
49
- const team = resolved.team ?? resolveTeamName(teamName);
50
-
51
- if (globalOpts.json || !isInteractive()) {
52
- outputResult(
53
- {
54
- authenticated: true,
55
- team,
56
- api_key: maskKey(resolved.key),
57
- source: resolved.source,
58
- },
59
- { json: globalOpts.json },
60
- );
61
- return;
62
- }
63
-
64
- console.log('');
65
- console.log(` Team: ${team}`);
66
- console.log(` API Key: ${maskKey(resolved.key)}`);
67
- console.log(
68
- ` Source: ${resolved.source === 'config' ? 'config file' : resolved.source === 'env' ? 'environment variable' : 'flag'}`,
69
- );
70
- console.log('');
71
- });
@@ -1,157 +0,0 @@
1
- import type { Resend } from 'resend';
2
- import type { GlobalOpts } from './client';
3
- import { requireClient } from './client';
4
- import { outputResult } from './output';
5
- import { confirmDelete } from './prompts';
6
- import { withSpinner } from './spinner';
7
- import { isInteractive } from './tty';
8
-
9
- type SdkCall<T> = (
10
- resend: Resend,
11
- ) => Promise<{ data: T | null; error: { message: string } | null }>;
12
- type SpinnerMessages = { loading: string; success: string; fail: string };
13
-
14
- /**
15
- * Shared pattern for all get commands:
16
- * requireClient → withSpinner(fetch_error) → if/else output
17
- */
18
- export async function runGet<T>(
19
- config: {
20
- spinner: SpinnerMessages;
21
- sdkCall: SdkCall<T>;
22
- onInteractive: (data: T) => void;
23
- },
24
- globalOpts: GlobalOpts,
25
- ): Promise<void> {
26
- const resend = requireClient(globalOpts);
27
- const data = await withSpinner(
28
- config.spinner,
29
- () => config.sdkCall(resend),
30
- 'fetch_error',
31
- globalOpts,
32
- );
33
- if (!globalOpts.json && isInteractive()) {
34
- config.onInteractive(data);
35
- } else {
36
- outputResult(data, { json: globalOpts.json });
37
- }
38
- }
39
-
40
- /**
41
- * Shared pattern for all delete commands:
42
- * requireClient → confirmDelete (if needed) → withSpinner → if/else output
43
- */
44
- export async function runDelete(
45
- id: string,
46
- skipConfirm: boolean,
47
- config: {
48
- confirmMessage: string;
49
- spinner: SpinnerMessages;
50
- object: string;
51
- successMsg: string;
52
- sdkCall: SdkCall<unknown>;
53
- },
54
- globalOpts: GlobalOpts,
55
- ): Promise<void> {
56
- const resend = requireClient(globalOpts);
57
- if (!skipConfirm) {
58
- await confirmDelete(id, config.confirmMessage, globalOpts);
59
- }
60
- await withSpinner(
61
- config.spinner,
62
- () => config.sdkCall(resend),
63
- 'delete_error',
64
- globalOpts,
65
- );
66
- if (!globalOpts.json && isInteractive()) {
67
- console.log(config.successMsg);
68
- } else {
69
- outputResult(
70
- { object: config.object, id, deleted: true },
71
- { json: globalOpts.json },
72
- );
73
- }
74
- }
75
-
76
- /**
77
- * Shared pattern for create commands:
78
- * requireClient → withSpinner('create_error') → if/else output
79
- */
80
- export async function runCreate<T>(
81
- config: {
82
- spinner: SpinnerMessages;
83
- sdkCall: SdkCall<T>;
84
- onInteractive: (data: T) => void;
85
- },
86
- globalOpts: GlobalOpts,
87
- ): Promise<void> {
88
- const resend = requireClient(globalOpts);
89
- const data = await withSpinner(
90
- config.spinner,
91
- () => config.sdkCall(resend),
92
- 'create_error',
93
- globalOpts,
94
- );
95
- if (!globalOpts.json && isInteractive()) {
96
- config.onInteractive(data);
97
- } else {
98
- outputResult(data, { json: globalOpts.json });
99
- }
100
- }
101
-
102
- /**
103
- * Shared pattern for write commands (update/verify/remove-segment) where
104
- * interactive output is a single status message:
105
- * requireClient → withSpinner(errorCode) → if/else output
106
- */
107
- export async function runWrite<T>(
108
- config: {
109
- spinner: SpinnerMessages;
110
- sdkCall: SdkCall<T>;
111
- errorCode: string;
112
- successMsg: string;
113
- },
114
- globalOpts: GlobalOpts,
115
- ): Promise<void> {
116
- const resend = requireClient(globalOpts);
117
- const data = await withSpinner(
118
- config.spinner,
119
- () => config.sdkCall(resend),
120
- config.errorCode,
121
- globalOpts,
122
- );
123
- if (!globalOpts.json && isInteractive()) {
124
- console.log(config.successMsg);
125
- } else {
126
- outputResult(data, { json: globalOpts.json });
127
- }
128
- }
129
-
130
- /**
131
- * Shared pattern for all list commands:
132
- * requireClient → withSpinner → if/else output
133
- *
134
- * Callers pass pagination opts (if any) via the sdkCall closure.
135
- * The onInteractive callback handles table rendering and pagination hints.
136
- */
137
- export async function runList<T>(
138
- config: {
139
- spinner: SpinnerMessages;
140
- sdkCall: SdkCall<T>;
141
- onInteractive: (result: T) => void;
142
- },
143
- globalOpts: GlobalOpts,
144
- ): Promise<void> {
145
- const resend = requireClient(globalOpts);
146
- const result = await withSpinner(
147
- config.spinner,
148
- () => config.sdkCall(resend),
149
- 'list_error',
150
- globalOpts,
151
- );
152
- if (!globalOpts.json && isInteractive()) {
153
- config.onInteractive(result);
154
- } else {
155
- outputResult(result, { json: globalOpts.json });
156
- }
157
- }