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
12 changes: 12 additions & 0 deletions resend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@
WebhookHeaders, WebhookStatus)
from .webhooks._webhook_event import (BaseEmailEventData, ContactCreatedEvent,
ContactDeletedEvent, ContactEventData,
ContactTopicsEventData,
ContactTopicSubscription,
ContactTopicsUpdatedEvent,
ContactUpdatedEvent, DomainCreatedEvent,
DomainDeletedEvent, DomainEventData,
DomainUpdatedEvent, EmailBouncedEvent,
Expand All @@ -92,6 +95,8 @@
SuppressionAddedEvent,
SuppressionEventData,
SuppressionRemovedEvent,
TopicCreatedEvent, TopicDeletedEvent,
TopicEventData, TopicUpdatedEvent,
WebhookEventPayload)
from .webhooks._webhooks import Webhooks

Expand Down Expand Up @@ -210,12 +215,19 @@
"ContactCreatedEvent",
"ContactUpdatedEvent",
"ContactDeletedEvent",
"ContactTopicsEventData",
"ContactTopicsUpdatedEvent",
"ContactTopicSubscription",
"DomainCreatedEvent",
"DomainUpdatedEvent",
"DomainDeletedEvent",
"SuppressionEventData",
"SuppressionAddedEvent",
"SuppressionRemovedEvent",
"TopicEventData",
"TopicCreatedEvent",
"TopicUpdatedEvent",
"TopicDeletedEvent",
"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.48.0"
__version__ = "2.49.0"


def get_version() -> str:
Expand Down
5 changes: 5 additions & 0 deletions resend/webhooks/_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,18 @@
"contact.created",
"contact.updated",
"contact.deleted",
"contact.topics.updated",
Comment thread
joaopcm marked this conversation as resolved.
# Domain events
"domain.created",
"domain.updated",
"domain.deleted",
# Suppression events
"suppression.added",
"suppression.removed",
# Topic events
"topic.created",
"topic.updated",
"topic.deleted",
]


Expand Down
101 changes: 101 additions & 0 deletions resend/webhooks/_webhook_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,36 @@ class ContactEventData(TypedDict):
"""


class ContactTopicSubscription(TypedDict):
"""
Topic entry on ``contact.topics.updated`` events.
"""

id: str
"""
The topic ID.
"""
subscription: Literal["opt_in", "opt_out"]
"""
The contact's new subscription to the topic.
"""


class ContactTopicsEventData(TypedDict):
"""
``data`` payload for ``contact.topics.updated`` events.
"""

email: str
"""
The contact email address.
"""
topics: List[ContactTopicSubscription]
"""
The topics changed in this update, each with its new subscription.
"""


class DomainRecord(TypedDict):
"""
DNS record included on domain webhook events.
Expand Down Expand Up @@ -364,6 +394,41 @@ class SuppressionEventData(SuppressionListItem):
"""


class TopicEventData(TypedDict):
"""
``data`` payload for topic webhook events.
"""

id: str
"""
The topic ID.
"""
name: str
"""
The topic name.
"""
description: Optional[str]
"""
The topic description. None when the topic has no description.
"""
default_subscription: Literal["opt_in", "opt_out"]
"""
The default subscription preference for new contacts.
"""
deleted: bool
"""
Whether the topic is deleted. True on ``topic.deleted`` events.
"""
created_at: str
"""
When the topic was created.
"""
updated_at: str
"""
When the topic was last updated.
"""


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

Expand Down Expand Up @@ -476,6 +541,14 @@ class ContactDeletedEvent(TypedDict):
data: ContactEventData


class ContactTopicsUpdatedEvent(TypedDict):
"""Webhook payload for ``contact.topics.updated``."""

type: Literal["contact.topics.updated"]
created_at: str
data: ContactTopicsEventData


class DomainCreatedEvent(TypedDict):
"""Webhook payload for ``domain.created``."""

Expand Down Expand Up @@ -516,6 +589,30 @@ class SuppressionRemovedEvent(TypedDict):
data: SuppressionEventData


class TopicCreatedEvent(TypedDict):
"""Webhook payload for ``topic.created``."""

type: Literal["topic.created"]
created_at: str
data: TopicEventData


class TopicUpdatedEvent(TypedDict):
"""Webhook payload for ``topic.updated``."""

type: Literal["topic.updated"]
created_at: str
data: TopicEventData


class TopicDeletedEvent(TypedDict):
"""Webhook payload for ``topic.deleted``."""

type: Literal["topic.deleted"]
created_at: str
data: TopicEventData


WebhookEventPayload = Union[
EmailSentEvent,
EmailScheduledEvent,
Expand All @@ -531,11 +628,15 @@ class SuppressionRemovedEvent(TypedDict):
ContactCreatedEvent,
ContactUpdatedEvent,
ContactDeletedEvent,
ContactTopicsUpdatedEvent,
DomainCreatedEvent,
DomainUpdatedEvent,
DomainDeletedEvent,
SuppressionAddedEvent,
SuppressionRemovedEvent,
TopicCreatedEvent,
TopicUpdatedEvent,
TopicDeletedEvent,
]
"""
Union of all Resend webhook event payload shapes returned by ``Webhooks.verify``.
Expand Down
Loading