resend-cli 1.2.2 → 1.3.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 (182) hide show
  1. package/README.md +25 -10
  2. package/dist/cli.cjs +539 -0
  3. package/package.json +31 -12
  4. package/.claude/settings.local.json +0 -5
  5. package/.github/scripts/pr-title-check.js +0 -34
  6. package/.github/workflows/ci.yml +0 -32
  7. package/.github/workflows/pr-title-check.yml +0 -13
  8. package/.github/workflows/release.yml +0 -120
  9. package/.github/workflows/test-install-windows.yml +0 -48
  10. package/CHANGELOG.md +0 -31
  11. package/biome.json +0 -36
  12. package/bun.lock +0 -73
  13. package/bunfig.toml +0 -2
  14. package/docs/agent-dx-gaps.md +0 -167
  15. package/docs/missing-commands.md +0 -58
  16. package/docs/production-readiness.md +0 -99
  17. package/docs/secure-key-storage.md +0 -174
  18. package/install.ps1 +0 -141
  19. package/install.sh +0 -301
  20. package/renovate.json +0 -4
  21. package/src/cli.ts +0 -92
  22. package/src/commands/api-keys/create.ts +0 -114
  23. package/src/commands/api-keys/delete.ts +0 -47
  24. package/src/commands/api-keys/index.ts +0 -26
  25. package/src/commands/api-keys/list.ts +0 -35
  26. package/src/commands/api-keys/utils.ts +0 -8
  27. package/src/commands/auth/index.ts +0 -20
  28. package/src/commands/auth/login.ts +0 -234
  29. package/src/commands/auth/logout.ts +0 -105
  30. package/src/commands/broadcasts/create.ts +0 -196
  31. package/src/commands/broadcasts/delete.ts +0 -46
  32. package/src/commands/broadcasts/get.ts +0 -59
  33. package/src/commands/broadcasts/index.ts +0 -43
  34. package/src/commands/broadcasts/list.ts +0 -60
  35. package/src/commands/broadcasts/send.ts +0 -56
  36. package/src/commands/broadcasts/update.ts +0 -95
  37. package/src/commands/broadcasts/utils.ts +0 -35
  38. package/src/commands/contact-properties/create.ts +0 -118
  39. package/src/commands/contact-properties/delete.ts +0 -48
  40. package/src/commands/contact-properties/get.ts +0 -46
  41. package/src/commands/contact-properties/index.ts +0 -48
  42. package/src/commands/contact-properties/list.ts +0 -68
  43. package/src/commands/contact-properties/update.ts +0 -88
  44. package/src/commands/contact-properties/utils.ts +0 -17
  45. package/src/commands/contacts/add-segment.ts +0 -78
  46. package/src/commands/contacts/create.ts +0 -122
  47. package/src/commands/contacts/delete.ts +0 -49
  48. package/src/commands/contacts/get.ts +0 -53
  49. package/src/commands/contacts/index.ts +0 -58
  50. package/src/commands/contacts/list.ts +0 -57
  51. package/src/commands/contacts/remove-segment.ts +0 -48
  52. package/src/commands/contacts/segments.ts +0 -39
  53. package/src/commands/contacts/topics.ts +0 -45
  54. package/src/commands/contacts/update-topics.ts +0 -90
  55. package/src/commands/contacts/update.ts +0 -77
  56. package/src/commands/contacts/utils.ts +0 -119
  57. package/src/commands/doctor.ts +0 -216
  58. package/src/commands/domains/create.ts +0 -83
  59. package/src/commands/domains/delete.ts +0 -42
  60. package/src/commands/domains/get.ts +0 -47
  61. package/src/commands/domains/index.ts +0 -35
  62. package/src/commands/domains/list.ts +0 -53
  63. package/src/commands/domains/update.ts +0 -75
  64. package/src/commands/domains/utils.ts +0 -44
  65. package/src/commands/domains/verify.ts +0 -38
  66. package/src/commands/emails/batch.ts +0 -140
  67. package/src/commands/emails/index.ts +0 -24
  68. package/src/commands/emails/receiving/attachment.ts +0 -55
  69. package/src/commands/emails/receiving/attachments.ts +0 -68
  70. package/src/commands/emails/receiving/get.ts +0 -58
  71. package/src/commands/emails/receiving/index.ts +0 -28
  72. package/src/commands/emails/receiving/list.ts +0 -59
  73. package/src/commands/emails/receiving/utils.ts +0 -38
  74. package/src/commands/emails/send.ts +0 -189
  75. package/src/commands/open.ts +0 -24
  76. package/src/commands/segments/create.ts +0 -50
  77. package/src/commands/segments/delete.ts +0 -47
  78. package/src/commands/segments/get.ts +0 -38
  79. package/src/commands/segments/index.ts +0 -36
  80. package/src/commands/segments/list.ts +0 -58
  81. package/src/commands/segments/utils.ts +0 -7
  82. package/src/commands/teams/index.ts +0 -10
  83. package/src/commands/teams/list.ts +0 -35
  84. package/src/commands/teams/remove.ts +0 -86
  85. package/src/commands/teams/switch.ts +0 -76
  86. package/src/commands/topics/create.ts +0 -73
  87. package/src/commands/topics/delete.ts +0 -47
  88. package/src/commands/topics/get.ts +0 -42
  89. package/src/commands/topics/index.ts +0 -42
  90. package/src/commands/topics/list.ts +0 -34
  91. package/src/commands/topics/update.ts +0 -59
  92. package/src/commands/topics/utils.ts +0 -16
  93. package/src/commands/webhooks/create.ts +0 -128
  94. package/src/commands/webhooks/delete.ts +0 -49
  95. package/src/commands/webhooks/get.ts +0 -42
  96. package/src/commands/webhooks/index.ts +0 -44
  97. package/src/commands/webhooks/list.ts +0 -55
  98. package/src/commands/webhooks/update.ts +0 -83
  99. package/src/commands/webhooks/utils.ts +0 -36
  100. package/src/commands/whoami.ts +0 -71
  101. package/src/lib/actions.ts +0 -157
  102. package/src/lib/client.ts +0 -37
  103. package/src/lib/config.ts +0 -217
  104. package/src/lib/files.ts +0 -15
  105. package/src/lib/help-text.ts +0 -38
  106. package/src/lib/output.ts +0 -54
  107. package/src/lib/pagination.ts +0 -36
  108. package/src/lib/prompts.ts +0 -149
  109. package/src/lib/spinner.ts +0 -100
  110. package/src/lib/table.ts +0 -57
  111. package/src/lib/tty.ts +0 -28
  112. package/src/lib/update-check.ts +0 -172
  113. package/src/lib/version.ts +0 -4
  114. package/tests/commands/api-keys/create.test.ts +0 -195
  115. package/tests/commands/api-keys/delete.test.ts +0 -156
  116. package/tests/commands/api-keys/list.test.ts +0 -133
  117. package/tests/commands/auth/login.test.ts +0 -156
  118. package/tests/commands/auth/logout.test.ts +0 -146
  119. package/tests/commands/broadcasts/create.test.ts +0 -447
  120. package/tests/commands/broadcasts/delete.test.ts +0 -182
  121. package/tests/commands/broadcasts/get.test.ts +0 -146
  122. package/tests/commands/broadcasts/list.test.ts +0 -196
  123. package/tests/commands/broadcasts/send.test.ts +0 -161
  124. package/tests/commands/broadcasts/update.test.ts +0 -283
  125. package/tests/commands/contact-properties/create.test.ts +0 -250
  126. package/tests/commands/contact-properties/delete.test.ts +0 -183
  127. package/tests/commands/contact-properties/get.test.ts +0 -144
  128. package/tests/commands/contact-properties/list.test.ts +0 -180
  129. package/tests/commands/contact-properties/update.test.ts +0 -216
  130. package/tests/commands/contacts/add-segment.test.ts +0 -188
  131. package/tests/commands/contacts/create.test.ts +0 -270
  132. package/tests/commands/contacts/delete.test.ts +0 -192
  133. package/tests/commands/contacts/get.test.ts +0 -148
  134. package/tests/commands/contacts/list.test.ts +0 -175
  135. package/tests/commands/contacts/remove-segment.test.ts +0 -166
  136. package/tests/commands/contacts/segments.test.ts +0 -167
  137. package/tests/commands/contacts/topics.test.ts +0 -163
  138. package/tests/commands/contacts/update-topics.test.ts +0 -247
  139. package/tests/commands/contacts/update.test.ts +0 -205
  140. package/tests/commands/doctor.test.ts +0 -165
  141. package/tests/commands/domains/create.test.ts +0 -192
  142. package/tests/commands/domains/delete.test.ts +0 -156
  143. package/tests/commands/domains/get.test.ts +0 -137
  144. package/tests/commands/domains/list.test.ts +0 -164
  145. package/tests/commands/domains/update.test.ts +0 -223
  146. package/tests/commands/domains/verify.test.ts +0 -117
  147. package/tests/commands/emails/batch.test.ts +0 -313
  148. package/tests/commands/emails/receiving/attachment.test.ts +0 -140
  149. package/tests/commands/emails/receiving/attachments.test.ts +0 -168
  150. package/tests/commands/emails/receiving/get.test.ts +0 -140
  151. package/tests/commands/emails/receiving/list.test.ts +0 -181
  152. package/tests/commands/emails/send.test.ts +0 -309
  153. package/tests/commands/segments/create.test.ts +0 -163
  154. package/tests/commands/segments/delete.test.ts +0 -182
  155. package/tests/commands/segments/get.test.ts +0 -137
  156. package/tests/commands/segments/list.test.ts +0 -173
  157. package/tests/commands/teams/list.test.ts +0 -63
  158. package/tests/commands/teams/remove.test.ts +0 -103
  159. package/tests/commands/teams/switch.test.ts +0 -96
  160. package/tests/commands/topics/create.test.ts +0 -191
  161. package/tests/commands/topics/delete.test.ts +0 -156
  162. package/tests/commands/topics/get.test.ts +0 -125
  163. package/tests/commands/topics/list.test.ts +0 -124
  164. package/tests/commands/topics/update.test.ts +0 -177
  165. package/tests/commands/webhooks/create.test.ts +0 -224
  166. package/tests/commands/webhooks/delete.test.ts +0 -156
  167. package/tests/commands/webhooks/get.test.ts +0 -125
  168. package/tests/commands/webhooks/list.test.ts +0 -177
  169. package/tests/commands/webhooks/update.test.ts +0 -206
  170. package/tests/commands/whoami.test.ts +0 -99
  171. package/tests/helpers.ts +0 -93
  172. package/tests/lib/client.test.ts +0 -71
  173. package/tests/lib/config.test.ts +0 -445
  174. package/tests/lib/files.test.ts +0 -65
  175. package/tests/lib/help-text.test.ts +0 -97
  176. package/tests/lib/output.test.ts +0 -127
  177. package/tests/lib/prompts.test.ts +0 -178
  178. package/tests/lib/spinner.test.ts +0 -146
  179. package/tests/lib/table.test.ts +0 -63
  180. package/tests/lib/tty.test.ts +0 -85
  181. package/tests/lib/update-check.test.ts +0 -169
  182. package/tsconfig.json +0 -14
