Skip to content
Open
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
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "7.19.2"
".": "7.20.0"
}
8 changes: 4 additions & 4 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 138
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier/courier-11e1931d767cef402bbed5a965746d1933ae72db0f41881860593a0b1424fd80.yml
openapi_spec_hash: 9def941805f233f8761c4bdae88f6137
config_hash: 6c3a754258f0f77e9032a90a478ab76d
configured_endpoints: 139
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier/courier-def1e982add0411bf64b48cdf5e4f2c1b85b9bd0ada0d5e6fc4869afa85e0bff.yml
openapi_spec_hash: 5d129cdf800798bcd4a93585ec89c696
config_hash: dcd58abf1e56b114bdce22336ca3d570
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 7.20.0 (2026-07-14)

Full Changelog: [v7.19.2...v7.20.0](https://github.com/trycourier/courier-python/compare/v7.19.2...v7.20.0)

### Features

* Document POST /notifications/{id}/duplicate [C-18607] ([#165](https://github.com/trycourier/courier-python/issues/165)) ([15985d7](https://github.com/trycourier/courier-python/commit/15985d79d0969c41dc4cfca6833dd111bbc5c0ca))
* Merge pull request [#149](https://github.com/trycourier/courier-python/issues/149) from trycourier/geraldosilva/c-19201-notification-template-subscription-topic-id ([99b10ca](https://github.com/trycourier/courier-python/commit/99b10cad359b2377e6bb8bc797be42c93a8823b8))

## 7.19.2 (2026-07-10)

Full Changelog: [v7.19.1...v7.19.2](https://github.com/trycourier/courier-python/compare/v7.19.1...v7.19.2)
Expand Down
1 change: 1 addition & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ Methods:
- <code title="get /notifications/{id}">client.notifications.<a href="./src/courier/resources/notifications/notifications.py">retrieve</a>(id, \*\*<a href="src/courier/types/notification_retrieve_params.py">params</a>) -> <a href="./src/courier/types/notification_template_response.py">NotificationTemplateResponse</a></code>
- <code title="get /notifications">client.notifications.<a href="./src/courier/resources/notifications/notifications.py">list</a>(\*\*<a href="src/courier/types/notification_list_params.py">params</a>) -> <a href="./src/courier/types/notification_list_response.py">NotificationListResponse</a></code>
- <code title="delete /notifications/{id}">client.notifications.<a href="./src/courier/resources/notifications/notifications.py">archive</a>(id) -> None</code>
- <code title="post /notifications/{id}/duplicate">client.notifications.<a href="./src/courier/resources/notifications/notifications.py">duplicate</a>(id) -> <a href="./src/courier/types/notification_template_response.py">NotificationTemplateResponse</a></code>
- <code title="get /notifications/{id}/versions">client.notifications.<a href="./src/courier/resources/notifications/notifications.py">list_versions</a>(id, \*\*<a href="src/courier/types/notification_list_versions_params.py">params</a>) -> <a href="./src/courier/types/notification_template_version_list_response.py">NotificationTemplateVersionListResponse</a></code>
- <code title="post /notifications/{id}/publish">client.notifications.<a href="./src/courier/resources/notifications/notifications.py">publish</a>(id, \*\*<a href="src/courier/types/notification_publish_params.py">params</a>) -> None</code>
- <code title="put /notifications/{id}/content">client.notifications.<a href="./src/courier/resources/notifications/notifications.py">put_content</a>(id, \*\*<a href="src/courier/types/notification_put_content_params.py">params</a>) -> <a href="./src/courier/types/notification_content_mutation_response.py">NotificationContentMutationResponse</a></code>
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "trycourier"
version = "7.19.2"
version = "7.20.0"
description = "The official Python library for the Courier API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion src/courier/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

__title__ = "courier"
__version__ = "7.19.2" # x-release-please-version
__version__ = "7.20.0" # x-release-please-version
90 changes: 90 additions & 0 deletions src/courier/resources/notifications/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,45 @@ def archive(
cast_to=NoneType,
)

def duplicate(
self,
id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> NotificationTemplateResponse:
"""Duplicate a notification template.

Creates a standalone copy within the same
workspace and environment, with " COPY" appended to the title. The copy clones
the source draft's tags, brand, subscription topic, routing strategy, channels,
and content, and is always created as a standalone template (it is not linked to
any journey or broadcast, even if the source was). Templates that are scoped to
a journey or a broadcast cannot be duplicated through this endpoint.

Args:
extra_headers: Send extra headers

extra_query: Add additional query parameters to the request

extra_body: Add additional JSON properties to the request

timeout: Override the client-level default timeout for this request, in seconds
"""
if not id:
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
return self._post(
path_template("/notifications/{id}/duplicate", id=id),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=NotificationTemplateResponse,
)

def list_versions(
self,
id: str,
Expand Down Expand Up @@ -801,6 +840,45 @@ async def archive(
cast_to=NoneType,
)

async def duplicate(
self,
id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> NotificationTemplateResponse:
"""Duplicate a notification template.

Creates a standalone copy within the same
workspace and environment, with " COPY" appended to the title. The copy clones
the source draft's tags, brand, subscription topic, routing strategy, channels,
and content, and is always created as a standalone template (it is not linked to
any journey or broadcast, even if the source was). Templates that are scoped to
a journey or a broadcast cannot be duplicated through this endpoint.

Args:
extra_headers: Send extra headers

extra_query: Add additional query parameters to the request

extra_body: Add additional JSON properties to the request

timeout: Override the client-level default timeout for this request, in seconds
"""
if not id:
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
return await self._post(
path_template("/notifications/{id}/duplicate", id=id),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=NotificationTemplateResponse,
)

async def list_versions(
self,
id: str,
Expand Down Expand Up @@ -1172,6 +1250,9 @@ def __init__(self, notifications: NotificationsResource) -> None:
self.archive = to_raw_response_wrapper(
notifications.archive,
)
self.duplicate = to_raw_response_wrapper(
notifications.duplicate,
)
self.list_versions = to_raw_response_wrapper(
notifications.list_versions,
)
Expand Down Expand Up @@ -1215,6 +1296,9 @@ def __init__(self, notifications: AsyncNotificationsResource) -> None:
self.archive = async_to_raw_response_wrapper(
notifications.archive,
)
self.duplicate = async_to_raw_response_wrapper(
notifications.duplicate,
)
self.list_versions = async_to_raw_response_wrapper(
notifications.list_versions,
)
Expand Down Expand Up @@ -1258,6 +1342,9 @@ def __init__(self, notifications: NotificationsResource) -> None:
self.archive = to_streamed_response_wrapper(
notifications.archive,
)
self.duplicate = to_streamed_response_wrapper(
notifications.duplicate,
)
self.list_versions = to_streamed_response_wrapper(
notifications.list_versions,
)
Expand Down Expand Up @@ -1301,6 +1388,9 @@ def __init__(self, notifications: AsyncNotificationsResource) -> None:
self.archive = async_to_streamed_response_wrapper(
notifications.archive,
)
self.duplicate = async_to_streamed_response_wrapper(
notifications.duplicate,
)
self.list_versions = async_to_streamed_response_wrapper(
notifications.list_versions,
)
Expand Down
6 changes: 6 additions & 0 deletions src/courier/types/notification_template_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ class NotificationTemplateSummary(BaseModel):

tags: List[str]

subscription_topic_id: Optional[str] = None
"""The linked subscription (preference) topic of the published version.

Omitted when no topic is linked or the template has never been published.
"""

updated: Optional[int] = None
"""Epoch milliseconds of last update."""

Expand Down
84 changes: 84 additions & 0 deletions tests/api_resources/test_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,48 @@ def test_path_params_archive(self, client: Courier) -> None:
"",
)

@pytest.mark.skip(reason="Mock server tests are disabled")
@parametrize
def test_method_duplicate(self, client: Courier) -> None:
notification = client.notifications.duplicate(
"id",
)
assert_matches_type(NotificationTemplateResponse, notification, path=["response"])

@pytest.mark.skip(reason="Mock server tests are disabled")
@parametrize
def test_raw_response_duplicate(self, client: Courier) -> None:
response = client.notifications.with_raw_response.duplicate(
"id",
)

assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
notification = response.parse()
assert_matches_type(NotificationTemplateResponse, notification, path=["response"])

@pytest.mark.skip(reason="Mock server tests are disabled")
@parametrize
def test_streaming_response_duplicate(self, client: Courier) -> None:
with client.notifications.with_streaming_response.duplicate(
"id",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"

notification = response.parse()
assert_matches_type(NotificationTemplateResponse, notification, path=["response"])

assert cast(Any, response.is_closed) is True

@pytest.mark.skip(reason="Mock server tests are disabled")
@parametrize
def test_path_params_duplicate(self, client: Courier) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
client.notifications.with_raw_response.duplicate(
"",
)

@pytest.mark.skip(reason="Mock server tests are disabled")
@parametrize
def test_method_list_versions(self, client: Courier) -> None:
Expand Down Expand Up @@ -917,6 +959,48 @@ async def test_path_params_archive(self, async_client: AsyncCourier) -> None:
"",
)

@pytest.mark.skip(reason="Mock server tests are disabled")
@parametrize
async def test_method_duplicate(self, async_client: AsyncCourier) -> None:
notification = await async_client.notifications.duplicate(
"id",
)
assert_matches_type(NotificationTemplateResponse, notification, path=["response"])

@pytest.mark.skip(reason="Mock server tests are disabled")
@parametrize
async def test_raw_response_duplicate(self, async_client: AsyncCourier) -> None:
response = await async_client.notifications.with_raw_response.duplicate(
"id",
)

assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
notification = await response.parse()
assert_matches_type(NotificationTemplateResponse, notification, path=["response"])

@pytest.mark.skip(reason="Mock server tests are disabled")
@parametrize
async def test_streaming_response_duplicate(self, async_client: AsyncCourier) -> None:
async with async_client.notifications.with_streaming_response.duplicate(
"id",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"

notification = await response.parse()
assert_matches_type(NotificationTemplateResponse, notification, path=["response"])

assert cast(Any, response.is_closed) is True

@pytest.mark.skip(reason="Mock server tests are disabled")
@parametrize
async def test_path_params_duplicate(self, async_client: AsyncCourier) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
await async_client.notifications.with_raw_response.duplicate(
"",
)

@pytest.mark.skip(reason="Mock server tests are disabled")
@parametrize
async def test_method_list_versions(self, async_client: AsyncCourier) -> None:
Expand Down