Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions resend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@
EmailReceivedEvent, EmailScheduledEvent,
EmailSentEvent, EmailSuppressedEvent,
ReceivedEmailEventData,
SuppressionAddedEvent,
SuppressionEventData,
SuppressionRemovedEvent,
WebhookEventPayload)
from .webhooks._webhooks import Webhooks

Expand Down Expand Up @@ -205,6 +208,9 @@
"DomainCreatedEvent",
"DomainUpdatedEvent",
"DomainDeletedEvent",
"SuppressionEventData",
"SuppressionAddedEvent",
"SuppressionRemovedEvent",
"Topic",
"OAuthGrant",
"OAuthGrantClient",
Expand Down
2 changes: 1 addition & 1 deletion resend/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "2.46.0"
__version__ = "2.47.0"


def get_version() -> str:
Expand Down
3 changes: 3 additions & 0 deletions resend/webhooks/_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
"domain.created",
"domain.updated",
"domain.deleted",
# Suppression events
"suppression.added",
"suppression.removed",
]


Expand Down
29 changes: 29 additions & 0 deletions resend/webhooks/_webhook_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from typing_extensions import Literal, NotRequired, TypedDict

from resend.suppressions._suppression import SuppressionListItem

# Functional syntax required because ``from`` is a reserved keyword.
_FromField = TypedDict(
"_FromField",
Expand Down Expand Up @@ -353,6 +355,15 @@ class DomainEventData(TypedDict):
"""


class SuppressionEventData(SuppressionListItem):
"""
``data`` payload for suppression webhook events.

Same shape as ``SuppressionListItem``: ``id``, ``email``, ``origin``,
``source_id``, ``created_at``.
"""


class EmailSentEvent(TypedDict):
"""Webhook payload for ``email.sent``."""

Expand Down Expand Up @@ -489,6 +500,22 @@ class DomainDeletedEvent(TypedDict):
data: DomainEventData


class SuppressionAddedEvent(TypedDict):
"""Webhook payload for ``suppression.added``."""

type: Literal["suppression.added"]
created_at: str
data: SuppressionEventData


class SuppressionRemovedEvent(TypedDict):
"""Webhook payload for ``suppression.removed``."""

type: Literal["suppression.removed"]
created_at: str
data: SuppressionEventData


WebhookEventPayload = Union[
EmailSentEvent,
EmailScheduledEvent,
Expand All @@ -507,6 +534,8 @@ class DomainDeletedEvent(TypedDict):
DomainCreatedEvent,
DomainUpdatedEvent,
DomainDeletedEvent,
SuppressionAddedEvent,
SuppressionRemovedEvent,
]
"""
Union of all Resend webhook event payload shapes returned by ``Webhooks.verify``.
Expand Down
Loading