Skip to content

飞书群公告 API(用户级) ​

接口名称 ​

飞书群公告 API -(IFeishuUserV1ChatGroupAnnouncement)

功能描述 ​

群公告是群组中的公告文档,采用飞书云文档承载,每个群组只有一个群公告,每篇群公告都有唯一的 chat_id 作为标识。 当前接口使用用户令牌访问,适应于用户应用场景。

参考文档 ​

函数列表 ​

函数名称功能描述认证方式HTTP 方法接口文档
GetNoticeInfoByIdAsync获取群公告基本信息用户令牌GETGetNoticeInfoByIdAsync
GetNoticeBlocksListByIdAsync分页获取群公告块列表用户令牌GETGetNoticeBlocksListByIdAsync
CreateNoticeBlockAsync创建群公告块用户令牌POSTCreateNoticeBlockAsync
UpdateNoticeBlockAsync更新群公告块用户令牌PATCHUpdateNoticeBlockAsync
GetBlockContentByIdAsync获取群公告块内容用户令牌GETGetBlockContentByIdAsync
GetBlockContentPageListByIdAsync分页获取块子内容用户令牌GETGetBlockContentPageListByIdAsync
DeleteBlockByIdAsync删除群公告块用户令牌DELETEDeleteBlockByIdAsync

函数详细内容 ​

获取群公告基本信息 ​

函数名称:获取群公告基本信息

函数签名:

csharp
Task<FeishuApiResult<GetAnnouncementResult>?> GetNoticeInfoByIdAsync(
    [Path] string chat_id,
    [Query("user_id_type")] string user_id_type = "open_id",
    CancellationToken cancellationToken = default);

认证:用户令牌

参数:

参数类型必填说明
chat_idstring✅群 ID
user_id_typestring⚪用户 ID 类型,默认值:"open_id"

响应:

json
{
  "code": 0,
  "msg": "success",
  "data": {
    "title": "群公告标题",
    "create_time": "1690000000",
    "edit_time": "1690100000",
    "owner_id": "ou_xxxxxxxx",
    "revision": 5
  }
}

代码示例:

csharp
public class UserAnnouncementService
{
    private readonly IFeishuUserV1ChatGroupAnnouncement _announcementClient;

    public UserAnnouncementService(IFeishuUserV1ChatGroupAnnouncement announcementClient)
    {
        _announcementClient = announcementClient;
    }

    public async Task ShowAnnouncementAsync(string chatId)
    {
        var result = await _announcementClient.GetNoticeInfoByIdAsync(chatId);
        if (result?.Data != null)
        {
            Console.WriteLine($"公告标题: {result.Data.title}");
        }
    }
}

分页获取群公告块列表 ​

函数名称:分页获取群公告块列表

函数签名:

csharp
Task<FeishuApiPageListResult<AnnouncementBlock>?> GetNoticeBlocksListByIdAsync(
    [Path] string chat_id,
    [Query("page_size")] int? page_size = 10,
    [Query("page_token")] string? page_token = null,
    [Query("revision_id")] int? revision_id = -1,
    [Query("user_id_type")] string user_id_type = "open_id",
    CancellationToken cancellationToken = default);

认证:用户令牌

参数:

参数类型必填说明
chat_idstring✅群 ID
page_sizeint?⚪分页大小,默认值:10
page_tokenstring?⚪分页标记
revision_idint?⚪群公告版本,-1 表示最新版本
user_id_typestring⚪用户 ID 类型,默认值:"open_id"

创建群公告块 ​

函数名称:创建群公告块

函数签名:

csharp
Task<FeishuApiResult<CreateBlockResult>?> CreateNoticeBlockAsync(
    [Path] string chat_id,
    [Path] string block_id,
    [Body] CreateBlockRequest createBlockRequest,
    [Query("revision_id")] int revision_id = -1,
    [Query("client_token")] string? client_token = null,
    [Query("user_id_type")] string user_id_type = "open_id",
    CancellationToken cancellationToken = default);

认证:用户令牌

参数:

参数类型必填说明
chat_idstring✅群 ID
block_idstring✅父块 ID
createBlockRequestCreateBlockRequest✅创建块请求体
revision_idint⚪群公告版本,默认值:-1
client_tokenstring?⚪幂等操作标识
user_id_typestring⚪用户 ID 类型,默认值:"open_id"

更新群公告块 ​

函数名称:更新群公告块

函数签名:

csharp
Task<FeishuApiResult<BatchUpdateResult>?> UpdateNoticeBlockAsync(
    [Path] string chat_id,
    [Body] BlocksBatchUpdateRequest batchUpdateRequest,
    [Query("revision_id")] int revision_id = -1,
    [Query("client_token")] string? client_token = null,
    [Query("user_id_type")] string user_id_type = "open_id",
    CancellationToken cancellationToken = default);

认证:用户令牌

参数:

参数类型必填说明
chat_idstring✅群 ID
batchUpdateRequestBlocksBatchUpdateRequest✅批量更新块内容请求体
revision_idint⚪群公告版本,默认值:-1
client_tokenstring?⚪幂等操作标识
user_id_typestring⚪用户 ID 类型,默认值:"open_id"

获取群公告块内容 ​

函数名称:获取群公告块内容

函数签名:

csharp
Task<FeishuApiResult<GetBlockContentListResult>?> GetBlockContentByIdAsync(
    [Path] string chat_id,
    [Path] string block_id,
    [Query("revision_id")] int? revision_id = -1,
    [Query("user_id_type")] string? user_id_type = "open_id",
    CancellationToken cancellationToken = default);

认证:用户令牌

参数:

参数类型必填说明
chat_idstring✅群 ID
block_idstring✅Block 唯一标识
revision_idint?⚪群公告版本,默认值:-1
user_id_typestring?⚪用户 ID 类型,默认值:"open_id"

分页获取块子内容 ​

函数名称:分页获取块子内容

函数签名:

csharp
Task<FeishuApiPageListResult<AnnouncementBlock>?> GetBlockContentPageListByIdAsync(
    [Path] string chat_id,
    [Path] string block_id,
    [Query("page_size")] int? page_size = 10,
    [Query("page_token")] string? page_token = null,
    [Query("revision_id")] int? revision_id = -1,
    [Query("user_id_type")] string? user_id_type = "open_id",
    CancellationToken cancellationToken = default);

认证:用户令牌

参数:

参数类型必填说明
chat_idstring✅群 ID
block_idstring✅Block 唯一标识
page_sizeint?⚪分页大小,默认值:10
page_tokenstring?⚪分页标记
revision_idint?⚪群公告版本,默认值:-1
user_id_typestring?⚪用户 ID 类型,默认值:"open_id"

删除群公告块 ​

函数名称:删除群公告块

函数签名:

csharp
Task<FeishuApiResult<DeleteAnnouncementBlockResult>?> DeleteBlockByIdAsync(
    [Path] string chat_id,
    [Path] string block_id,
    [Body] DeleteAnnouncementBlockRequest deleteRequest,
    [Query("user_id_type")] string? user_id_type = "open_id",
    [Query("client_token")] string? client_token = null,
    CancellationToken cancellationToken = default);

认证:用户令牌

参数:

参数类型必填说明
chat_idstring✅群 ID
block_idstring✅Block 唯一标识
deleteRequestDeleteAnnouncementBlockRequest✅删除请求体
user_id_typestring?⚪用户 ID 类型,默认值:"open_id"
client_tokenstring?⚪幂等操作标识