Content API¶
The Content API allows you to manage documents and files in the Unique AI knowledge base.
Overview¶
The Content resource provides methods to:
- Search and retrieve content from the knowledge base
- Upload new documents and files
- Update existing content (title, location, metadata)
- Delete content
- Ingest magic table sheets
Methods¶
unique_sdk.Content.search - Search content with filtering
Load full content/files from the knowledge base with user rights and filtering.
Returns:
Returns a list of Content objects.
Parameters:
where(required) - Filter conditions usingContentWhereInputchatId(optional) - Filter content by chat IDincludeFailedContent(optional) - Include failed ingestion content
Example:
unique_sdk.Content.get_info - Get content info (Deprecated)
Deprecated
Use unique_sdk.Content.get_infos instead.
Get content info with UniqueQL metadata filtering.
Parameters:
metadataFilter(optional) - UniqueQL metadata filterskip(optional) - Number of entries to skip (default: 0)take(optional) - Number of entries to return (default: 50)filePath(optional) - Filter by file pathcontentId(optional) - Filter by content IDchatId(optional) - Filter by chat ID
Returns:
Returns a PaginatedContentInfo object.
Example:
unique_sdk.Content.get_infos - Get content infos
Get content infos with either UniqueQL metadata filter or parentId. Cannot use both simultaneously.
Parameters:
metadataFilter(optional) - UniqueQL metadata filter (cannot be used withparentId)parentId(optional) - Filter by parent folder/scope ID (cannot be used withmetadataFilter)skip(optional) - Number of entries to skip (default: 0)take(optional) - Number of entries to return (default: 50)
Returns:
Returns a PaginatedContentInfos object.
Example with Metadata Filter:
Example with Parent ID:
unique_sdk.Content.upsert - Upload content
Upload new content to the knowledge base into a specific scope or chat.
Parameters:
input(required) - Content input object. SeeContent.Inputfor field details.scopeId(str, optional) - Scope ID to upload to (required ifchatIdnot provided)chatId(str, optional) - Chat ID to upload to (required ifscopeIdnot provided)sourceOwnerType(str, optional) - Source owner typestoreInternally(bool, optional) - Store file internallyfileUrl(str, optional) - External file URLreadUrl(str, optional) - Read URL for confirming upload (used in second call)
Returns:
Returns a Content object.
Example:
unique_sdk.Content.ingest_magic_table_sheets - Ingest table sheets
Ingest a magic table sheet where each row is processed and converted into content.
Parameters:
data(List[MagicTableSheetTable], required) - List of table rows to ingest- Each row contains:
rowId(str) - Unique row identifiercolumns(List[MagicTableSheetTableColumn]) - List of column valuescolumnId(str) - Column identifiercolumnName(str) - Column namecontent(str) - Column content/text
ingestionConfiguration(MagicTableSheetIngestionConfiguration, required) - Configuration for ingestioncolumnIdsInMetadata(List[str]) - Column IDs to include in metadatacolumnIdsInChunkText(List[str]) - Column IDs to include in chunk textmetadata(Dict[str, Optional[str]], required) - Base metadata for all ingested contentscopeId(str, required) - Scope ID to ingest content intosheetName(str, required) - Name of the sheet being ingested
Returns:
Returns a MagicTableSheetResponse object.
Example:
unique_sdk.Content.update - Update content
Compatibility
Compatible with release >.36
Update a file by its contentId or filePath.
Parameters:
contentId(str, optional) - ID of the file to update (required iffilePathnot provided)filePath(str, optional) - Absolute path of the file (required ifcontentIdnot provided)title(str, optional) - New file titleownerId(str, optional) - Move file to different folder using folder IDparentFolderPath(str, optional) - Move file to different folder using folder pathmetadata(Dict[str, str | None], optional) - Update file metadata (available in release >.40)
Returns:
Returns a ContentInfo object.
Examples:
Update title by path:
Move file by content ID:
Move and update title:
Move by folder path:
unique_sdk.Content.delete - Delete content
Compatibility
Compatible with release >.36
Delete a file by its contentId or filePath.
Parameters:
contentId(str, optional) - ID of the file to delete (required iffilePathnot provided)chatId(str, optional) - Chat ID (required if file is part of a chat)filePath(str, optional) - Absolute path of the file (required ifcontentIdnot provided)
Returns:
Returns a DeleteResponse object.
Examples:
Delete from chat:
Delete by path:
Use Cases¶
For simplified file operations, use the File I/O utilities:
Upload Files
Instead of manually handling the three-step Content.upsert process, use the upload_file utility:
Download Files
Use the download_content utility to download files from the knowledge base:
Wait for Ingestion Completion
After uploading a file, wait for it to be fully ingested before using it:
Filtering¶
ContentWhereInput¶
The ContentWhereInput type defines filter conditions for searching content. It supports logical operators (AND, OR, NOT) and field-specific filters
Available Fields:
id- Filter by content ID (usesStringFilter)key- Filter by file key/name (usesStringFilter)ownerId- Filter by owner/folder ID (usesStringFilter)title- Filter by content title (usesStringNullableFilter)url- Filter by content URL (usesStringNullableFilter)
Logical Operators:
AND- All conditions must match (array ofContentWhereInput)OR- Any condition must match (array ofContentWhereInput)NOT- Conditions must not match (array ofContentWhereInput)
String Filter Operators:
Each field filter supports the following operators:
contains(str) - Field contains the substringequals(str) - Field equals the value exactlystartsWith(str) - Field starts with the valueendsWith(str) - Field ends with the valuegt(str) - Field is greater than the valuegte(str) - Field is greater than or equal to the valuelt(str) - Field is less than the valuelte(str) - Field is less than or equal to the valuein_(List[str]) - Field is in the list of valuesnotIn(List[str]) - Field is not in the list of valuesnot_(NestedStringFilter) - Negate a nested filter conditionmode(QueryMode) - Query mode:"default"or"insensitive"(case-insensitive)
Examples:
Simple filter:
Multiple conditions with AND:
Multiple conditions with OR:
Case-insensitive search:
Using in_ operator:
Complex nested conditions:
Input Types¶
Content.Input¶
The Content.Input type defines the structure for creating or updating content
Fields:
key(str, required) - File key/nametitle(str, optional) - Content titlemimeType(str, required) - MIME type (e.g., "application/pdf", "text/plain")description(str, optional) - Content descriptionownerType(str, optional) - Owner typeownerId(str, optional) - Owner/folder IDbyteSize(int, optional) - File size in bytesingestionConfig(IngestionConfig, optional) - Ingestion configurationmetadata(Dict[str, Any], optional) - Custom metadata dictionary
Used in: Content.upsert()
Return Types¶
Content¶
The Content object represents a full content item with chunks and URLs
Fields:
id(str) - Unique content identifierkey(str) - File key/nameurl(str | None) - Content URLtitle(str | None) - Content titleupdatedAt(str) - Last update timestamp (ISO 8601)chunks(List[Chunk] | None) - Document chunks with text and page informationmetadata(Dict[str, Any] | None) - Custom metadata dictionarywriteUrl(str | None) - URL for uploading file contentreadUrl(str | None) - URL for reading/downloading file contentexpiredAt(str | None) - Expiration timestamp (ISO 8601)
Returned by: Content.search(), Content.upsert()
Chunk¶
The Chunk object represents a text chunk within a document
Fields:
id(str) - Chunk identifiertext(str) - Chunk text contentstartPage(int | None) - Starting page numberendPage(int | None) - Ending page numberorder(int | None) - Chunk order in document
Used in: Content.chunks
ContentInfo¶
The ContentInfo object represents basic information about a content item without full chunks.
Fields:
id(str) - Unique content identifierkey(str) - File key/nameurl(str | None) - Content URLtitle(str | None) - Content titlemetadata(Dict[str, Any] | None) - Custom metadata dictionarymimeType(str) - MIME type of the filedescription(str | None) - Content descriptionbyteSize(int) - File size in bytesownerId(str) - Owner/folder IDcreatedAt(str) - Creation timestamp (ISO 8601)updatedAt(str) - Last update timestamp (ISO 8601)expiresAt(str | None) - Expiration timestamp (ISO 8601)deletedAt(str | None) - Deletion timestamp (ISO 8601)expiredAt(str | None) - Expiration timestamp alias (ISO 8601)
Returned by: Content.get_info(), Content.get_infos(), Content.update()
PaginatedContentInfo¶
The PaginatedContentInfo object contains paginated content info results
Fields:
contentInfo(List[ContentInfo]) - List of content info objectstotalCount(int) - Total number of matching entries
Returned by: Content.get_info()
PaginatedContentInfos¶
The PaginatedContentInfos object contains paginated content infos results
Fields:
contentInfos(List[ContentInfo]) - List of content info objectstotalCount(int) - Total number of matching entries
Returned by: Content.get_infos()
MagicTableSheetResponse¶
The MagicTableSheetResponse object contains the mapping of row IDs to created content IDs
Fields:
rowIdsToContentIds(List[MagicTableSheetRowIdToContentId]) - Mapping of row IDs to created content IDs
MagicTableSheetRowIdToContentId Fields:
rowId(str) - Original row identifiercontentId(str) - Created content identifier
Returned by: Content.ingest_magic_table_sheets()
DeleteResponse¶
The DeleteResponse object contains the ID of deleted content
Fields:
id(str) - ID of the deleted content
Returned by: Content.delete()
Related Resources¶
- File I/O Utilities - Simplified file upload and download
- Folder API - Organize content into folders
- Search API - Search across content
- UniqueQL - Query language for filtering