# Save PAGE content (optimistic concurrency + version snapshot).

`PUT /api/plugins/docs/documents/{id}/content`

Authentication: no security requirement declared for this operation.

Parameters:

- `id` (path, string, required)
  Type: string

Request body: application/json (required)

Type: object

Schema: [UpdateDocumentContentDTO](https://sourcey-gauzy.pages.dev/api-reference/models/updatedocumentcontentdto/index.md)

- `tenant` (optional)
  Type: object

- `tenantId` (optional)
  Type: string

- `organization` (optional)
  Type: object

- `organizationId` (optional)
  Type: string

- `sentTo` (optional)
  Type: string

- `contentJson` (required)
  Type: object
  
  Canonical TipTap JSON document

- `contentHtml` (optional)
  Type: string
  
  Render cache (editor.getHTML()), sanitized server-side

- `contentBinary` (optional)
  Type: string, byte

- `expectedUpdatedAt` (required)
  Type: string, date-time

- `forceSnapshot` (optional)
  Type: boolean

- `mentionEmployeeIds` (optional)
  Type: array
  
  Items:
    Type: string

- `metadata` (optional)
  Reference: [UpdateDocumentContentMetadataDTO](https://sourcey-gauzy.pages.dev/api-reference/models/updatedocumentcontentmetadatadto/index.md); Type: object

Responses:

- 200: Content saved successfully.

Content type: application/json

Type: object

Schema: [Document](https://sourcey-gauzy.pages.dev/api-reference/models/document/index.md)

- `deletedAt` (optional)
  Type: string, date-time
  
  Example:
  
  ```json
  "2018-11-21T06:20:32.232Z"
  ```

- `createdAt` (optional)
  Type: string, date-time
  
  The creation timestamp of the entity.
  
  Example:
  
  ```json
  "2018-11-21T06:20:32.232Z"
  ```

- `updatedAt` (optional)
  Type: string, date-time
  
  The last update timestamp of the entity.
  
  Example:
  
  ```json
  "2018-11-21T06:20:32.232Z"
  ```

- `id` (optional)
  Type: string

- `isActive` (optional)
  Type: boolean
  
  default: true

- `isArchived` (optional)
  Type: boolean
  
  default: false

- `archivedAt` (optional)
  Type: string, date-time
  
  Example:
  
  ```json
  "2018-11-21T06:20:32.232Z"
  ```

- `tenantId` (optional)
  Type: string

- `organizationId` (optional)
  Type: string

- `kind` (required)
  Type: string
  
  enum: ["FOLDER","PAGE","FILE"]

- `index` (required)
  Type: number
  
  Sibling sort order within the parent

- `name` (required)
  Type: string
  
  Display name / page title

- `icon` (optional)
  Type: string

- `color` (optional)
  Type: string

- `description` (optional)
  Type: string

- `contentJson` (optional)
  Type: object

- `contentHtml` (optional)
  Type: string

- `contentBinary` (optional)
  Type: string, binary

- `isLocked` (required)
  Type: boolean

- `storageProvider` (optional)
  Type: string
  
  enum: ["LOCAL","S3","WASABI","CLOUDINARY","DIGITALOCEAN"]

- `storageKey` (optional)
  Type: string

- `thumbKey` (optional)
  Type: string

- `mimeType` (optional)
  Type: string

- `fileSize` (optional)
  Type: number

- `sha256` (optional)
  Type: string

- `originalFilename` (optional)
  Type: string

- `version` (required)
  Type: number

- `extractedText` (optional)
  Type: string

- `extractedTextEdited` (required)
  Type: boolean

- `summary` (optional)
  Type: string

- `status` (required)
  Type: string
  
  enum: ["UPLOADED","PROCESSING","READY","FAILED"]

- `statusMessage` (optional)
  Type: string

- `source` (required)
  Type: string
  
  enum: ["UPLOAD","EDITOR","CHAT","EMAIL","INTEGRATION","SYSTEM","IMPORT"]

- `knowledgeStatus` (required)
  Type: string
  
  enum: ["NONE","QUEUED","INDEXING","INDEXED","FAILED","EXCLUDED"]

- `aiConfidence` (optional)
  Type: number

- `searchable` (required)
  Type: boolean

- `reviewStatus` (required)
  Type: string
  
  enum: ["NONE","PENDING","APPROVED","REJECTED"]

- `reviewReason` (optional)
  Type: string
  
  enum: ["extraction-failed","low-confidence","ai-generated","manual"]

- `reviewedAt` (optional)
  Type: string, date-time

- `visibility` (required)
  Type: string
  
  enum: ["ORGANIZATION","PRIVATE"]

- `externalSource` (optional)
  Type: string

- `externalId` (optional)
  Type: string

- `metadata` (optional)
  Type: object

- `parentId` (optional)
  Type: string

- `reviewedById` (optional)
  Type: string

- 409: Content changed since it was loaded.

## Examples

### cURL

```bash
curl -X PUT 'http://localhost:3000/api/plugins/docs/documents/string/content' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "tenant": {},
  "tenantId": "string",
  "organization": {},
  "organizationId": "string",
  "sentTo": "string",
  "contentJson": {},
  "contentHtml": "string",
  "contentBinary": "dGVzdA==",
  "expectedUpdatedAt": "2024-01-15T09:30:00Z",
  "forceSnapshot": true,
  "mentionEmployeeIds": [
    "string"
  ],
  "metadata": {
    "schemaVersion": 0
  }
}'
```

### JavaScript

```javascript
const body = `{
  "tenant": {},
  "tenantId": "string",
  "organization": {},
  "organizationId": "string",
  "sentTo": "string",
  "contentJson": {},
  "contentHtml": "string",
  "contentBinary": "dGVzdA==",
  "expectedUpdatedAt": "2024-01-15T09:30:00Z",
  "forceSnapshot": true,
  "mentionEmployeeIds": [
    "string"
  ],
  "metadata": {
    "schemaVersion": 0
  }
}`;

const response = await fetch('http://localhost:3000/api/plugins/docs/documents/string/content', {
  method: 'PUT',
  headers: {
    'Content-Type': 'application/json',
  },
  body,
});

const data = await response.text();
```

### Python

```python
import requests

body = '''{
  "tenant": {},
  "tenantId": "string",
  "organization": {},
  "organizationId": "string",
  "sentTo": "string",
  "contentJson": {},
  "contentHtml": "string",
  "contentBinary": "dGVzdA==",
  "expectedUpdatedAt": "2024-01-15T09:30:00Z",
  "forceSnapshot": true,
  "mentionEmployeeIds": [
    "string"
  ],
  "metadata": {
    "schemaVersion": 0
  }
}'''

response = requests.put(
    'http://localhost:3000/api/plugins/docs/documents/string/content',
    data=body.encode('utf-8'),
    headers={
        'Content-Type': 'application/json',
    },
)
print(response.text)
```
