feat(events): accept an idempotency key when sending an event
Summary
Resend::Events.send now takes an options: keyword, and options: { idempotency_key: "..." } sends the Idempotency-Key header on POST /events/send. It uses the same option name and header code as Resend::Emails.send and Resend::Batch.send. Callers that don't pass options: see no change.
The API has accepted Idempotency-Key on this endpoint since Dec 3 (contract: resend/resend-docs#2039). This matches resend-node's resend.events.send(payload, { idempotencyKey }) from resend/resend-node#1205.
Resend::Events.send(
{ event: "order.created", email: "ana@example.com" },
options: { idempotency_key: "order_created:123" }
)
Also adds this call to examples/events.rb and bumps the version to 1.23.0, as recent feature PRs do.
Testing
- New spec in
spec/events_spec.rbchecks that the header is sent when a key is given. It fails without thelibchange. bundle exec rake spec: 497 examples, 0 failures (Ruby 4.0.9)bundle exec rubocop: no offenses
🤖 Generated with Claude Code
Summary by cubic
Resend::Events.send now accepts an options: keyword so callers can pass an idempotency key, which is sent as the Idempotency-Key header on POST /events/send. This mirrors how Resend::Emails.send and Resend::Batch.send already handle idempotency keys, and callers that don't pass options: see no change.
- Adds the
options:keyword tosendand forwards it to the underlying request. - Updates
examples/events.rbwith an idempotent event example and bumps the gem version to 1.23.0. - Adds a spec verifying the header is sent when a key is provided.