Request
Basic information
| Field | Value |
|---|---|
| HTTP URL | https://api.dingtalk.io/v1.0/doc/workspaces/{workspaceId}/docs |
| HTTP Method | POST |
| Supported app types | appType-Internal app appType-Third-party enterprise app |
| Permissions | permission-Document.WorkspaceDocument.Write-Knowledge Base document write permission |
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 enterprise authorized to a third-party app API. |
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
| workspaceId | String | Yes | The Knowledge Base ID. Obtain the value of the workspaceId field by calling the Create a Knowledge Base API or the Get the Knowledge Base list API. |
Request body
| Name | Type | Required | Description |
|---|---|---|---|
| name | String | Yes | The document name. |
| docType | String | Yes | The document type. Valid values: - DOC: Document - WORKBOOK: Spreadsheet - MIND: Mind Map - FOLDER: Folder |
| operatorId | String | Yes | The unionId of the user. Obtain it by calling the Query user details API. |
| parentNodeId | String | No | The parent node ID. Obtain the value of the DentryModel parameter by calling the Get the node list API. If not specified, the document is created in the root directory by default. The parent node can be a folder or a regular document. |
| templateId | String | No | The document template ID. |
| templateType | String | No | The document template type. Valid values: - public_template: Recommends - team_template: Team template - user_template: Personal template |
Request example
HTTPResponse
Response body
| Name | Type | Description |
|---|---|---|
| workspaceId | String | The Knowledge Base ID. |
| nodeId | String | The Knowledge Base document ID. |
| docKey | String | The document docKey. |
| url | String | The document URL. |
| dentryUuid | String | The UUID of the returned file. |
Response example
Error codes
If an error is returned when you call this API, refer to the Global error codes document for solutions based on the error message.| HttpCode | Error code | Error message | Description |
|---|---|---|---|
| 400 | invalidRequest.workspaceNode.nameConflict | Knowledge Base document name conflict | Knowledge Base document name conflict. |
| 400 | invalidRequest.inputArgs.invalid | Method parameter validation failed | Method parameter validation failed. Check whether any required parameters are missing or whether the unionId is valid. |
| 400 | invalidRequest.workspaceNode.parentNotFound | Parent node does not exist | Parent node does not exist. |
| 400 | invalidRequest.template.notFound | Document template does not exist | Document template does not exist. |
| 403 | forbidden.user.notInOrg | The operator is not in the organization | The operator is not in the organization. |
| 403 | forbidden.accessDenied | The user does not have operation permissions | The user does not have operation permissions. |
| 404 | invalidRequest.resource.notFound | Resource not found | Resource not found. |
| 404 | invalidRequest.workspace.deleted | The Knowledge Base has been deleted | The Knowledge Base has been deleted. |
| 500 | internalError | Internal system error | Internal system error. |