This endpoint performs an upsert operation: it creates a new document or updates an existing one
based on the identifier you provide.
Document Identification
You must provide exactly one of the following identifiers (providing both will result in an error):
1. document_id (integer):
- Use the internal Customerly document ID to update an existing document
- If the document doesn't exist, a 404 error will be returned
2. custom_document_id (string):
- Use your custom identifier for upsert operations
- If a document with this custom_document_id exists, it will be updated
- If it doesn't exist, a new document will be created with this identifier
- Must be unique within your app
Important: You cannot specify both document_id and custom_document_id in the same request.
Required Fields
title: Document title (required)body: Document content, supports HTML (required)- One identifier: either
document_idORcustom_document_id(required)
AI Training
If is_ai_enabled is set to true, the document will be trained for AI-powered features.
Note: AI training can take a few minutes to complete. The document will have ai_training_status: "to_train"
initially, and will change to "trained" once the training process is complete.
Document Folders
To organize documents in folders, use the polymorphic_folder_id parameter:
- Create folders in the Customerly UI or use
GET /documents/foldersto list existing folders - Get the folder ID from the response
- Pass the folder ID in the
polymorphic_folder_idparameter when creating/updating the document
Content Visibility
Use contact_segment_ids and company_segment_ids to restrict access to this document inside Aura
(the AI assistant). Only contacts and companies belonging to the specified segments will be able to
access this content through Aura.
If a document has no explicit visibility rules, it inherits them from its parent folder (if any).
- Omit the field (or pass
null) to leave existing visibilities unchanged. - Pass an empty array
[]to remove all visibility restrictions for that segment type. - Pass a non-empty array to replace the current visibilities with exactly those segment IDs.
Requires the content_visibility feature on your plan.
| Time | Status | User Agent | |
|---|---|---|---|
Retrieving recent requests… | |||
401Authentication required
403Permission denied
404Document folder not found (if polymorphic_folder_id is provided and invalid)
422The request is not valid