Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add idempotencyKey support to emails.receiving.forward() #967

@franzwilhelm

Description

@franzwilhelm

The emails.receiving.forward() helper is the recommended path for forwarding inbound emails, and it is useful because it preserves received content and attachments without each app reimplementing MIME parsing.

For webhook-based forwarding, duplicate prevention is critical. Resend webhooks can be retried or replayed, and a serverless handler/background job can fail after the underlying email send is accepted but before local state is marked as sent. In that situation, retrying the forwarding job can send duplicate customer emails.

The Send Email API already supports Idempotency-Key, and the Node SDK exposes idempotencyKey for emails.send / emails.create request options. But emails.receiving.forward() does not currently expose a way to pass an idempotency key.

From the SDK shape, forward() appears to call /emails internally, so it would be useful if the helper accepted request options too.

Potential API:

await resend.emails.receiving.forward(
  {
    emailId,
    to,
    from,
  },
  {
    idempotencyKey: `forward:${emailId}:${to}`,
  }
)

Alternative API if preferred:

await resend.emails.receiving.forward({
  emailId,
  to,
  from,
  idempotencyKey: `forward:${emailId}:${to}`,
})

Use case:

  • Receive email.received webhook
  • Resolve customer-specific forwarding address
  • Forward inbound email
  • Retry safely on transient failures or webhook replays
  • Avoid duplicate forwarded messages

Without this, apps that need strict duplicate prevention have to avoid the recommended helper and manually download/parse/send the raw email through emails.send only to get idempotency support.

Thanks.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions