feat(broadcasts): add duplicate()

Merged
GA
1mo ago
+59-1

Adds resend.broadcasts.duplicate(id), a POST to /broadcasts/{id}/duplicate that returns the new draft's { object: 'broadcast', id }, the contract in resend/resend-openapi#115. Production already serves the route (resend/resend-monorepo#9608 merged on 2026-09-02). This release is 6.28.0; the CLI, OSS MCP, and remote MCP PRs in DEV-2089 pin it.

Claude ran the built dist against staging (duplicated a draft, read the copy back, removed it), then probed production with an unknown id and an unknown path to show the route is live there.

dup-node.mjs
import { Resend } from './dist/index.mjs';
const resend = new Resend(process.env.RESEND_API_KEY);
const source = 'e6bd3843-3cc7-4c0d-b7fd-e01cbb514a16';
const dup = await resend.broadcasts.duplicate(source);
console.log('duplicate:', JSON.stringify(dup.data), dup.error);
const copy = await resend.broadcasts.get(dup.data.id);
console.log('copy:', JSON.stringify({ id: copy.data.id, name: copy.data.name, status: copy.data.status }));
const removed = await resend.broadcasts.remove(dup.data.id);
console.log('removed:', JSON.stringify(removed.data));
duplicate: {"object":"broadcast","id":"b1a06415-1e88-428c-a64f-bc7f6f5ed0df"} null
copy: {"id":"b1a06415-1e88-428c-a64f-bc7f6f5ed0df","name":"Untitled (copy)","status":"draft"}
removed: {"object":"broadcast","id":"b1a06415-1e88-428c-a64f-bc7f6f5ed0df","deleted":true}
$ http POST https://api.resend.com/broadcasts/00000000-0000-0000-0000-000000000000/duplicate "Authorization: Bearer <redacted>"
{"statusCode":404,"message":"Broadcast not found","name":"not_found"}
$ http POST https://api.resend.com/broadcasts/00000000-0000-0000-0000-000000000000/does-not-exist "Authorization: Bearer <redacted>"
{"statusCode":405,"message":"Method POST is not allowed for the requested path.","name":"method_not_allowed"}

🤖 Generated with Claude Code


Summary by cubic

Adds resend.broadcasts.duplicate(id), calling POST /broadcasts/{id}/duplicate and returning the new draft's { object, id }. The production route already exists, so this only ships the Node SDK method and bumps the package to 6.28.0 for the CLI and MCP releases that depend on it.

  • Adds the DuplicateBroadcastResponse interface and exports it.
  • Covers the new method with a unit test asserting the request URL, method, and response shape.