Skip to content

Conversation

gabrielmfern
Copy link
Member

@gabrielmfern gabrielmfern commented Aug 27, 2025

this is a stacked change on #599. The idea for this is that users can pass in if they want then permissive or strict validation on an option, so the usage would be like:

const response = resend.batch.send(..., { batchValidation: 'permissive' });

// Should always be an array, even if empty.
console.log(response.data.errors)

This options also allows us to use typescript's inference on type parameters to automatically change the return type to not have the errors when batchValidation is 'strict'.


Summary by cubic

Adds a batchValidation option to Batch.send/create that sets the x-batch-validation header automatically. Responses are now type-safe: errors are only present when using permissive mode.

  • New Features

    • Add CreateBatchRequestOptions.batchValidation ('strict' | 'permissive', default 'strict').
    • Automatically sets x-batch-validation header based on the option.
    • Generic response typing: errors are available only in permissive mode; no client-side stripping.
  • Migration

    • Use { batchValidation: 'permissive' } to get partial failures with an errors[] array. Default behavior stays strict.

@gabrielmfern gabrielmfern self-assigned this Aug 27, 2025
@gabrielmfern gabrielmfern requested a review from a team as a code owner August 27, 2025 13:26
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 issues found across 2 files

React with 👍 or 👎 to teach cubic. You can also tag @cubic-dev-ai to give feedback, ask questions, or re-run the review.

gabrielmfern and others added 4 commits August 27, 2025 10:41
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Copy link

pkg-pr-new bot commented Aug 27, 2025

Open in StackBlitz

npm i https://pkg.pr.new/resend/resend-node/resend@605

commit: db2a1b9

@pedro-stramantinoli
Copy link
Contributor

Nice!!

@pedro-stramantinoli pedro-stramantinoli merged commit e1165fa into feat/batch-mode-permissive Aug 27, 2025
8 checks passed
@pedro-stramantinoli pedro-stramantinoli deleted the chore/suggestions-to-batch-mode-api branch August 27, 2025 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants