Skip to content

创建标签

根据用户指定的名称、颜色等信息,创建邮件标签

请求

项目
HTTP URLhttps://open.feishu.cn/open-apis/mail/v1/user_mailboxes/:user_mailbox_id/labels
HTTP MethodPOST
接口频率限制5 次/秒
支持的应用类型custom
权限要求 调用该 API 所需的权限。开启其中任意一项权限即可调用mail:user_mailbox.message:modify 修改邮件

请求头

名称类型必填描述
Authorizationstringtenant_access_tokenuser_access_token 值格式:"Bearer access_token" 示例值:"Bearer u-7f1bcd13fc57d46bac21793a18e560" 了解更多:如何选择与获取 access token
Content-Typestring固定值:"application/json; charset=utf-8"

路径参数

名称类型描述
user_mailbox_idstring用户邮箱地址。当使用用户身份访问时,可以输入"me"代表当前调用接口用户
示例值:"user@xxx.xx 或 me"

请求体

名称类型必填描述
label\-邮件标签,必须填写标签名称,可选填写背景颜色
  └ namestring标签名称,必须填写。最长255个字符。
示例值:"test"
  └ background_colorstring标签背景颜色,支持以下颜色值:blue、indigo、purple、violet、carmine、red、orange、yellow、lime、green、turquoise、wathet
示例值:"blue"

请求体示例

json
{
    "label": {
        "name": "test",
        "background_color": "blue"
    }
}

响应

响应体

名称类型描述
codeint错误码,非 0 表示失败
msgstring错误描述
data\--
  └ labellabel标签
    └ idstring标签ID
    └ namestring标签名称,最长 255 个字符。支持嵌套标签,嵌套层级之间以 / 分隔(如 a/b/c 表示三级嵌套标签)。创建或更新嵌套标签时,需要传入完整路径(如 a/b/c),不能只传最后一级名称。
    └ background_colorstring标签背景颜色,支持以下颜色值:blue、indigo、purple、violet、carmine、red、orange、yellow、lime、green、turquoise、wathet
    └ messages_unreadint带有该标签的未读邮件数量

响应体示例

json
{
    "code": 0,
    "msg": "success",
    "data": {
        "label": {
            "id": "7620003644728938013",
            "name": "test",
            "background_color": "blue",
            "messages_unread": 0
        }
    }
}

错误码

HTTP状态码错误码描述排查建议
4001234000invalid params参数错误,请参考此文档检查参数
5001234017internal error服务器内部错误,请稍后重试
4031234030permission deny无权限访问此资源,请检查权限申请状态
4001234013user mailbox not found or user mailbox not active指定邮箱地址不存在或邮箱状态不正确,请检查输入的邮箱地址
4001230101label name already exists指定的标签名称已经存在,无法重复创建,请修改标签名称
4001230102label count exceeds the limit已有的标签数量超过上限,无法继续创建,请减少标签数量后重试
4001230103label name is reserved by system自定义标签无法使用系统内置的标签名称,请修改标签名称后创建

内容来源:飞书开放平台 · 自动爬取整理