> ## Documentation Index
> Fetch the complete documentation index at: https://docs.camel-ai.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Camel.toolkits.lark toolkit

<a id="camel.toolkits.lark_toolkit" />

<a id="camel.toolkits.lark_toolkit.LarkToolkit" />

## LarkToolkit

```python theme={"system"}
class LarkToolkit(BaseToolkit):
```

A toolkit for Lark (Feishu) chat operations.

<a id="camel.toolkits.lark_toolkit.LarkToolkit.__init__" />

### **init**

```python theme={"system"}
def __init__(
    self,
    app_id: Optional[str] = None,
    app_secret: Optional[str] = None,
    use_feishu: bool = False,
    timeout: Optional[float] = None
):
```

Initializes the LarkToolkit.

**Parameters:**

* **app\_id** (Optional\[str]): The Lark application ID. If not provided, uses LARK\_APP\_ID environment variable.
* **app\_secret** (Optional\[str]): The Lark application secret. If not provided, uses LARK\_APP\_SECRET environment variable.
* **use\_feishu** (bool): Set to True to use Feishu (China) API endpoints instead of Lark (international). (default: :obj:`False`)
* **timeout** (Optional\[float]): Request timeout in seconds.

<a id="camel.toolkits.lark_toolkit.LarkToolkit._get_tenant_http_headers" />

### \_get\_tenant\_http\_headers

```python theme={"system"}
def _get_tenant_http_headers(self):
```

**Returns:**

Dict\[str, str]: Headers dict with Content-Type and Authorization.

<a id="camel.toolkits.lark_toolkit.LarkToolkit._convert_timestamp" />

### \_convert\_timestamp

```python theme={"system"}
def _convert_timestamp(self, ts: Any):
```

Convert millisecond timestamp to readable datetime string.

**Parameters:**

* **ts**: Timestamp value (can be string or int, in milliseconds).

**Returns:**

str: ISO format datetime string, or original value if conversion
fails.

<a id="camel.toolkits.lark_toolkit.LarkToolkit._process_message_items" />

### \_process\_message\_items

```python theme={"system"}
def _process_message_items(self, items: List[Dict[str, Any]]):
```

Process message items to agent-friendly format.

**Parameters:**

* **items**: List of message items from API response.

**Returns:**

List\[Dict\[str, Any]]: Simplified items with only essential fields.

<a id="camel.toolkits.lark_toolkit.LarkToolkit.lark_list_chats" />

### lark\_list\_chats

```python theme={"system"}
def lark_list_chats(
    self,
    sort_type: Literal['ByCreateTimeAsc', 'ByActiveTimeDesc'] = 'ByCreateTimeAsc',
    page_size: int = 20,
    page_token: Optional[str] = None
):
```

Lists chats and groups that the user belongs to.

Use this method to discover available chats and obtain chat\_id values.

**Parameters:**

* **sort\_type** (str): Sort order for chats. Options: - "ByCreateTimeAsc" (default) - "ByActiveTimeDesc"
* **page\_size** (int): Number of chats to return per page (max 100). (default: :obj:`20`)
* **page\_token** (Optional\[str]): Token for pagination. Use the page\_token from previous response to get next page.

**Returns:**

Dict\[str, object]: A dictionary containing:

* chats: List of chat objects with chat\_id and name
* has\_more: Whether there are more chats to fetch
* page\_token: Token to fetch the next page

<a id="camel.toolkits.lark_toolkit.LarkToolkit.lark_get_chat_messages" />

### lark\_get\_chat\_messages

```python theme={"system"}
def lark_get_chat_messages(
    self,
    container_id: str,
    container_id_type: Literal['chat', 'thread'] = 'chat',
    start_time: Optional[str] = None,
    end_time: Optional[str] = None,
    sort_type: Literal['ByCreateTimeAsc', 'ByCreateTimeDesc'] = 'ByCreateTimeAsc',
    page_size: int = 20,
    page_token: Optional[str] = None
):
```

