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
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.18.1"
".": "7.18.2"
}
8 changes: 4 additions & 4 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 135
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier/courier-0b80b9b90e51b4d19f5cebadddf91c345090af9e6ad46cfb9364f0421e35e0bb.yml
openapi_spec_hash: 5283fb7d76bbdd7dcf48784f7128513b
config_hash: 66d7703eac15d2affc326ac25b55bcd6
configured_endpoints: 136
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier/courier-d2b3bdb6747f4acc997702dbd9f24340a3d85f22c00e1f17af2bd6621358bc77.yml
openapi_spec_hash: b6791652567d04fd87c6117090de7635
config_hash: 627f8592c19dfb77f91ffbec2a057c3a
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 7.18.2 (2026-07-09)

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

### Chores

* update api-spec with new message resend endpoint ([692be20](https://github.com/trycourier/courier-python/commit/692be204486c24fa3c92740f806a54233b738ef4))

## 7.18.1 (2026-07-07)

Full Changelog: [v7.18.0...v7.18.1](https://github.com/trycourier/courier-python/compare/v7.18.0...v7.18.1)
Expand Down
2 changes: 2 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ from courier.types import (
MessageListResponse,
MessageContentResponse,
MessageHistoryResponse,
MessageResendResponse,
)
```

Expand All @@ -398,6 +399,7 @@ Methods:
- <code title="post /messages/{message_id}/cancel">client.messages.<a href="./src/courier/resources/messages.py">cancel</a>(message_id) -> <a href="./src/courier/types/message_details.py">MessageDetails</a></code>
- <code title="get /messages/{message_id}/output">client.messages.<a href="./src/courier/resources/messages.py">content</a>(message_id) -> <a href="./src/courier/types/message_content_response.py">MessageContentResponse</a></code>
- <code title="get /messages/{message_id}/history">client.messages.<a href="./src/courier/resources/messages.py">history</a>(message_id, \*\*<a href="src/courier/types/message_history_params.py">params</a>) -> <a href="./src/courier/types/message_history_response.py">MessageHistoryResponse</a></code>
- <code title="post /messages/{message_id}/resend">client.messages.<a href="./src/courier/resources/messages.py">resend</a>(message_id) -> <a href="./src/courier/types/message_resend_response.py">MessageResendResponse</a></code>

# Requests

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.18.1"
version = "7.18.2"
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.18.1" # x-release-please-version
__version__ = "7.18.2" # x-release-please-version
89 changes: 89 additions & 0 deletions src/courier/resources/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from .._base_client import make_request_options
from ..types.message_details import MessageDetails
from ..types.message_list_response import MessageListResponse
from ..types.message_resend_response import MessageResendResponse
from ..types.message_content_response import MessageContentResponse
from ..types.message_history_response import MessageHistoryResponse
from ..types.message_retrieve_response import MessageRetrieveResponse
Expand Down Expand Up @@ -294,6 +295,44 @@ def history(
cast_to=MessageHistoryResponse,
)

def resend(
self,
message_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,
) -> MessageResendResponse:
"""Resend a previously sent message.

The original send request is loaded from
storage and a brand-new send is enqueued for the same recipient and content,
producing a **new** `messageId` — the original message is not modified.
Throttled by a per-message rate limit; a repeat inside the limit window returns
`429 Too Many Requests`.

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 message_id:
raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}")
return self._post(
path_template("/messages/{message_id}/resend", message_id=message_id),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=MessageResendResponse,
)


class AsyncMessagesResource(AsyncAPIResource):
@cached_property
Expand Down Expand Up @@ -562,6 +601,44 @@ async def history(
cast_to=MessageHistoryResponse,
)

async def resend(
self,
message_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,
) -> MessageResendResponse:
"""Resend a previously sent message.

The original send request is loaded from
storage and a brand-new send is enqueued for the same recipient and content,
producing a **new** `messageId` — the original message is not modified.
Throttled by a per-message rate limit; a repeat inside the limit window returns
`429 Too Many Requests`.

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 message_id:
raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}")
return await self._post(
path_template("/messages/{message_id}/resend", message_id=message_id),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=MessageResendResponse,
)


class MessagesResourceWithRawResponse:
def __init__(self, messages: MessagesResource) -> None:
Expand All @@ -582,6 +659,9 @@ def __init__(self, messages: MessagesResource) -> None:
self.history = to_raw_response_wrapper(
messages.history,
)
self.resend = to_raw_response_wrapper(
messages.resend,
)


class AsyncMessagesResourceWithRawResponse:
Expand All @@ -603,6 +683,9 @@ def __init__(self, messages: AsyncMessagesResource) -> None:
self.history = async_to_raw_response_wrapper(
messages.history,
)
self.resend = async_to_raw_response_wrapper(
messages.resend,
)


class MessagesResourceWithStreamingResponse:
Expand All @@ -624,6 +707,9 @@ def __init__(self, messages: MessagesResource) -> None:
self.history = to_streamed_response_wrapper(
messages.history,
)
self.resend = to_streamed_response_wrapper(
messages.resend,
)


class AsyncMessagesResourceWithStreamingResponse:
Expand All @@ -645,3 +731,6 @@ def __init__(self, messages: AsyncMessagesResource) -> None:
self.history = async_to_streamed_response_wrapper(
messages.history,
)
self.resend = async_to_streamed_response_wrapper(
messages.resend,
)
1 change: 1 addition & 0 deletions src/courier/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@
from .journey_exit_node_param import JourneyExitNodeParam as JourneyExitNodeParam
from .journey_retrieve_params import JourneyRetrieveParams as JourneyRetrieveParams
from .journey_send_node_param import JourneySendNodeParam as JourneySendNodeParam
from .message_resend_response import MessageResendResponse as MessageResendResponse
from .profile_create_response import ProfileCreateResponse as ProfileCreateResponse
from .providers_catalog_entry import ProvidersCatalogEntry as ProvidersCatalogEntry
from .widget_background_param import WidgetBackgroundParam as WidgetBackgroundParam
Expand Down
15 changes: 15 additions & 0 deletions src/courier/types/message_resend_response.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from pydantic import Field as FieldInfo

from .._models import BaseModel

__all__ = ["MessageResendResponse"]


class MessageResendResponse(BaseModel):
message_id: str = FieldInfo(alias="messageId")
"""The new message id for the resent message.

It is distinct from the id of the original message that was resent.
"""
85 changes: 85 additions & 0 deletions tests/api_resources/test_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from courier.types import (
MessageDetails,
MessageListResponse,
MessageResendResponse,
MessageContentResponse,
MessageHistoryResponse,
MessageRetrieveResponse,
Expand Down Expand Up @@ -249,6 +250,48 @@ def test_path_params_history(self, client: Courier) -> None:
message_id="",
)

@pytest.mark.skip(reason="Mock server tests are disabled")
@parametrize
def test_method_resend(self, client: Courier) -> None:
message = client.messages.resend(
"message_id",
)
assert_matches_type(MessageResendResponse, message, path=["response"])

@pytest.mark.skip(reason="Mock server tests are disabled")
@parametrize
def test_raw_response_resend(self, client: Courier) -> None:
response = client.messages.with_raw_response.resend(
"message_id",
)

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

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

message = response.parse()
assert_matches_type(MessageResendResponse, message, path=["response"])

assert cast(Any, response.is_closed) is True

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


class TestAsyncMessages:
parametrize = pytest.mark.parametrize(
Expand Down Expand Up @@ -480,3 +523,45 @@ async def test_path_params_history(self, async_client: AsyncCourier) -> None:
await async_client.messages.with_raw_response.history(
message_id="",
)

@pytest.mark.skip(reason="Mock server tests are disabled")
@parametrize
async def test_method_resend(self, async_client: AsyncCourier) -> None:
message = await async_client.messages.resend(
"message_id",
)
assert_matches_type(MessageResendResponse, message, path=["response"])

@pytest.mark.skip(reason="Mock server tests are disabled")
@parametrize
async def test_raw_response_resend(self, async_client: AsyncCourier) -> None:
response = await async_client.messages.with_raw_response.resend(
"message_id",
)

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

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

message = await response.parse()
assert_matches_type(MessageResendResponse, message, 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_resend(self, async_client: AsyncCourier) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `message_id` but received ''"):
await async_client.messages.with_raw_response.resend(
"",
)