88
99import httpx
1010
11- from ...types import chat_create_params , chat_search_params , chat_archive_params , chat_retrieve_params
11+ from ...types import chat_list_params , chat_create_params , chat_search_params , chat_archive_params , chat_retrieve_params
1212from ..._types import Body , Omit , Query , Headers , NotGiven , SequenceNotStr , omit , not_given
1313from ..._utils import maybe_transform , async_maybe_transform
1414from ..._compat import cached_property
3030from ...pagination import SyncCursor , AsyncCursor
3131from ...types .chat import Chat
3232from ..._base_client import AsyncPaginator , make_request_options
33+ from ...types .chat_list_response import ChatListResponse
3334from ...types .chat_create_response import ChatCreateResponse
3435from ...types .shared .base_response import BaseResponse
3536
@@ -166,6 +167,65 @@ def retrieve(
166167 cast_to = Chat ,
167168 )
168169
170+ def list (
171+ self ,
172+ * ,
173+ account_ids : SequenceNotStr [str ] | Omit = omit ,
174+ cursor : str | Omit = omit ,
175+ direction : Literal ["after" , "before" ] | Omit = omit ,
176+ limit : int | Omit = omit ,
177+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
178+ # The extra values given here take precedence over values defined on the client or passed to this method.
179+ extra_headers : Headers | None = None ,
180+ extra_query : Query | None = None ,
181+ extra_body : Body | None = None ,
182+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
183+ ) -> SyncCursor [ChatListResponse ]:
184+ """List all chats sorted by last activity (most recent first).
185+
186+ Combines all
187+ accounts into a single paginated list.
188+
189+ Args:
190+ account_ids: Limit to specific account IDs. If omitted, fetches from all accounts.
191+
192+ cursor: Timestamp cursor (milliseconds since epoch) for pagination. Use with direction
193+ to navigate results.
194+
195+ direction: Pagination direction used with 'cursor': 'before' fetches older results, 'after'
196+ fetches newer results. Defaults to 'before' when only 'cursor' is provided.
197+
198+ limit: Maximum number of chats to return (1–200). Defaults to 50.
199+
200+ extra_headers: Send extra headers
201+
202+ extra_query: Add additional query parameters to the request
203+
204+ extra_body: Add additional JSON properties to the request
205+
206+ timeout: Override the client-level default timeout for this request, in seconds
207+ """
208+ return self ._get_api_list (
209+ "/v1/chats" ,
210+ page = SyncCursor [ChatListResponse ],
211+ options = make_request_options (
212+ extra_headers = extra_headers ,
213+ extra_query = extra_query ,
214+ extra_body = extra_body ,
215+ timeout = timeout ,
216+ query = maybe_transform (
217+ {
218+ "account_ids" : account_ids ,
219+ "cursor" : cursor ,
220+ "direction" : direction ,
221+ "limit" : limit ,
222+ },
223+ chat_list_params .ChatListParams ,
224+ ),
225+ ),
226+ model = ChatListResponse ,
227+ )
228+
169229 def archive (
170230 self ,
171231 chat_id : str ,
@@ -436,6 +496,65 @@ async def retrieve(
436496 cast_to = Chat ,
437497 )
438498
499+ def list (
500+ self ,
501+ * ,
502+ account_ids : SequenceNotStr [str ] | Omit = omit ,
503+ cursor : str | Omit = omit ,
504+ direction : Literal ["after" , "before" ] | Omit = omit ,
505+ limit : int | Omit = omit ,
506+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
507+ # The extra values given here take precedence over values defined on the client or passed to this method.
508+ extra_headers : Headers | None = None ,
509+ extra_query : Query | None = None ,
510+ extra_body : Body | None = None ,
511+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
512+ ) -> AsyncPaginator [ChatListResponse , AsyncCursor [ChatListResponse ]]:
513+ """List all chats sorted by last activity (most recent first).
514+
515+ Combines all
516+ accounts into a single paginated list.
517+
518+ Args:
519+ account_ids: Limit to specific account IDs. If omitted, fetches from all accounts.
520+
521+ cursor: Timestamp cursor (milliseconds since epoch) for pagination. Use with direction
522+ to navigate results.
523+
524+ direction: Pagination direction used with 'cursor': 'before' fetches older results, 'after'
525+ fetches newer results. Defaults to 'before' when only 'cursor' is provided.
526+
527+ limit: Maximum number of chats to return (1–200). Defaults to 50.
528+
529+ extra_headers: Send extra headers
530+
531+ extra_query: Add additional query parameters to the request
532+
533+ extra_body: Add additional JSON properties to the request
534+
535+ timeout: Override the client-level default timeout for this request, in seconds
536+ """
537+ return self ._get_api_list (
538+ "/v1/chats" ,
539+ page = AsyncCursor [ChatListResponse ],
540+ options = make_request_options (
541+ extra_headers = extra_headers ,
542+ extra_query = extra_query ,
543+ extra_body = extra_body ,
544+ timeout = timeout ,
545+ query = maybe_transform (
546+ {
547+ "account_ids" : account_ids ,
548+ "cursor" : cursor ,
549+ "direction" : direction ,
550+ "limit" : limit ,
551+ },
552+ chat_list_params .ChatListParams ,
553+ ),
554+ ),
555+ model = ChatListResponse ,
556+ )
557+
439558 async def archive (
440559 self ,
441560 chat_id : str ,
@@ -586,6 +705,9 @@ def __init__(self, chats: ChatsResource) -> None:
586705 self .retrieve = to_raw_response_wrapper (
587706 chats .retrieve ,
588707 )
708+ self .list = to_raw_response_wrapper (
709+ chats .list ,
710+ )
589711 self .archive = to_raw_response_wrapper (
590712 chats .archive ,
591713 )
@@ -609,6 +731,9 @@ def __init__(self, chats: AsyncChatsResource) -> None:
609731 self .retrieve = async_to_raw_response_wrapper (
610732 chats .retrieve ,
611733 )
734+ self .list = async_to_raw_response_wrapper (
735+ chats .list ,
736+ )
612737 self .archive = async_to_raw_response_wrapper (
613738 chats .archive ,
614739 )
@@ -632,6 +757,9 @@ def __init__(self, chats: ChatsResource) -> None:
632757 self .retrieve = to_streamed_response_wrapper (
633758 chats .retrieve ,
634759 )
760+ self .list = to_streamed_response_wrapper (
761+ chats .list ,
762+ )
635763 self .archive = to_streamed_response_wrapper (
636764 chats .archive ,
637765 )
@@ -655,6 +783,9 @@ def __init__(self, chats: AsyncChatsResource) -> None:
655783 self .retrieve = async_to_streamed_response_wrapper (
656784 chats .retrieve ,
657785 )
786+ self .list = async_to_streamed_response_wrapper (
787+ chats .list ,
788+ )
658789 self .archive = async_to_streamed_response_wrapper (
659790 chats .archive ,
660791 )
0 commit comments