Gets message history from a chat with optional time filtering.

Retrieves messages from a specific chat. Requires the bot to be a
member of the chat.

**Parameters:**

* **container\_id** (str): The container ID to retrieve messages from.
* **container\_id\_type** (str): The container type. Options: - "chat": Chat (p2p or group) - "thread": Thread
* **start\_time** (Optional\[str]): Start time filter (Unix timestamp in seconds, e.g., "1609459200"). Messages created after this time. Not supported for "thread" container type.
* **end\_time** (Optional\[str]): End time filter (Unix timestamp in seconds). Messages created before this time. Not supported for "thread" container type.
* **sort\_type** (str): Sort order for messages. Options: - "ByCreateTimeAsc": Oldest first (default) - "ByCreateTimeDesc": Newest first
* **page\_size** (int): Number of messages to return per page (max 50). (default: :obj:`20`)
* **page\_token** (Optional\[str]): Token for pagination. Use the page\_token from previous response to get next page.

**Returns:**

Dict\[str, object]: A dictionary containing:

* messages: List of processed message objects with fields:
* message\_id: Message identifier
* msg\_type: Message type (text, image, file, etc.)
* text: Extracted message text content
* time: Human-readable timestamp (UTC)
* sender\_id: Sender's user ID
* sender\_type: Type of sender
* has\_more: Whether there are more messages to fetch
* page\_token: Token to fetch the next page

<a id="camel.toolkits.lark_toolkit.LarkToolkit.lark_send_message" />

### lark\_send\_message

```python theme={"system"}
def lark_send_message(
    self,
    receive_id: str,
    text: str,
    receive_id_type: Literal['open_id', 'user_id', 'union_id', 'email', 'chat_id'] = 'chat_id'
):
```

Sends a message to a user or chat. If send message to
a chat, use lark\_list\_chats to get chat\_id first, if send
message to a user, need user provide open\_id, user\_id,
union\_id or email.

**Parameters:**

* **receive\_id** (str): The recipient identifier.
* **text** (str): The text message content.
* **receive\_id\_type** (str): The recipient ID type. Options: - "open\_id" - "user\_id" - "union\_id" - "email" - "chat\_id" (default)

**Returns:**

Dict\[str, object]: A dictionary containing:

* message\_id: The sent message ID
* chat\_id: The chat ID the message belongs to
* msg\_type: Message type (text)

<a id="camel.toolkits.lark_toolkit.LarkToolkit.lark_get_message_resource" />

### lark\_get\_message\_resource

```python theme={"system"}
def lark_get_message_resource(
    self,
    message_id: str,
    file_key: str,
    resource_type: Literal['image', 'file']
):
```

Obtains resource files in messages, including audios, videos,
images, and files. Emoji resources cannot be downloaded, and the
resource files for download cannot exceed 100 MB.

**Parameters:**

* **message\_id** (str): The message ID containing the resource.
* **file\_key** (str): The resource file key from message content.
* **resource\_type** (str): Resource type, either "image" or "file".

**Returns:**

Dict\[str, object]: A dictionary containing:

* content\_type: Response Content-Type header value
* path: File path where content was saved
* size: Content size in bytes

<a id="camel.toolkits.lark_toolkit.LarkToolkit.lark_get_message_resource_key" />

### lark\_get\_message\_resource\_key

```python theme={"system"}
def lark_get_message_resource_key(self, message_id: str):
```

Gets the resource key from a message's content.

**Parameters:**

* **message\_id** (str): The message ID to fetch.

**Returns:**

Dict\[str, object]: A dictionary containing:

* key: The resource key from message content

<a id="camel.toolkits.lark_toolkit.LarkToolkit.get_tools" />

### get\_tools

```python theme={"system"}
def get_tools(self):
```

**Returns:**

List\[FunctionTool]: A list of FunctionTool objects
representing the functions in the toolkit.
