diff --git a/examples/templates.py b/examples/templates.py index dec3990..10da65b 100644 --- a/examples/templates.py +++ b/examples/templates.py @@ -45,6 +45,7 @@ # Get a template by ID retrieved_template: resend.Template = resend.Templates.get(template["id"]) print(f"Retrieved template: {retrieved_template['name']}") +print(f"Has unpublished versions: {retrieved_template['has_unpublished_versions']}") # Update a template (update just the name, keep HTML/variables the same) update_params: resend.Templates.UpdateParams = { diff --git a/resend/templates/_template.py b/resend/templates/_template.py index 3124240..a5fbb9d 100644 --- a/resend/templates/_template.py +++ b/resend/templates/_template.py @@ -53,6 +53,8 @@ class Template(_FromParam): created_at (str): The timestamp when the template was created. updated_at (str): The timestamp when the template was last updated. published_at (str): The timestamp when the template was published. + current_version_id (str): The ID of the current version of the template. + has_unpublished_versions (bool): Whether the template has unpublished versions. """ id: str @@ -93,6 +95,10 @@ class Template(_FromParam): published_at: NotRequired[str] """The timestamp when the template was published.""" + current_version_id: NotRequired[str] + """The ID of the current version of the template.""" + has_unpublished_versions: NotRequired[bool] + """Whether the template has unpublished versions.""" class TemplateListItem(TypedDict): diff --git a/resend/version.py b/resend/version.py index 5cd4c2a..4e3219f 100644 --- a/resend/version.py +++ b/resend/version.py @@ -1,4 +1,4 @@ -__version__ = "2.54.0" +__version__ = "2.54.1" def get_version() -> str: diff --git a/tests/templates_async_test.py b/tests/templates_async_test.py index 75f8129..5688d30 100644 --- a/tests/templates_async_test.py +++ b/tests/templates_async_test.py @@ -1,4 +1,5 @@ import pytest +from typing_extensions import assert_type import resend from resend.exceptions import NoContentError @@ -217,3 +218,42 @@ async def test_should_list_templates_async_raise_exception_when_no_content( self.set_mock_json(None) with pytest.raises(NoContentError): _ = await resend.Templates.list_async() + + async def test_templates_get_async_returns_version_fields(self) -> None: + self.set_mock_json( + { + "object": "template", + "id": "34a080c9-b17d-4187-ad80-5af20266e535", + "current_version_id": "b2693018-7abb-4b4b-b4cb-aadf72dc06bd", + "alias": "reset-password", + "name": "reset-password", + "created_at": "2026-10-06 23:47:56.678+00", + "updated_at": "2026-10-06 23:47:56.678+00", + "status": "published", + "published_at": "2026-10-06 23:47:56.678+00", + "from": "John Doe ", + "subject": "Hello, world!", + "reply_to": None, + "html": "

Hello, world!

", + "text": "Hello, world!", + "variables": [ + { + "id": "e169aa45-1ecf-4183-9955-b1499d5701d3", + "key": "user_name", + "type": "string", + "fallback_value": "John Doe", + "created_at": "2026-10-06 23:47:56.678+00", + "updated_at": "2026-10-06 23:47:56.678+00", + } + ], + "has_unpublished_versions": True, + } + ) + + template = await resend.Templates.get_async( + "34a080c9-b17d-4187-ad80-5af20266e535" + ) + assert_type(template["current_version_id"], str) + assert_type(template["has_unpublished_versions"], bool) + assert template["current_version_id"] == "b2693018-7abb-4b4b-b4cb-aadf72dc06bd" + assert template["has_unpublished_versions"] is True diff --git a/tests/templates_test.py b/tests/templates_test.py index f2f598b..b86978d 100644 --- a/tests/templates_test.py +++ b/tests/templates_test.py @@ -1,3 +1,5 @@ +from typing_extensions import assert_type + import resend from tests.conftest import ResendBaseTest @@ -305,3 +307,40 @@ def test_templates_variable_types(self) -> None: template: resend.Templates.CreateResponse = resend.Templates.create(params) assert template["id"] == "49a3999c-0ce1-4ea6-ab68-afcd6dc2e794" assert template["object"] == "template" + + def test_templates_get_returns_version_fields(self) -> None: + self.set_mock_json( + { + "object": "template", + "id": "34a080c9-b17d-4187-ad80-5af20266e535", + "current_version_id": "b2693018-7abb-4b4b-b4cb-aadf72dc06bd", + "alias": "reset-password", + "name": "reset-password", + "created_at": "2026-10-06 23:47:56.678+00", + "updated_at": "2026-10-06 23:47:56.678+00", + "status": "published", + "published_at": "2026-10-06 23:47:56.678+00", + "from": "John Doe ", + "subject": "Hello, world!", + "reply_to": None, + "html": "

Hello, world!

", + "text": "Hello, world!", + "variables": [ + { + "id": "e169aa45-1ecf-4183-9955-b1499d5701d3", + "key": "user_name", + "type": "string", + "fallback_value": "John Doe", + "created_at": "2026-10-06 23:47:56.678+00", + "updated_at": "2026-10-06 23:47:56.678+00", + } + ], + "has_unpublished_versions": True, + } + ) + + template = resend.Templates.get("34a080c9-b17d-4187-ad80-5af20266e535") + assert_type(template["current_version_id"], str) + assert_type(template["has_unpublished_versions"], bool) + assert template["current_version_id"] == "b2693018-7abb-4b4b-b4cb-aadf72dc06bd" + assert template["has_unpublished_versions"] is True