Request
Basic information
| Field | Value |
|---|---|
| HTTP URL | https://api.dingtalk.io/v1.0/calendar/users/{userId}/subscribedCalendars/{calendarId} |
| HTTP Method | PUT |
| Supported app types | appType-Internal app appType-Third-party enterprise app appType-Third-party personal app |
| Required permissions | permission-Calendar.Calendar.Write-Write permission for the Calendar app |
Request headers
| Name | Type | Required | Description |
|---|---|---|---|
| x-acs-dingtalk-access-token | String | Yes | The access credential for calling this API. Obtain it as follows: - For an internal app, call Obtain the access token of an internal app. - For a third-party enterprise app, call Obtain the access token of an authorized enterprise for a third-party app. - For a third-party personal app, call Obtain a user token. |
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
| calendarId | String | Yes | The subscription calendar ID. Call Create a subscription calendar to obtain the value of the calendarId parameter. |
| userId | String | Yes | The unionId of the calendar author or co-editor. - For internal apps and third-party enterprise apps, call Query user details to obtain the value of the unionid parameter. - For third-party personal apps, call Obtain the profile of a Contacts user to obtain the value of the unionId parameter. |
Request body
| Name | Type | Required | Description |
|---|---|---|---|
| name | String | No | The title of the subscription calendar. |
| description | String | No | The description of the subscription calendar. |
| managers | Array of String | No | The unionId list of the calendar co-editors. - For internal apps and third-party enterprise apps, call Query user details to obtain the value of the unionid parameter. - For third-party personal apps, call Obtain the profile of a Contacts user to obtain the value of the unionId parameter. |
| subscribeScope | Object | No | The subscription scope of the calendar. |
| unionIds | Array of String | No | The unionIds of the users who can subscribe to the calendar. - For internal apps and third-party enterprise apps, call Query user details to obtain the value of the unionid parameter. - For third-party personal apps, call Obtain the profile of a Contacts user to obtain the value of the unionId parameter. |
| openConversationIds | Array of String | No | The OpenConversationId list of the groups that can subscribe to this calendar. - For an internal app, call Obtain the OpenConversationId of a group chat to obtain the value of the openConversationId parameter. - For a third-party enterprise app, call Create a group to obtain the value of the open_conversation_id parameter. - You must pass the OpenConversationId of the group that the subscription event creator belongs to. - For a third-party personal app, this parameter is not required. |
| corpIds | Array of String | No | The corpId list of the organizations that can subscribe to this calendar. Sign in to the DingTalk Developer Console and view your organization ID on the Home page. You must pass the corpId of the organization that the subscription event creator belongs to. |
Request example
HTTPResponse
Response body
| Name | Type | Description |
|---|---|---|
| result | Boolean | Whether the API call succeeded. true indicates success. |
Response body example
Error codes
If an error is returned when calling this API, find the solution in the Global error codes document based on the error message.| HttpCode | Error code | Error message | Description |
|---|---|---|---|
| 400 | invalidParameter | forwardErrorMessage | Parameter error |
| 400 | invalidParameter | calendar id cannot be blank | The calendar ID cannot be empty |
| 400 | invalidParameter | calendar name length must less than 128 | The calendar name cannot exceed 128 characters |
| 400 | invalidParameter | subscribe range cannot be null | The subscription scope cannot be empty |
| 400 | invalidParameter | calendar name cannot be blank | The calendar name cannot be empty |
| 400 | invalidParameter | current user must in range | The current user must be in the corresponding group and organization |
| 403 | permissionDenied | permission denied | Authentication failed |