Skip to content

Commit a6f1cc1

Browse files
cursoragentcpenned
andcommitted
feat: add message_id typing for emails and webhook events
Add message_id to the Email type for GET /emails/:id and list responses. Introduce typed webhook event payloads (WebhookEventPayload) matching the Node.js SDK, including message_id on all outbound email webhook events. Update Webhooks.verify to return the parsed and verified event payload. Co-authored-by: cpenned <cpenned@users.noreply.github.com>
1 parent 0dad9d6 commit a6f1cc1

6 files changed

Lines changed: 706 additions & 9 deletions

File tree

resend/__init__.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,22 @@
5757
from .version import __version__, get_version
5858
from .webhooks._webhook import (VerifyWebhookOptions, Webhook, WebhookEvent,
5959
WebhookHeaders, WebhookStatus)
60+
from .webhooks._webhook_event import (BaseEmailEventData, ContactCreatedEvent,
61+
ContactDeletedEvent, ContactUpdatedEvent,
62+
ContactEventData, DomainCreatedEvent,
63+
DomainDeletedEvent, DomainEventData,
64+
DomainRecord, DomainUpdatedEvent,
65+
EmailBounce, EmailBouncedEvent,
66+
EmailClickedEvent, EmailClick,
67+
EmailComplainedEvent, EmailDeliveredEvent,
68+
EmailDeliveryDelayedEvent,
69+
EmailFailed, EmailFailedEvent,
70+
EmailOpenedEvent, EmailReceivedEvent,
71+
EmailScheduledEvent, EmailSentEvent,
72+
EmailSuppressed, EmailSuppressedEvent,
73+
ReceivedEmailAttachment,
74+
ReceivedEmailEventData,
75+
WebhookEventPayload)
6076
from .webhooks._webhooks import Webhooks
6177

6278
# Type for clients that support both sync and async
@@ -135,9 +151,37 @@
135151
"Variable",
136152
"Webhook",
137153
"WebhookEvent",
154+
"WebhookEventPayload",
138155
"WebhookHeaders",
139156
"WebhookStatus",
140157
"VerifyWebhookOptions",
158+
"BaseEmailEventData",
159+
"EmailBounce",
160+
"EmailClick",
161+
"EmailFailed",
162+
"EmailSuppressed",
163+
"ReceivedEmailAttachment",
164+
"ReceivedEmailEventData",
165+
"ContactEventData",
166+
"DomainRecord",
167+
"DomainEventData",
168+
"EmailSentEvent",
169+
"EmailScheduledEvent",
170+
"EmailDeliveredEvent",
171+
"EmailDeliveryDelayedEvent",
172+
"EmailComplainedEvent",
173+
"EmailBouncedEvent",
174+
"EmailOpenedEvent",
175+
"EmailClickedEvent",
176+
"EmailReceivedEvent",
177+
"EmailFailedEvent",
178+
"EmailSuppressedEvent",
179+
"ContactCreatedEvent",
180+
"ContactUpdatedEvent",
181+
"ContactDeletedEvent",
182+
"DomainCreatedEvent",
183+
"DomainUpdatedEvent",
184+
"DomainDeletedEvent",
141185
"Topic",
142186
"BatchValidationError",
143187
"ReceivedEmail",

resend/emails/_email.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ class _EmailDefaultAttrs(_FromParam):
1616
"""
1717
The Email ID.
1818
"""
19+
message_id: str
20+
"""
21+
RFC Message-ID header value for the email.
22+
"""
1923
to: Union[List[str], str]
2024
"""
2125
List of email addresses to send the email to.
@@ -60,6 +64,7 @@ class Email(_EmailDefaultAttrs):
6064
6165
Attributes:
6266
id (str): The Email ID.
67+
message_id (str): RFC Message-ID header value for the email.
6368
from (str): The email address the email was sent from.
6469
to (Union[List[str], str]): List of email addresses to send the email to.
6570
created_at (str): When the email was created.

0 commit comments

Comments
 (0)