创建标签
根据用户指定的名称、颜色等信息,创建邮件标签
请求
| 项目 | 值 |
|---|---|
| HTTP URL | https://open.feishu.cn/open-apis/mail/v1/user_mailboxes/:user_mailbox_id/labels |
| HTTP Method | POST |
| 接口频率限制 | 5 次/秒 |
| 支持的应用类型 | custom |
| 权限要求 调用该 API 所需的权限。开启其中任意一项权限即可调用 | mail:user_mailbox.message:modify 修改邮件 |
请求头
| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
| Authorization | string | 是 | tenant_access_token 或 user_access_token 值格式:"Bearer access_token" 示例值:"Bearer u-7f1bcd13fc57d46bac21793a18e560" 了解更多:如何选择与获取 access token |
| Content-Type | string | 是 | 固定值:"application/json; charset=utf-8" |
路径参数
| 名称 | 类型 | 描述 |
|---|---|---|
user_mailbox_id | string | 用户邮箱地址。当使用用户身份访问时,可以输入"me"代表当前调用接口用户 示例值:"user@xxx.xx 或 me" |
请求体
| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
label | \- | 是 | 邮件标签,必须填写标签名称,可选填写背景颜色 |
└ name | string | 是 | 标签名称,必须填写。最长255个字符。 示例值:"test" |
└ background_color | string | 否 | 标签背景颜色,支持以下颜色值:blue、indigo、purple、violet、carmine、red、orange、yellow、lime、green、turquoise、wathet 示例值:"blue" |
请求体示例
json
{
"label": {
"name": "test",
"background_color": "blue"
}
}响应
响应体
| 名称 | 类型 | 描述 |
|---|---|---|
code | int | 错误码,非 0 表示失败 |
msg | string | 错误描述 |
data | \- | - |
└ label | label | 标签 |
└ id | string | 标签ID |
└ name | string | 标签名称,最长 255 个字符。支持嵌套标签,嵌套层级之间以 / 分隔(如 a/b/c 表示三级嵌套标签)。创建或更新嵌套标签时,需要传入完整路径(如 a/b/c),不能只传最后一级名称。 |
└ background_color | string | 标签背景颜色,支持以下颜色值:blue、indigo、purple、violet、carmine、red、orange、yellow、lime、green、turquoise、wathet |
└ messages_unread | int | 带有该标签的未读邮件数量 |
响应体示例
json
{
"code": 0,
"msg": "success",
"data": {
"label": {
"id": "7620003644728938013",
"name": "test",
"background_color": "blue",
"messages_unread": 0
}
}
}错误码
| HTTP状态码 | 错误码 | 描述 | 排查建议 |
|---|---|---|---|
| 400 | 1234000 | invalid params | 参数错误,请参考此文档检查参数 |
| 500 | 1234017 | internal error | 服务器内部错误,请稍后重试 |
| 403 | 1234030 | permission deny | 无权限访问此资源,请检查权限申请状态 |
| 400 | 1234013 | user mailbox not found or user mailbox not active | 指定邮箱地址不存在或邮箱状态不正确,请检查输入的邮箱地址 |
| 400 | 1230101 | label name already exists | 指定的标签名称已经存在,无法重复创建,请修改标签名称 |
| 400 | 1230102 | label count exceeds the limit | 已有的标签数量超过上限,无法继续创建,请减少标签数量后重试 |
| 400 | 1230103 | label name is reserved by system | 自定义标签无法使用系统内置的标签名称,请修改标签名称后创建 |
