From 5ad58fd5a7acbeb620862270292254df44c5fcce Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Fri, 10 Jul 2026 20:58:15 +0000 Subject: [PATCH 1/3] test(batch): verify scheduled_at, tags, and attachments serialize in batch payloads Document batch email support for scheduled_at, tags, and attachments in Batch.send() javadoc. Add a serialization test to ensure these fields are included in the JSON payload sent to POST /emails/batch. Co-authored-by: cpenned --- .../java/com/resend/services/batch/Batch.java | 6 ++++++ .../com/resend/services/batch/BatchTest.java | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/main/java/com/resend/services/batch/Batch.java b/src/main/java/com/resend/services/batch/Batch.java index cdcf2df..0290364 100644 --- a/src/main/java/com/resend/services/batch/Batch.java +++ b/src/main/java/com/resend/services/batch/Batch.java @@ -33,6 +33,9 @@ public Batch(final String apiKey) { /** * Sends up to 100 batch emails. * + *

Each email supports the same options as single sends, including + * {@code scheduled_at}, {@code tags}, and {@code attachments}. + * * @param emails batch emails to send. * @return The emails ids. * @throws ResendException If an error occurs while sending batch emails. @@ -54,6 +57,9 @@ public CreateBatchEmailsResponse send(List emails) throws Re /** * Sends up to 100 batch emails. * + *

Each email supports the same options as single sends, including + * {@code scheduled_at}, {@code tags}, and {@code attachments}. + * * @param emails batch emails to send. * @param requestOptions The options with additional headers. * @return The emails ids. diff --git a/src/test/java/com/resend/services/batch/BatchTest.java b/src/test/java/com/resend/services/batch/BatchTest.java index 0ae1c22..cfffd3a 100644 --- a/src/test/java/com/resend/services/batch/BatchTest.java +++ b/src/test/java/com/resend/services/batch/BatchTest.java @@ -12,6 +12,7 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -50,6 +51,23 @@ public void tearDown() throws Exception { mocks.close(); } + @Test + public void testCreateBatchEmails_SerializesScheduledAtTagsAndAttachments() throws ResendException { + List batchEmailsRequest = EmailsUtil.createBatchEmailOptions(); + ArgumentCaptor payloadCaptor = ArgumentCaptor.forClass(String.class); + AbstractHttpResponse httpResponse = new AbstractHttpResponse<>(200, BATCH_RESPONSE_JSON, true); + + when(httpClient.perform(eq("/emails/batch"), anyString(), eq(HttpMethod.POST), payloadCaptor.capture(), any(MediaType.class))) + .thenReturn(httpResponse); + + batch.send(batchEmailsRequest); + + String payload = payloadCaptor.getValue(); + assertTrue(payload.contains("\"scheduled_at\":\"2024-08-20T11:52:01.858Z\"")); + assertTrue(payload.contains("\"tags\":[{\"name\":\"tagName\",\"value\":\"tagValue\"}]")); + assertTrue(payload.contains("\"attachments\":[{\"filename\":\"invoice.pdf\",\"content\":\"invoice.pdf\",\"content_type\":\"pdf\",\"content_id\":\"my-image\"}]")); + } + @Test public void testCreateBatchEmails_Success() throws ResendException { List batchEmailsRequest = EmailsUtil.createBatchEmailOptions(); From 00c0629e707eaccd21ecf1428274b8824c0608c0 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 13 Jul 2026 16:16:55 +0000 Subject: [PATCH 2/3] fix(batch): document tags-only support for batch emails Clarify that only tags are supported on batch emails. Attachments and scheduled_at remain unsupported. Update batch test fixtures and serialization test accordingly. Co-authored-by: cpenned --- .../java/com/resend/services/batch/Batch.java | 8 ++++---- .../java/com/resend/services/batch/BatchTest.java | 6 +++--- .../java/com/resend/services/util/EmailsUtil.java | 15 ++++++++++++++- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/resend/services/batch/Batch.java b/src/main/java/com/resend/services/batch/Batch.java index 0290364..21fb755 100644 --- a/src/main/java/com/resend/services/batch/Batch.java +++ b/src/main/java/com/resend/services/batch/Batch.java @@ -33,8 +33,8 @@ public Batch(final String apiKey) { /** * Sends up to 100 batch emails. * - *

Each email supports the same options as single sends, including - * {@code scheduled_at}, {@code tags}, and {@code attachments}. + *

Each email supports standard send options plus {@code tags}. + * {@code attachments} and {@code scheduled_at} are not supported for batch emails. * * @param emails batch emails to send. * @return The emails ids. @@ -57,8 +57,8 @@ public CreateBatchEmailsResponse send(List emails) throws Re /** * Sends up to 100 batch emails. * - *

Each email supports the same options as single sends, including - * {@code scheduled_at}, {@code tags}, and {@code attachments}. + *

Each email supports standard send options plus {@code tags}. + * {@code attachments} and {@code scheduled_at} are not supported for batch emails. * * @param emails batch emails to send. * @param requestOptions The options with additional headers. diff --git a/src/test/java/com/resend/services/batch/BatchTest.java b/src/test/java/com/resend/services/batch/BatchTest.java index cfffd3a..227724d 100644 --- a/src/test/java/com/resend/services/batch/BatchTest.java +++ b/src/test/java/com/resend/services/batch/BatchTest.java @@ -52,7 +52,7 @@ public void tearDown() throws Exception { } @Test - public void testCreateBatchEmails_SerializesScheduledAtTagsAndAttachments() throws ResendException { + public void testCreateBatchEmails_SerializesTags() throws ResendException { List batchEmailsRequest = EmailsUtil.createBatchEmailOptions(); ArgumentCaptor payloadCaptor = ArgumentCaptor.forClass(String.class); AbstractHttpResponse httpResponse = new AbstractHttpResponse<>(200, BATCH_RESPONSE_JSON, true); @@ -63,9 +63,9 @@ public void testCreateBatchEmails_SerializesScheduledAtTagsAndAttachments() thro batch.send(batchEmailsRequest); String payload = payloadCaptor.getValue(); - assertTrue(payload.contains("\"scheduled_at\":\"2024-08-20T11:52:01.858Z\"")); assertTrue(payload.contains("\"tags\":[{\"name\":\"tagName\",\"value\":\"tagValue\"}]")); - assertTrue(payload.contains("\"attachments\":[{\"filename\":\"invoice.pdf\",\"content\":\"invoice.pdf\",\"content_type\":\"pdf\",\"content_id\":\"my-image\"}]")); + assertFalse(payload.contains("attachments")); + assertFalse(payload.contains("scheduled_at")); } @Test diff --git a/src/test/java/com/resend/services/util/EmailsUtil.java b/src/test/java/com/resend/services/util/EmailsUtil.java index efaadc1..9e8e432 100644 --- a/src/test/java/com/resend/services/util/EmailsUtil.java +++ b/src/test/java/com/resend/services/util/EmailsUtil.java @@ -99,8 +99,21 @@ public static CancelEmailResponse cancelEmailResponse() { return new CancelEmailResponse("123", "emails"); } + public static CreateEmailOptions createBatchEmailOption() { + return CreateEmailOptions.builder() + .from("Acme ") + .to(Arrays.asList("example@resend.dev")) + .cc(Arrays.asList("example@resend.dev")) + .bcc(Arrays.asList("example@resend.dev")) + .replyTo(Arrays.asList("example@resend.dev", "example@resend.dev")) + .text("Hello, this is a batch email.") + .subject("Test batch email with tags") + .tags(Arrays.asList(createTag())) + .build(); + } + public static List createBatchEmailOptions() { - return Arrays.asList(createEmailOptions(), createEmailOptions()); + return Arrays.asList(createBatchEmailOption(), createBatchEmailOption()); } public static CreateBatchEmailsResponse createBatchEmailsResponse() { From 112250fd6a687bf5720331238c5317bd7367b27e Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 15 Jul 2026 03:32:23 +0000 Subject: [PATCH 3/3] docs(batch): remove attachment references from batch tags PR Co-authored-by: cpenned --- src/main/java/com/resend/services/batch/Batch.java | 2 -- src/test/java/com/resend/services/batch/BatchTest.java | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/main/java/com/resend/services/batch/Batch.java b/src/main/java/com/resend/services/batch/Batch.java index 21fb755..b2c1457 100644 --- a/src/main/java/com/resend/services/batch/Batch.java +++ b/src/main/java/com/resend/services/batch/Batch.java @@ -34,7 +34,6 @@ public Batch(final String apiKey) { * Sends up to 100 batch emails. * *

Each email supports standard send options plus {@code tags}. - * {@code attachments} and {@code scheduled_at} are not supported for batch emails. * * @param emails batch emails to send. * @return The emails ids. @@ -58,7 +57,6 @@ public CreateBatchEmailsResponse send(List emails) throws Re * Sends up to 100 batch emails. * *

Each email supports standard send options plus {@code tags}. - * {@code attachments} and {@code scheduled_at} are not supported for batch emails. * * @param emails batch emails to send. * @param requestOptions The options with additional headers. diff --git a/src/test/java/com/resend/services/batch/BatchTest.java b/src/test/java/com/resend/services/batch/BatchTest.java index 227724d..3b9c147 100644 --- a/src/test/java/com/resend/services/batch/BatchTest.java +++ b/src/test/java/com/resend/services/batch/BatchTest.java @@ -64,8 +64,6 @@ public void testCreateBatchEmails_SerializesTags() throws ResendException { String payload = payloadCaptor.getValue(); assertTrue(payload.contains("\"tags\":[{\"name\":\"tagName\",\"value\":\"tagValue\"}]")); - assertFalse(payload.contains("attachments")); - assertFalse(payload.contains("scheduled_at")); } @Test