@@ -1,73 +0,0 @@
1
- import { Command, Option } from '@commander-js/extra-typings';
2
- import { runCreate } from '../../lib/actions';
3
- import type { GlobalOpts } from '../../lib/client';
4
- import { buildHelpText } from '../../lib/help-text';
5
- import { requireText } from '../../lib/prompts';
6
-
7
- export const createTopicCommand = new Command('create')
8
- .description('Create a new topic for subscription management')
9
- .option('--name <name>', 'Topic name (required)')
10
- .option(
11
- '--description <description>',
12
- 'Description shown to contacts when managing subscriptions',
13
- )
14
- .addOption(
15
- new Option(
16
- '--default-subscription <mode>',
17
- 'Default subscription state for contacts',
18
- )
19
- .choices(['opt_in', 'opt_out'] as const)
20
- .default('opt_in' as const),
21
- )
22
- .addHelpText(
23
- 'after',
24
- buildHelpText({
25
- context: `Topics enable fine-grained subscription management. Contacts can opt in or out of
26
- individual topics. Broadcasts can target only contacts opted into a specific topic.
27
-
28
- Example topics: "Product Updates", "Security Alerts", "Weekly Digest".
29
-
30
- --default-subscription controls what happens for contacts with no explicit subscription:
31
- opt_in Contacts receive broadcasts unless they explicitly opt out (default)
32
- opt_out Contacts do NOT receive broadcasts unless they explicitly opt in
33
-
34
- Non-interactive: --name is required.`,
35
- output: ` {"id":"<uuid>"}`,
36
- errorCodes: ['auth_error', 'missing_name', 'create_error'],
37
- examples: [
38
- 'resend topics create --name "Product Updates"',
39
- 'resend topics create --name "Weekly Digest" --default-subscription opt_out',
40
- 'resend topics create --name "Security Alerts" --description "Critical security notices" --json',
41
- ],
42
- }),
43
- )
44
- .action(async (opts, cmd) => {
45
- const globalOpts = cmd.optsWithGlobals() as GlobalOpts;
46
-
47
- const name = await requireText(
48
- opts.name,
49
- { message: 'Topic name', placeholder: 'Product Updates' },
50
- { message: 'Missing --name flag.', code: 'missing_name' },
51
- globalOpts,
52
- );
53
-
54
- await runCreate(
55
- {
56
- spinner: {
57
- loading: 'Creating topic...',
58
- success: 'Topic created',
59
- fail: 'Failed to create topic',
60
- },
61
- sdkCall: (resend) =>
62
- resend.topics.create({
63
- name,
64
- defaultSubscription: opts.defaultSubscription,
65
- ...(opts.description && { description: opts.description }),
66
- }),
67
- onInteractive: (data) => {
68
- console.log(`\nTopic created: ${data.id}`);
69
- },
70
- },
71
- globalOpts,
72
- );
73
- });
@@ -1,47 +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 deleteTopicCommand = new Command('delete')
7
- .alias('rm')
8
- .description('Delete a topic')
9
- .argument('<id>', 'Topic 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 topic removes all contact subscriptions to that topic and may affect
18
- broadcasts that reference this topic_id. Contacts themselves are not deleted.
19
-
20
- Non-interactive: --yes is required to confirm deletion when stdin/stdout is not a TTY.`,
21
- output: ` {"object":"topic","id":"<uuid>","deleted":true}`,
22
- errorCodes: ['auth_error', 'confirmation_required', 'delete_error'],
23
- examples: [
24
- 'resend topics delete 78261eea-8f8b-4381-83c6-79fa7120f1cf --yes',
25
- 'resend topics delete 78261eea-8f8b-4381-83c6-79fa7120f1cf --yes --json',
26
- ],
27
- }),
28
- )
29
- .action(async (id, opts, cmd) => {
30
- const globalOpts = cmd.optsWithGlobals() as GlobalOpts;
31
- await runDelete(
32
- id,
33
- !!opts.yes,
34
- {
35
- confirmMessage: `Delete topic ${id}?\nAll contact subscriptions and broadcast associations will be removed.`,
36
- spinner: {
37
- loading: 'Deleting topic...',
38
- success: 'Topic deleted',
39
- fail: 'Failed to delete topic',
40
- },
41
- object: 'topic',
42
- successMsg: 'Topic deleted.',
43
- sdkCall: (resend) => resend.topics.remove(id),
44
- },
45
- globalOpts,
46
- );
47
- });
@@ -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 getTopicCommand = new Command('get')
7
- .description('Retrieve a topic by ID')
8
- .argument('<id>', 'Topic UUID')
9
- .addHelpText(
10
- 'after',
11
- buildHelpText({
12
- output: ` {"id":"<uuid>","name":"<name>","description":"<desc>","default_subscription":"opt_in|opt_out","created_at":"<iso-date>"}`,
13
- errorCodes: ['auth_error', 'fetch_error'],
14
- examples: [
15
- 'resend topics get 78261eea-8f8b-4381-83c6-79fa7120f1cf',
16
- 'resend topics get 78261eea-8f8b-4381-83c6-79fa7120f1cf --json',
17
- ],
18
- }),
19
- )
20
- .action(async (id, _opts, cmd) => {
21
- const globalOpts = cmd.optsWithGlobals() as GlobalOpts;
22
- await runGet(
23
- {
24
- spinner: {
25
- loading: 'Fetching topic...',
26
- success: 'Topic fetched',
27
- fail: 'Failed to fetch topic',
28
- },
29
- sdkCall: (resend) => resend.topics.get(id),
30
- onInteractive: (data) => {
31
- console.log(`\n${data.name}`);
32
- console.log(`ID: ${data.id}`);
33
- if (data.description) {
34
- console.log(`Description: ${data.description}`);
35
- }
36
- console.log(`Default subscription: ${data.default_subscription}`);
37
- console.log(`Created: ${data.created_at}`);
38
- },
39
- },
40
- globalOpts,
41
- );
42
- });
@@ -1,42 +0,0 @@
1
- import { Command } from '@commander-js/extra-typings';
2
- import { buildHelpText } from '../../lib/help-text';
3
- import { createTopicCommand } from './create';
4
- import { deleteTopicCommand } from './delete';
5
- import { getTopicCommand } from './get';
6
- import { listTopicsCommand } from './list';
7
- import { updateTopicCommand } from './update';
8
-
9
- export const topicsCommand = new Command('topics')
10
- .description('Manage topics for contact subscription preferences')
11
- .addHelpText(
12
- 'after',
13
- buildHelpText({
14
- context: `Topics enable fine-grained subscription management beyond the global unsubscribe flag.
15
- A contact can opt in or out of individual topics independently.
16
-
17
- Broadcasts can target a topic_id so only contacts who have opted into that topic
18
- receive the email. Contacts with no subscription record use the topic's
19
- default_subscription setting.
20
-
21
- Subscription states:
22
- opt_in Contact will receive broadcasts for this topic
23
- opt_out Contact will NOT receive broadcasts for this topic
24
-
25
- Contact topic subscriptions are managed via the contacts namespace:
26
- resend contacts topics <contactId>
27
- resend contacts update-topics <contactId> --topic-id <id> --subscription opt_in`,
28
- examples: [
29
- 'resend topics list',
30
- 'resend topics create --name "Product Updates"',
31
- 'resend topics create --name "Weekly Digest" --default-subscription opt_out',
32
- 'resend topics get 78261eea-8f8b-4381-83c6-79fa7120f1cf',
33
- 'resend topics update 78261eea-8f8b-4381-83c6-79fa7120f1cf --name "Security Alerts"',
34
- 'resend topics delete 78261eea-8f8b-4381-83c6-79fa7120f1cf --yes',
35
- ],
36
- }),
37
- )
38
- .addCommand(createTopicCommand)
39
- .addCommand(getTopicCommand)
40
- .addCommand(listTopicsCommand, { isDefault: true })
41
- .addCommand(updateTopicCommand)
42
- .addCommand(deleteTopicCommand);
@@ -1,34 +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 { renderTopicsTable } from './utils';
6
-
7
- export const listTopicsCommand = new Command('list')
8
- .alias('ls')
9
- .description('List all topics')
10
- .addHelpText(
11
- 'after',
12
- buildHelpText({
13
- context: `Returns all topics in your account. Topic subscription management for individual
14
- contacts is handled via "resend contacts topics <contactId>".`,
15
- output: ` {"data":[{"id":"<uuid>","name":"<name>","description":"<desc>","default_subscription":"opt_in|opt_out","created_at":"<iso-date>"}]}`,
16
- errorCodes: ['auth_error', 'list_error'],
17
- examples: ['resend topics list', 'resend topics list --json'],
18
- }),
19
- )
20
- .action(async (_opts, cmd) => {
21
- const globalOpts = cmd.optsWithGlobals() as GlobalOpts;
22
- await runList(
23
- {
24
- spinner: {
25
- loading: 'Fetching topics...',
26
- success: 'Topics fetched',
27
- fail: 'Failed to list topics',
28
- },
29
- sdkCall: (resend) => resend.topics.list(),
30
- onInteractive: (list) => console.log(renderTopicsTable(list.data)),
31
- },
32
- globalOpts,
33
- );
34
- });
@@ -1,59 +0,0 @@
1
- import { Command } from '@commander-js/extra-typings';
2
- import { runWrite } from '../../lib/actions';
3
- import type { GlobalOpts } from '../../lib/client';
4
- import { buildHelpText } from '../../lib/help-text';
5
- import { outputError } from '../../lib/output';
6
-
7
- export const updateTopicCommand = new Command('update')
8
- .description("Update a topic's name or description")
9
- .argument('<id>', 'Topic UUID')
10
- .option('--name <name>', 'New topic name')
11
- .option('--description <description>', 'New description shown to contacts')
12
- .addHelpText(
13
- 'after',
14
- buildHelpText({
15
- context: `At least one of --name or --description must be provided to update the topic.
16
-
17
- Note: --default-subscription cannot be changed after creation.
18
- To change the default subscription, delete the topic and recreate it.`,
19
- output: ` {"id":"<uuid>"}`,
20
- errorCodes: ['auth_error', 'no_changes', 'update_error'],
21
- examples: [
22
- 'resend topics update 78261eea-8f8b-4381-83c6-79fa7120f1cf --name "Security Alerts"',
23
- 'resend topics update 78261eea-8f8b-4381-83c6-79fa7120f1cf --description "Critical notices" --json',
24
- ],
25
- }),
26
- )
27
- .action(async (id, opts, cmd) => {
28
- const globalOpts = cmd.optsWithGlobals() as GlobalOpts;
29
-
30
- if (!opts.name && !opts.description) {
31
- outputError(
32
- {
33
- message:
34
- 'Provide at least one option to update: --name or --description.',
35
- code: 'no_changes',
36
- },
37
- { json: globalOpts.json },
38
- );
39
- }
40
-
41
- await runWrite(
42
- {
43
- spinner: {
44
- loading: 'Updating topic...',
45
- success: 'Topic updated',
46
- fail: 'Failed to update topic',
47
- },
48
- sdkCall: (resend) =>
49
- resend.topics.update({
50
- id,
51
- ...(opts.name && { name: opts.name }),
52
- ...(opts.description && { description: opts.description }),
53
- }),
54
- errorCode: 'update_error',
55
- successMsg: `Topic updated: ${id}`,
56
- },
57
- globalOpts,
58
- );
59
- });
@@ -1,16 +0,0 @@
1
- import type { Topic } from 'resend';
2
- import { renderTable } from '../../lib/table';
3
-
4
- export function renderTopicsTable(topics: Topic[]): string {
5
- const rows = topics.map((t) => [
6
- t.name,
7
- t.description ?? '',
8
- t.id,
9
- t.created_at,
10
- ]);
11
- return renderTable(
12
- ['Name', 'Description', 'ID', 'Created'],
13
- rows,
14
- '(no topics)',
15
- );
16
- }
@@ -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
- });