API call description
Before calling this API, make sure the user has subscription permissions for the calendar.Request
Basic information
| Field | Value |
|---|---|
| HTTP URL | https://api.dingtalk.io/v1.0/calendar/users/{userId}/calendars/{calendarId}/subscribe |
| HTTP Method | POST |
| Supported app types | appType-Internal app appType-Third-party enterprise app appType-Third-party personal app |
| Permissions required | 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 the Get the access token of an internal app API. - For a third-party enterprise app, call the Get the access token of an authorized enterprise for 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 subscriber. - For internal apps and third-party enterprise apps, call the Query user details API to obtain the value of the unionid parameter. - For third-party personal apps, call the Get the user’s Contacts profile API to obtain the value of the unionId parameter. |
| calendarId | String | Yes | The calendar ID. Currently, the subscribe action only supports calendars of type subscribed. The creator of a subscribed calendar or users who have already subscribed to the calendar can obtain it through the Query a calendar API. |
Request example
HTTPResponse
Response body example
Error codes
If an error occurs when calling this API, refer to the Global error codes document to find a solution based on the error message.| HttpCode | Error code | Error message | Description |
|---|---|---|---|
| 400 | permissionDenied | The user is not within the subscription scope | The user is not within the subscription scope |
| 400 | invalidParameter | forwardErrorMessage | Invalid parameter |
| 400 | invalidParameter | calendarId cannot be blank | calendarId cannot be empty |
| 400 | invalidParameter | calendar type invalid | Invalid calendar type |
| 400 | exceedSubscribeLimit | exceed subscribe limit | Subscribed calendars exceed the upper limit |