> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://developers.awork.com/apiv1/documents/put-document-content-by-document-id/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developers.awork.com/_mcp/server. # Updates the specified document content. PUT https://api.awork.com/api/v1/documents/{documentId}/content Content-Type: multipart/form-data Updates document content using UTF-8 HTML or Markdown. Set `contentFormat` to `html` or `markdown`; HTML is the default. Canonical awork Markdown preserves safe editor structures during re-import. The user must have at least `write` permission for the specified document. Reference: https://developers.awork.com/apiv1/documents/put-document-content-by-document-id ## Authentication - `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer `, where token is your auth token. ## Request ### Path parameters - `documentId` (string, required) — The id of the document to update. ### Body (multipart/form-data) This endpoint expects a multipart form containing a file. - `content` (file, required) — The UTF-8 document content. Use Awork.Core.Models.Documents.Documents.DocumentContentForm.ContentFormat to select HTML or Markdown input. - `contentFormat` (enum, optional) — The input format of Awork.Core.Models.Documents.Documents.DocumentContentForm.Content. Defaults to `html`. Canonical awork Markdown supports lossless re-import of safe editor content. ## Response ### 200 OK - `id` (string, optional) — The id of the entity. - `createdOn` (string, optional) — The date this entity was created. - `createdBy` (string, optional) — The id of the user who created this entity. - `updatedOn` (string, optional) — The date this entity was last modified. - `updatedBy` (string, optional) — The id of the user who last modified this entity. - `name` (string, optional, nullable) — The name of the document. - `currentDocumentVersionId` (string, optional, nullable) — The id of the current document version. - `documentSpaceId` (string, optional, nullable) — The id of the document space. - `documentSpace` (DocumentSpaceModel, optional) - `parentId` (string, optional, nullable) — The id of the document's parent document. - `projectId` (string, optional, nullable) — The id of the project this document references. - `project` (PermissionProject, optional) - `taskId` (string, optional, nullable) — The id of the task this document references. - `emoji` (string, optional, nullable) — The emoji of the document. - `isPrivate` (boolean, optional) — Whether the document is private. - `order` (double, optional, nullable) — The order of the document in either the list of private docs, the referenced document space or in the referenced project. - `isExternal` (boolean, optional) — Whether the document belongs to an external project. - `isHiddenForConnectUsers` (boolean, optional) — Whether the document is hidden for connect users. - `contributors` (list of DocumentContributorModel, optional, nullable) — The contributors of this document. - `teams` (list of DocumentToTeamModel, optional, nullable) — The teams this document is connected to. - `workspaceAccessLevel` (string, optional, nullable) — Determines the level of access to this document granted to all workspace users. Can be either not set (no access), `read`, or `manage`. - `inheritedWorkspaceAccessFromDocumentId` (string, optional, nullable) — The id of the document the workspace access level permission has been inherited from. - `inheritedWorkspaceAccessFromDocument` (PermissionInheritedWorkspaceAccessFromDocument, optional) - `movedToTrashOn` (string, optional, nullable) — The date the document has been moved to the trash - `movedToTrashBy` (string, optional, nullable) — The id of the user that moved the document to the trash. - `rootDocumentCreatedBy` (string, optional) — The user id of the creator of the root document of this document's document tree. ## Errors ### 400 Bad Request Error Bad Request - `code` (string, required) — The error code. - `description` (string, required) — The description of the error. - `link` (string, required) — The link to the API documentation page. - `details` (list of string, optional, nullable) — A list of details describing the error. - `validationErrors` (list of ValidationErrorResponse, optional, nullable) — If a validation error occurred, this contains the validation errors for each property. - `traceId` (string, optional, nullable) — The request trace id for tracking the request. ## Types ### DocumentSpaceModel - `id` (string, optional) — The id of the entity. - `createdOn` (string, optional) — The date this entity was created. - `createdBy` (string, optional) — The id of the user who created this entity. - `updatedOn` (string, optional) — The date this entity was last modified. - `updatedBy` (string, optional) — The id of the user who last modified this entity. - `name` (string, optional, nullable) — The name of the document space. - `isExternal` (boolean, optional) — Whether this document space is coming from an external workspace (awork Connect). - `emoji` (string, optional, nullable) — The emoji of the document space. - `color` (string, optional, nullable) — The color of the document space for display purposes in the app. Can be null when no color assigned. - `order` (double, optional, nullable) — The order of the document space in the list of document spaces. - `workspaceAccessLevel` (string, optional, nullable) — Determines the level of access to this document space granted to all workspace users. Can be either not set (no access), `read`, or `manage`. - `contributors` (list of ContributorModel, optional, nullable) — The contributors of this document space. - `teams` (list of EntityToTeamModel, optional, nullable) — The teams this document space is connected to. ### PermissionProject - `id` (string, optional) - `name` (string, optional, nullable) - `createdBy` (string, optional) - `teams` (list of PermissionTeam, optional, nullable) - `members` (list of PermissionProjectMember, optional, nullable) - `isPrivate` (boolean, optional) - `isExternal` (boolean, optional) ### DocumentContributorModel - `id` (string, optional) — The id of the contributor. - `userId` (string, optional) — The id of the user this contributor references. - `accessLevel` (string, optional, nullable) — Determines the level of access granted to this contributor with respect to the specific entity. Can be either set to `read` or `manage`. - `firstName` (string, optional, nullable) — The first name of the user. - `lastName` (string, optional, nullable) — The last name of the user. - `hasImage` (boolean, optional, nullable) — Whether the user has an image. - `isDeactivated` (boolean, optional) — Whether the user is deactivated. - `documentId` (string, optional) — The id of the referenced document. - `inheritedFromDocumentContributorId` (string, optional, nullable) — The id of the contributor the permission has been inherited from. - `inheritedDocumentContributor` (PermissionInheritedDocumentContributor, optional) ### DocumentToTeamModel - `id` (string, optional) — The id of the entity to team. - `teamId` (string, optional) — The id of the team this entity to team references. - `accessLevel` (string, optional, nullable) — Determines the level of access granted to this entity to team with respect to the specific entity. Can be either set to `read` or `manage`. - `name` (string, optional, nullable) — The name of the team. - `icon` (string, optional, nullable) — The icon which is assigned to the team. - `color` (string, optional, nullable) — The color of the team. - `documentId` (string, optional) — The id of the referenced document. - `inheritedFromDocumentToTeamId` (string, optional, nullable) — The id of the document to team the permission has been inherited from. - `inheritedDocumentToTeam` (PermissionInheritedDocumentToTeam, optional) ### PermissionInheritedWorkspaceAccessFromDocument - `workspaceAccessLevel` (string, optional, nullable) ### ValidationErrorResponse The validation error response. - `property` (string, optional, nullable) — The name of the property that failed validation. - `message` (string, optional, nullable) — The reason why this property failed validation. ### ContributorModel - `id` (string, optional) — The id of the contributor. - `userId` (string, optional) — The id of the user this contributor references. - `accessLevel` (string, optional, nullable) — Determines the level of access granted to this contributor with respect to the specific entity. Can be either set to `read` or `manage`. - `firstName` (string, optional, nullable) — The first name of the user. - `lastName` (string, optional, nullable) — The last name of the user. - `hasImage` (boolean, optional, nullable) — Whether the user has an image. - `isDeactivated` (boolean, optional) — Whether the user is deactivated. ### EntityToTeamModel - `id` (string, optional) — The id of the entity to team. - `teamId` (string, optional) — The id of the team this entity to team references. - `accessLevel` (string, optional, nullable) — Determines the level of access granted to this entity to team with respect to the specific entity. Can be either set to `read` or `manage`. - `name` (string, optional, nullable) — The name of the team. - `icon` (string, optional, nullable) — The icon which is assigned to the team. - `color` (string, optional, nullable) — The color of the team. ### PermissionTeam - `id` (string, optional) - `name` (string, optional, nullable) ### PermissionProjectMember - `id` (string, optional) - `projectRoleId` (string, optional) - `userId` (string, optional) ### PermissionInheritedDocumentContributor - `documentId` (string, optional) - `accessLevel` (string, optional, nullable) ### PermissionInheritedDocumentToTeam - `documentId` (string, optional) - `accessLevel` (string, optional, nullable) ## Examples **Request** ```json { "content": "", "contentFormat": { "type": "json" } } ``` **Response** ```json { "id": "123e4567-e89b-12d3-a456-426614174000", "createdOn": "2022-03-11T15:33:47.100Z", "createdBy": "123e4567-e89b-12d3-a456-426614174000", "updatedOn": "2022-03-11T21:15:00.100Z", "updatedBy": "123e4567-e89b-12d3-a456-426614174000", "name": "string", "currentDocumentVersionId": "123e4567-e89b-12d3-a456-426614174000", "documentSpaceId": "123e4567-e89b-12d3-a456-426614174000", "documentSpace": { "id": "123e4567-e89b-12d3-a456-426614174000", "createdOn": "2022-03-11T15:33:47.100Z", "createdBy": "123e4567-e89b-12d3-a456-426614174000", "updatedOn": "2022-03-11T21:15:00.100Z", "updatedBy": "123e4567-e89b-12d3-a456-426614174000", "name": "string", "isExternal": true, "emoji": "string", "color": "purple", "order": 1.1, "workspaceAccessLevel": "string", "contributors": [ { "id": "123e4567-e89b-12d3-a456-426614174000", "userId": "123e4567-e89b-12d3-a456-426614174000", "accessLevel": "string", "firstName": "Lisa", "lastName": "Smith", "hasImage": true, "isDeactivated": false } ], "teams": [ { "id": "123e4567-e89b-12d3-a456-426614174000", "teamId": "123e4567-e89b-12d3-a456-426614174000", "accessLevel": "string", "name": "Designers", "icon": "paintbrush", "color": "purple" } ] }, "parentId": "123e4567-e89b-12d3-a456-426614174000", "projectId": "123e4567-e89b-12d3-a456-426614174000", "project": { "id": "123e4567-e89b-12d3-a456-426614174000", "name": "string", "createdBy": "123e4567-e89b-12d3-a456-426614174000", "teams": [ { "id": "123e4567-e89b-12d3-a456-426614174000", "name": "string" } ], "members": [ { "id": "123e4567-e89b-12d3-a456-426614174000", "projectRoleId": "123e4567-e89b-12d3-a456-426614174000", "userId": "123e4567-e89b-12d3-a456-426614174000" } ], "isPrivate": true, "isExternal": true }, "taskId": "123e4567-e89b-12d3-a456-426614174000", "emoji": "string", "isPrivate": true, "order": 1.1, "isExternal": true, "isHiddenForConnectUsers": true, "contributors": [ { "id": "123e4567-e89b-12d3-a456-426614174000", "userId": "123e4567-e89b-12d3-a456-426614174000", "accessLevel": "string", "firstName": "Lisa", "lastName": "Smith", "hasImage": true, "isDeactivated": false, "documentId": "123e4567-e89b-12d3-a456-426614174000", "inheritedFromDocumentContributorId": "123e4567-e89b-12d3-a456-426614174000", "inheritedDocumentContributor": { "documentId": "123e4567-e89b-12d3-a456-426614174000", "accessLevel": "string" } } ], "teams": [ { "id": "123e4567-e89b-12d3-a456-426614174000", "teamId": "123e4567-e89b-12d3-a456-426614174000", "accessLevel": "string", "name": "Designers", "icon": "paintbrush", "color": "purple", "documentId": "123e4567-e89b-12d3-a456-426614174000", "inheritedFromDocumentToTeamId": "123e4567-e89b-12d3-a456-426614174000", "inheritedDocumentToTeam": { "documentId": "123e4567-e89b-12d3-a456-426614174000", "accessLevel": "string" } } ], "workspaceAccessLevel": "string", "inheritedWorkspaceAccessFromDocumentId": "123e4567-e89b-12d3-a456-426614174000", "inheritedWorkspaceAccessFromDocument": { "workspaceAccessLevel": "string" }, "movedToTrashOn": "2024-01-15T09:30:00Z", "movedToTrashBy": "123e4567-e89b-12d3-a456-426614174000", "rootDocumentCreatedBy": "123e4567-e89b-12d3-a456-426614174000" } ``` **SDK Code** ```python import requests url = "https://api.awork.com/api/v1/documents/documentId/content" files = { "content": "open('[object Object]', 'rb')" } payload = { "contentFormat": "{ \"type\": \"json\" }" } headers = {"Authorization": "Bearer "} response = requests.put(url, data=payload, files=files, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.awork.com/api/v1/documents/documentId/content'; const form = new FormData(); form.append('content', '[object Object]'); form.append('contentFormat', '{ "type": "json" }'); const options = {method: 'PUT', headers: {Authorization: 'Bearer '}}; options.body = form; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.awork.com/api/v1/documents/documentId/content" payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"content\"; filename=\"[object Object]\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"contentFormat\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001--\r\n") req, _ := http.NewRequest("PUT", url, payload) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://api.awork.com/api/v1/documents/documentId/content") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Put.new(url) request["Authorization"] = 'Bearer ' request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"content\"; filename=\"[object Object]\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"contentFormat\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001--\r\n" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.put("https://api.awork.com/api/v1/documents/documentId/content") .header("Authorization", "Bearer ") .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"content\"; filename=\"[object Object]\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"contentFormat\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001--\r\n") .asString(); ``` ```php request('PUT', 'https://api.awork.com/api/v1/documents/documentId/content', [ 'multipart' => [ [ 'name' => 'content', 'filename' => '[object Object]', 'contents' => null ], [ 'name' => 'contentFormat', 'contents' => '{ "type": "json" }' ] ] 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.awork.com/api/v1/documents/documentId/content"); var request = new RestRequest(Method.PUT); request.AddHeader("Authorization", "Bearer "); request.AddParameter("undefined", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"content\"; filename=\"[object Object]\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"contentFormat\"\r\n\r\n{\n \"type\": \"json\"\n}\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = ["Authorization": "Bearer "] let parameters = [ [ "name": "content", "fileName": "[object Object]" ], [ "name": "contentFormat", "value": "{ \"type\": \"json\" }" ] ] let boundary = "---011000010111000001101001" var body = "" var error: NSError? = nil for param in parameters { let paramName = param["name"]! body += "--\(boundary)\r\n" body += "Content-Disposition:form-data; name=\"\(paramName)\"" if let filename = param["fileName"] { let contentType = param["content-type"]! let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8) if (error != nil) { print(error as Any) } body += "; filename=\"\(filename)\"\r\n" body += "Content-Type: \(contentType)\r\n\r\n" body += fileContent } else if let paramValue = param["value"] { body += "\r\n\r\n\(paramValue)" } } let request = NSMutableURLRequest(url: NSURL(string: "https://api.awork.com/api/v1/documents/documentId/content")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "PUT" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```