API call description
- When a user sends an image, voice, video, file, or rich text message to the bot, obtain the temporary download code
downloadCodefrom the information that the bot returns to the developer through the callback. - Use the temporary download code
downloadCodeto call this API and obtain the temporary download link for the image, voice, file, or video in the message. - Access the temporary download link to retrieve the file content.
Description
- In a group chat: When a group member @s the bot, the bot does not support receiving voice, file, or video messages.
- In a one-to-one chat between users: The bot does not support receiving voice, file, or video messages.
- In a one-to-one chat between a user and a bot: The bot supports receiving voice, file, and video messages.
Request
Basic information
| Field | Value |
|---|---|
| HTTP URL | https://api.dingtalk.io/v1.0/robot/messageFiles/download |
| HTTP Method | POST |
| Supported app types | appType-Internal app appType-Third-party enterprise app |
| Required permission | permission-qyapi_robot_sendmsg-Permission to send messages from a bot in your organization |
Request header
| 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 Obtain the access token of an internal app API. - For a third-party enterprise app, call the Obtain the access token of an enterprise authorized by a third-party app API. |
Request body
| Name | Type | Required | Description |
|---|---|---|---|
| downloadCode | String | Yes | The download code returned by the bot to the developer after a user sends a file message to the bot. For more information, see Bot receives messages. |
| robotCode | String | Yes | The code of the bot. For more information, see Bot ID. |
Request example
HTTPResponse
Response body
| Name | Type | Description |
|---|---|---|
| downloadUrl | String | The temporary download link for the file. Access the temporary download link to retrieve the file. After the file is downloaded locally, the developer must replace the local file extension. For example, to replace a video file extension: - Before: iAEI******IVAiYgXNCKMGzSsRB85j_Z7zCM0CYA.file. - After: iAEI******IVAiYgXNCKMGzSsRB85j_Z7zCM0CYA.mp4. |
Response body example
Error codes
If an error occurs when you call this API, look up the solution in the Global error codes document based on the error message.| HttpCode | Error code | Error message | Description |
|---|---|---|---|
| 400 | invalidParameter.robotCode.empty | The bot robotCode is empty. | The bot robotCode is invalid. Check whether the bot is in the group. |
| 400 | invalidParameter.robotCode.auth | This downloadCode does not match the bot robotCode. Use the robotCode of the bot that received this message and the corresponding downloadCode. | This downloadCode does not match the bot robotCode. Use the robotCode of the bot that received this message and the corresponding downloadCode. |
| 400 | invalidParameter.robotCode.empty | The bot downloadCode is empty. | The bot downloadCode is empty. |
| 400 | invalidParameter.robotCode.auth | This API can only be called by an internal app or an authorized third-party app. | This API can only be called by an internal app or an authorized third-party app. |
| 400 | invalidParameter.robotCode.downloadCode | The download code is incorrect or has expired. | The download code is incorrect or has expired. |
| 400 | invalidParameter.robotCode.auth | The organization that calls this API is different from the organization to which the bot corresponding to this downloadCode belongs. | The organization that calls this API is different from the organization to which the bot corresponding to this downloadCode belongs. |