From 6ebe83f1e35c0f0245a42d44364e8cfaae128a62 Mon Sep 17 00:00:00 2001 From: Gabriel Miranda Date: Thu, 13 Aug 2026 17:10:20 -0300 Subject: [PATCH 1/3] feat(automations): endpoint to duplicate Signed-off-by: Gabriel Miranda --- src/automations/automations.spec.ts | 40 +++++++++++++++++++ src/automations/automations.ts | 11 +++++ .../duplicate-automation.interface.ts | 10 +++++ src/automations/interfaces/index.ts | 1 + 4 files changed, 62 insertions(+) create mode 100644 src/automations/interfaces/duplicate-automation.interface.ts diff --git a/src/automations/automations.spec.ts b/src/automations/automations.spec.ts index 553558cf..a6137abe 100644 --- a/src/automations/automations.spec.ts +++ b/src/automations/automations.spec.ts @@ -9,6 +9,7 @@ import type { import type { GetAutomationResponseSuccess } from './interfaces/get-automation.interface'; import type { ListAutomationsResponseSuccess } from './interfaces/list-automation.interface'; import type { RemoveAutomationResponseSuccess } from './interfaces/remove-automation.interface'; +import type { DuplicateAutomationResponseSuccess } from './interfaces/duplicate-automation.interface'; import type { StopAutomationResponseSuccess } from './interfaces/stop-automation.interface'; import type { UpdateAutomationResponseSuccess } from './interfaces/update-automation.interface'; @@ -529,6 +530,45 @@ describe('update', () => { }); }); +describe('duplicate', () => { + it('duplicates an automation', async () => { + const id = '71cdfe68-cf79-473a-a9d7-21f91db6a526'; + const response: DuplicateAutomationResponseSuccess = { + object: 'automation', + id: 'e169aa45-1ecf-4183-9955-b1499d5701d3', + }; + + fetchMock.mockOnce(JSON.stringify(response), { + status: 200, + headers: { + 'content-type': 'application/json', + }, + }); + + const data = await resend.automations.duplicate(id); + expect(data).toMatchInlineSnapshot(` + { + "data": { + "id": "e169aa45-1ecf-4183-9955-b1499d5701d3", + "object": "automation", + }, + "error": null, + "headers": { + "content-type": "application/json", + }, + } + `); + + expect(fetchMock).toHaveBeenCalledWith( + `https://api.resend.com/automations/${id}/duplicate`, + expect.objectContaining({ + method: 'POST', + headers: expect.any(Headers), + }), + ); + }); +}); + describe('stop', () => { it('stops an automation', async () => { const id = '71cdfe68-cf79-473a-a9d7-21f91db6a526'; diff --git a/src/automations/automations.ts b/src/automations/automations.ts index 159a9d65..c6b3e411 100644 --- a/src/automations/automations.ts +++ b/src/automations/automations.ts @@ -11,6 +11,10 @@ import type { CreateAutomationResponse, CreateAutomationResponseSuccess, } from './interfaces/create-automation-options.interface'; +import type { + DuplicateAutomationResponse, + DuplicateAutomationResponseSuccess, +} from './interfaces/duplicate-automation.interface'; import type { GetAutomationResponse, GetAutomationResponseSuccess, @@ -109,6 +113,13 @@ export class Automations { return data; } + async duplicate(id: string): Promise { + const data = await this.resend.post( + `/automations/${id}/duplicate`, + ); + return data; + } + async stop(id: string): Promise { const data = await this.resend.post( `/automations/${id}/stop`, diff --git a/src/automations/interfaces/duplicate-automation.interface.ts b/src/automations/interfaces/duplicate-automation.interface.ts new file mode 100644 index 00000000..02523808 --- /dev/null +++ b/src/automations/interfaces/duplicate-automation.interface.ts @@ -0,0 +1,10 @@ +import type { Response } from '../../interfaces'; +import type { Automation } from './automation'; + +export interface DuplicateAutomationResponseSuccess + extends Pick { + object: 'automation'; +} + +export type DuplicateAutomationResponse = + Response; diff --git a/src/automations/interfaces/index.ts b/src/automations/interfaces/index.ts index bcee0eb7..002122a9 100644 --- a/src/automations/interfaces/index.ts +++ b/src/automations/interfaces/index.ts @@ -1,6 +1,7 @@ export * from './automation'; export * from './automation-step.interface'; export * from './create-automation-options.interface'; +export * from './duplicate-automation.interface'; export * from './get-automation.interface'; export * from './list-automation.interface'; export * from './remove-automation.interface'; From f04632a387e966609e52e350fec6a0b1d22e7148 Mon Sep 17 00:00:00 2001 From: Gabriel Miranda Date: Thu, 13 Aug 2026 17:12:04 -0300 Subject: [PATCH 2/3] bump to 6.20.0 Signed-off-by: Gabriel Miranda --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4fa298df..e5b43354 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "resend", - "version": "6.19.0", + "version": "6.20.0", "description": "Node.js library for the Resend API", "main": "./dist/index.cjs", "module": "./dist/index.mjs", From e23bd5e52b69acd91ed6e2ce57ce0b71213442f2 Mon Sep 17 00:00:00 2001 From: Gabriel Miranda Date: Thu, 13 Aug 2026 17:13:14 -0300 Subject: [PATCH 3/3] lint Signed-off-by: Gabriel Miranda --- src/automations/automations.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/automations/automations.spec.ts b/src/automations/automations.spec.ts index a6137abe..bf45ddf5 100644 --- a/src/automations/automations.spec.ts +++ b/src/automations/automations.spec.ts @@ -6,10 +6,10 @@ import type { CreateAutomationOptions, CreateAutomationResponseSuccess, } from './interfaces/create-automation-options.interface'; +import type { DuplicateAutomationResponseSuccess } from './interfaces/duplicate-automation.interface'; import type { GetAutomationResponseSuccess } from './interfaces/get-automation.interface'; import type { ListAutomationsResponseSuccess } from './interfaces/list-automation.interface'; import type { RemoveAutomationResponseSuccess } from './interfaces/remove-automation.interface'; -import type { DuplicateAutomationResponseSuccess } from './interfaces/duplicate-automation.interface'; import type { StopAutomationResponseSuccess } from './interfaces/stop-automation.interface'; import type { UpdateAutomationResponseSuccess } from './interfaces/update-automation.interface';