diff --git a/resend/__init__.py b/resend/__init__.py index 301d91a..c2b983c 100644 --- a/resend/__init__.py +++ b/resend/__init__.py @@ -79,6 +79,9 @@ WebhookHeaders, WebhookStatus) from .webhooks._webhook_event import (BaseEmailEventData, ContactCreatedEvent, ContactDeletedEvent, ContactEventData, + ContactTopicsEventData, + ContactTopicSubscription, + ContactTopicsUpdatedEvent, ContactUpdatedEvent, DomainCreatedEvent, DomainDeletedEvent, DomainEventData, DomainUpdatedEvent, EmailBouncedEvent, @@ -92,6 +95,8 @@ SuppressionAddedEvent, SuppressionEventData, SuppressionRemovedEvent, + TopicCreatedEvent, TopicDeletedEvent, + TopicEventData, TopicUpdatedEvent, WebhookEventPayload) from .webhooks._webhooks import Webhooks @@ -210,12 +215,19 @@ "ContactCreatedEvent", "ContactUpdatedEvent", "ContactDeletedEvent", + "ContactTopicsEventData", + "ContactTopicsUpdatedEvent", + "ContactTopicSubscription", "DomainCreatedEvent", "DomainUpdatedEvent", "DomainDeletedEvent", "SuppressionEventData", "SuppressionAddedEvent", "SuppressionRemovedEvent", + "TopicEventData", + "TopicCreatedEvent", + "TopicUpdatedEvent", + "TopicDeletedEvent", "Topic", "OAuthGrant", "OAuthGrantClient", diff --git a/resend/version.py b/resend/version.py index 434821a..9ada10a 100644 --- a/resend/version.py +++ b/resend/version.py @@ -1,4 +1,4 @@ -__version__ = "2.48.0" +__version__ = "2.49.0" def get_version() -> str: diff --git a/resend/webhooks/_webhook.py b/resend/webhooks/_webhook.py index 0f82eac..4f916f9 100644 --- a/resend/webhooks/_webhook.py +++ b/resend/webhooks/_webhook.py @@ -21,6 +21,7 @@ "contact.created", "contact.updated", "contact.deleted", + "contact.topics.updated", # Domain events "domain.created", "domain.updated", @@ -28,6 +29,10 @@ # Suppression events "suppression.added", "suppression.removed", + # Topic events + "topic.created", + "topic.updated", + "topic.deleted", ] diff --git a/resend/webhooks/_webhook_event.py b/resend/webhooks/_webhook_event.py index 65c4902..5407e81 100644 --- a/resend/webhooks/_webhook_event.py +++ b/resend/webhooks/_webhook_event.py @@ -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. @@ -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``.""" @@ -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``.""" @@ -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, @@ -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``.