Chats

Pachca.get_chats(sort_field: Literal['id', 'last_message_at'] = 'id', sort_direction: Literal['asc', 'desc'] = 'desc', availability: Literal['is_member', 'public'] = 'is_member', last_message_at_after: str | None = None, last_message_at_before: str | None = None, personal: bool | None = None, limit: int = 50) list[dict]

Gets available chats according to https://crm.pachca.com/dev/chats/list/

Parameters:
  • sort_field (str) – Sort field: ‘id’ or ‘last_message_at’.

  • sort_direction (str) – Sort direction: ‘asc’ or ‘desc’.

  • availability (str) – Chat availability: ‘public’ or ‘is_member’ (access token user).

  • last_message_at_after (str) – Chats with last messages written after ‘YYYY-MM-DDThh:mm:ss.sssZ’.

  • last_message_at_before – Chats with last messages written before ‘YYYY-MM-DDThh:mm:ss.sssZ’.

  • personal (bool) – Get personal chats.

  • limit (50) – Number of items per request (max 50).

Returns:

List of chats.

Return type:

list[dict]

Pachca.find_chats(name: str) list[dict]

Return chats with specified name, if exists.

Parameters:

name (str) – Name to search.

Returns:

List of chats.

Return type:

list[dict]

Pachca.get_chat(chat_id: int) dict

Get chat by ID.

Parameters:

chat_id (int) – Unique integer chat ID.

Returns:

Chat parameters.

Return type:

dict

Pachca.create_chat(name: str, member_ids: list[int] | None = None, group_tag_ids: list[int] | None = None, channel: bool = False, public: bool = False, ignore_existing: bool = True) dict

Create new chat.

Parameters:
  • name (str) – Name of the new chat.

  • member_ids (list[int]) – Member IDs (aka user IDs) of new chat.

  • group_tag_ids – (list[int]): (User) Group Tag IDs of new chat.

  • channel (bool) – Simple chat (False) or read-only channel (only editors can write messages)

  • public (bool) – Is chat should be public or private.

  • ignore_existing (bool) – False will raise the PachcaChatAlreadyExists exception if chat with name already exists.

Returns:

Parameters of created chat.

Return type:

dict

Pachca.update_chat(chat_id: int, name: str | None = None, public: bool | None = None, ignore_existing: bool = True) dict

Update chat name or public flag (access type).

Parameters:
  • chat_id (int) – Chat unique ID.

  • name (str, optional) – New name of the chat.

  • public (bool, optional) – New access type: public or private.

  • ignore_existing (bool) – False will raise the PachcaChatAlreadyExists exception if chat with name already exists.

Returns:

Parameters of created chat.

Return type:

dict

Pachca.archive_chat(chat_id: int) dict

Archive chat.

Parameters:

chat_id (int) – Chat ID.

Pachca.unarchive_chat(chat_id: int) dict

Unarchive chat.

Parameters:

chat_id (int) – Chat ID.