订阅日历
调用该接口以当前身份(应用或用户)订阅指定的日历。
Tip: - 当前身份由 Header Authorization 的 Token 类型决定。tenant_access_token 指应用身份,user_access_token 指用户身份。
请求
| 项目 | 值 |
|---|---|
| HTTP URL | https://open.feishu.cn/open-apis/calendar/v4/calendars/:calendar_id/subscribe |
| HTTP Method | POST |
| 接口频率限制 | 1000 次/分钟、50 次/秒 |
| 支持的应用类型 | custom,isv |
| 权限要求 调用该 API 所需的权限。开启其中任意一项权限即可调用 开启任一权限即可 | calendar:calendar 更新日历及日程信息 calendar:calendar:subscribe 订阅、退订日历 |
请求头
| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
| Authorization | string | 是 | tenant_access_token 或 user_access_token 值格式:"Bearer access_token" 示例值:"Bearer u-7f1bcd13fc57d46bac21793a18e560" 了解更多:如何选择与获取 access token |
路径参数
| 名称 | 类型 | 描述 |
|---|---|---|
calendar_id | string | 日历ID。 创建共享日历时会返回日历 ID。你也可以调用以下接口获取某一日历的 ID。 - 查询主日历信息 - 查询日历列表 - 搜索日历 示例值:"feishu.cn_xxxxxxxxxx@group.calendar.feishu.cn" |
响应
响应体
| 名称 | 类型 | 描述 |
|---|---|---|
code | int | 错误码,非 0 表示失败 |
msg | string | 错误描述 |
data | \- | - |
└ calendar | calendar | 订阅的日历实体。 |
└ calendar_id | string | 日历 ID。后续可以通过该 ID 查询、更新或删除日历信息。更多信息参见日历 ID 字段说明。 |
└ summary | string | 日历标题。 |
└ description | string | 日历描述。 |
└ permissions | string | 日历公开范围。 可选值有: - private: 私密 - show_only_free_busy: 仅展示忙闲信息 - public: 公开,他人可查看日程详情 |
└ color | int | 日历颜色,由颜色 RGB 值的 int32 表示。实际在客户端展示时会映射到色板上最接近的一种颜色,且该字段仅对当前身份生效。 |
└ type | string | 日历类型。 可选值有: - unknown: 未知类型 - primary: 用户或应用的主日历 - shared: 由用户或应用创建的共享日历 - google: 用户绑定的谷歌日历 - resource: 会议室日历 - exchange: 用户绑定的 Exchange 日历 |
└ summary_alias | string | 日历备注名,仅对当前身份生效。 |
└ is_deleted | boolean | 对于当前身份,日历是否已经被标记为删除。 |
└ is_third_party | boolean | 当前日历是否是第三方数据。三方日历及日程只支持读,不支持写入。 |
└ role | string | 当前身份对于该日历的访问权限。 可选值有: - unknown: 未知权限 - free_busy_reader: 游客,只能看到忙碌、空闲信息 - reader: 订阅者,可查看所有日程详情 - writer: 编辑者,可创建及修改日程 - owner: 管理员,可管理日历及共享设置 |
响应体示例
json
{
"code": 0,
"msg": "success",
"data": {
"calendar": {
"calendar_id": "feishu.cn_xxxxxxxxxx@group.calendar.feishu.cn",
"summary": "测试日历",
"description": "使用开放接口创建日历",
"permissions": "private",
"color": -1,
"type": "shared",
"summary_alias": "日历备注名",
"is_deleted": false,
"is_third_party": false,
"role": "owner"
}
}
}错误码
| HTTP状态码 | 错误码 | 描述 | 排查建议 |
|---|---|---|---|
| 400 | 190002 | invalid parameters in request | 无效的请求参数。排查建议如下: - 确认请求参数的字段名称、传参类型正确。 - 确认已经申请了相应资源的权限。 - 确认相应资源未被删除。 |
| 500 | 190003 | internal service error | 内部服务错误,请咨询技术支持。 |
| 429 | 190004 | method rate limited | 方法频率限制。建议稍后再试,并适当减小请求 QPS。 |
| 429 | 190005 | app rate limited | 应用频率限制。建议稍后再试,并适当减小请求 QPS。 |
| 403 | 190006 | wrong unit for app tenant | 请求错误,检查应用 App ID 和 App Secret 是否正确。如仍无法解决请咨询技术支持。 |
| 404 | 190007 | app bot_id not found | 应用的 bot_id 没有找到。你需要确保应用开启了机器人能力。如仍未解决请咨询技术支持。 |
| 429 | 190010 | current operation rate limited | 当前操作被限流,原因一般为公用资源并发抢占失败。你可以适当降低当前操作频率,然后重试。 |
| 400 | 190014 | invalid request parameters. check details for more info. | 无效的请求参数。请从details字段查看详细原因。 |
| 404 | 191000 | calendar not found | 日历没有找到。你需要检查并改为正确的日历 ID。 |
| 400 | 191001 | invalid calendar_id | calendar_id 无效。你需要检查并改为正确的日历 ID。 |
| 403 | 191002 | no calendar access_role | 当前身份没有日历的访问权限。如需查询某一日历信息,则需要确保当前身份拥有该日历的访问权限。 |
| 403 | 191003 | calendar is deleted | 日历已经被删除。你需要检查并改为正确的日历 ID。 |
| 403 | 191004 | invalid calendar type | 日历类型错误。你可以调用查询日历信息接口获取日历类型信息,然后确保日历类型适用于当前接口。 |
| 400 | 191005 | subscribe calendars count rich limit | 订阅日历数量已达上限(同一身份可订阅日历数量上限为 1000)。建议取消订阅其他不再使用的日历,然后重试。 |
| 400 | 191006 | subscribe target calendar is not allowed | - 不允许订阅机器人的主日历。 - 不允许订阅其他租户或者公开范围为私密的日历。你可以调用查询日历信息接口获取日历的公开范围、类型以及访问权限等信息,并确保传入的日历适用于当前接口。 |
| 404 | 195100 | user is dismiss or not exist in the tenant | 当前身份或指定用户已经离职,或者不在该租户内。请检查并改为正确的身份来调用接口。 |
更多错误码信息,参见通用错误码。
