Request
Basic information
| Field | Value |
|---|---|
| HTTP URL | https://api.dingtalk.io/v1.0/calendar/users/{userId}/subscribedCalendars |
| HTTP Method | POST |
| 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 header
| Name | Type | Required | Description |
|---|---|---|---|
| x-acs-dingtalk-access-token | String | Yes | The access credential used to call this API. Obtain it as follows: - For an internal app, call the Get the access token of an internal app API. - For a third-party enterprise app, call the Get the access token of an enterprise that authorized a third-party app API. - For a third-party personal app, call the Get the user token API. |
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
| userId | String | Yes | The unionId of the calendar creator. - For an internal app or a third-party enterprise app, call the Query user details API to obtain the value of the unionid parameter. - For a third-party personal app, call the Get the user’s contact profile API to obtain the value of the unionId parameter. |
Request body
| Name | Type | Required | Description |
|---|---|---|---|
| name | String | Yes | The name of the subscription calendar. |
| description | String | No | The description of the subscription calendar. Maximum length: 1,024 characters. |
| managers | Array of String | No | The unionId values of the co-editors of the subscription calendar. - For an internal app or a third-party enterprise app, call the Query user details API to obtain the value of the unionid parameter. - For a third-party personal app, call the Get the user’s contact profile API to obtain the value of the unionId parameter. |
| subscribeScope | Object | Yes | The objects that can subscribe to this calendar. |
| unionIds | Array of String | No | The unionId values of the users that can subscribe to this calendar. - For an internal app or a third-party enterprise app, call the Query user details API to obtain the value of the unionid parameter. - For a third-party personal app, call the Get the user’s contact profile API to obtain the value of the unionId parameter. |
| openConversationIds | Array of String | No | The list of OpenConversationIds of the groups that can subscribe to this calendar. - For an internal app, call the Get the OpenConversationId of a group chat API to obtain the value of the openConversationId parameter. - For a third-party enterprise app, call the Create a group API to obtain the value of the open_conversation_id parameter. - The unionId of the event creator must belong to a group specified in openConversationIds or to an organization specified in corpIds. - This parameter is not required for a third-party personal app. |
| corpIds | Array of String | No | The list of organization corpIds that can subscribe to this calendar. Sign in to the DingTalk Developer Console and view your organization ID on the Home page. The unionId of the event creator must belong to the organization specified by corpId or to a group specified in openConversationIds. |
Request example
HTTPResponse
Response body
| Name | Type | Description |
|---|---|---|
| calendarId | String | The ID of the subscription calendar. |
Response body example
Error codes
If the API call returns an error, refer to the Global error codes document to find a solution based on the error message.| HttpCode | Error code | Error message | Description |
|---|---|---|---|
| 400 | invalidParameter | forwardErrorMessage | Invalid parameter |
| 400 | invalidParameter | calendar name cannot be blank | The calendar name 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 range 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 |