@@ -250,29 +250,34 @@ def update(cls, params: UpdateParams) -> UpdateContactResponse:
250250
251251 @classmethod
252252 def list (
253- cls , audience_id : Optional [str ] = None , params : Optional [ListParams ] = None
253+ cls ,
254+ audience_id : Optional [str ] = None ,
255+ params : Optional [ListParams ] = None ,
256+ segment_id : Optional [str ] = None ,
254257 ) -> ListResponse :
255258 """
256259 List all contacts.
257- Can list either global contacts or audience-specific contacts.
260+ Can list global contacts, audience-specific contacts, or segment contacts.
258261 see more: https://resend.com/docs/api-reference/contacts/list-contacts
259262
260263 Args:
261- audience_id (Optional[str]): The audience ID. If not provided, lists all global contacts .
264+ audience_id (Optional[str]): Deprecated. Use segment_id instead .
262265 params (Optional[ListParams]): Optional pagination parameters
263266 - limit: Number of contacts to retrieve (max 100, min 1).
264267 If not provided, all contacts will be returned without pagination.
265268 - after: ID after which to retrieve more contacts
266269 - before: ID before which to retrieve more contacts
270+ segment_id (Optional[str]): The segment ID. When provided, lists contacts
271+ in the segment via GET /segments/{segment_id}/contacts.
267272
268273 Returns:
269274 ListResponse: A list of contact objects
270275 """
271- if audience_id :
272- # Audience-specific contacts
276+ if segment_id :
277+ base_path = f"/segments/{ segment_id } /contacts"
278+ elif audience_id :
273279 base_path = f"/audiences/{ audience_id } /contacts"
274280 else :
275- # Global contacts
276281 base_path = "/contacts"
277282
278283 query_params = cast (Dict [Any , Any ], params ) if params else None
@@ -419,21 +424,28 @@ async def update_async(cls, params: UpdateParams) -> UpdateContactResponse:
419424
420425 @classmethod
421426 async def list_async (
422- cls , audience_id : Optional [str ] = None , params : Optional [ListParams ] = None
427+ cls ,
428+ audience_id : Optional [str ] = None ,
429+ params : Optional [ListParams ] = None ,
430+ segment_id : Optional [str ] = None ,
423431 ) -> ListResponse :
424432 """
425433 List all contacts (async).
426- Can list either global contacts or audience-specific contacts.
434+ Can list global contacts, audience-specific contacts, or segment contacts.
427435 see more: https://resend.com/docs/api-reference/contacts/list-contacts
428436
429437 Args:
430- audience_id (Optional[str]): The audience ID. If not provided, lists all global contacts .
438+ audience_id (Optional[str]): Deprecated. Use segment_id instead .
431439 params (Optional[ListParams]): Optional pagination parameters
440+ segment_id (Optional[str]): The segment ID. When provided, lists contacts
441+ in the segment via GET /segments/{segment_id}/contacts.
432442
433443 Returns:
434444 ListResponse: A list of contact objects
435445 """
436- if audience_id :
446+ if segment_id :
447+ base_path = f"/segments/{ segment_id } /contacts"
448+ elif audience_id :
437449 base_path = f"/audiences/{ audience_id } /contacts"
438450 else :
439451 base_path = "/contacts"
0 commit comments