From 65987a378c3018223b8b172d98a8a9daf004304d Mon Sep 17 00:00:00 2001 From: Gabriel Miranda Date: Fri, 14 Aug 2026 11:48:13 -0300 Subject: [PATCH] feat(automations): duplicate endpoint Co-Authored-By: Claude Fable 5 --- src/Service/Automation.php | 14 ++++++++++++++ tests/Service/Automation.php | 12 ++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/Service/Automation.php b/src/Service/Automation.php index 0015b05..0ca0935 100644 --- a/src/Service/Automation.php +++ b/src/Service/Automation.php @@ -115,6 +115,20 @@ public function remove(string $automationId): \Resend\Automation return $this->createResource('automations', $result); } + /** + * Duplicate an existing automation. + * + * @see https://resend.com/docs/api-reference/automations/duplicate-automation + */ + public function duplicate(string $automationId): \Resend\Automation + { + $payload = Payload::create("automations/$automationId/duplicate", []); + + $result = $this->transporter->request($payload); + + return $this->createResource('automations', $result); + } + /** * Stop a running automation. * diff --git a/tests/Service/Automation.php b/tests/Service/Automation.php index 35351fd..5db4972 100644 --- a/tests/Service/Automation.php +++ b/tests/Service/Automation.php @@ -83,6 +83,18 @@ ->id->toBe('c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd'); }); +it('can duplicate an automation', function () { + $client = mockClient('POST', 'automations/c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd/duplicate', [], [], [ + 'object' => 'automation', + 'id' => 'e169aa45-1ecf-4183-9955-b1499d5701d3', + ]); + + $result = $client->automations->duplicate('c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd'); + + expect($result)->toBeInstanceOf(Automation::class) + ->id->toBe('e169aa45-1ecf-4183-9955-b1499d5701d3'); +}); + it('can stop an automation', function () { $client = mockClient('POST', 'automations/c9b16d4f-ba6c-4e2e-b044-6bf4404e57fd/stop', [], [], automation());