Endpoints
Publish data to context
Publish unstructured data or files to enrich your contexts
POST
Overview
The publish endpoint allows you to add unstructured data or files to a context. This is how you build up the “memory” in Contextbase’s compression engine - by continuously publishing user interactions, system events, profile updates, documents, and other relevant data that will later be compressed into context-rich prompts for your LLMs.Path Parameters
Name of the context to publish to (e.g., “user-interactions”, “knowledge-base”)
Request Body
You can provide either abody object or a file object, but not both.
Unstructured data to publish to the context. This can be any JSON object containing information you want to enrich your context with - user messages, profile updates, system events, etc.
File to upload and publish to the context. The file will be processed and its content will be made available for context resolution.Supported file types: PDF, CSV, DOC, DOCX, XLS, XLSX, HTML, TXT, MD, PNG, JPEG, WEBP
Scoping parameters for the published data. These determine which resolved contexts will include this data - essential for personalization and data organization.
Response
Confirmation message indicating successful publication to the context.
Example Request
File Upload Example
Example Response
Error Responses
Use Cases
- User Interaction Memory: Publish chat messages, user questions, feedback, and preferences to build user-specific context
- Behavioral Data: Track user actions, feature usage, and interaction patterns for personalized AI responses
- System Events: Log important system changes, errors, or updates that might be relevant for support contexts
- Profile Updates: Maintain current user information, role changes, or permission updates
- Conversation History: Build memory for chatbots by publishing both user messages and AI responses
- Document Uploads: Upload PDFs, spreadsheets, images, and other files to enrich context with document content
- Knowledge Base Management: Publish documentation, guides, and reference materials for AI to reference
- Image Analysis: Upload images for visual context and analysis capabilities
Context Types
Static Contexts
Static contexts contain fixed content that doesn’t change:- System prompts and instructions
- General knowledge base articles
- Product documentation
- Universal policies and guidelines
Dynamic Contexts
Dynamic contexts accept new publications and can be scoped:- User-specific interaction history (scoped by
user_id) - Project-specific information (scoped by
project) - Environment-specific configurations (scoped by
environment) - Session-specific data (scoped by
session_id)
Notes
- Only dynamic contexts accept new publications. Static contexts will return a 422 error.
- Some contexts may require specific scopes to be present. Check the context configuration for requirements.
- Published data becomes immediately available when resolving the context.
- Data is compressed and filtered during context resolution, so you can publish freely without worrying about overwhelming your prompts.
- When uploading files, ensure they are in one of the supported formats: PDF, CSV, DOC, DOCX, XLS, XLSX, HTML, TXT, MD, PNG, JPEG, WEBP.
- Files are processed and their content is extracted for context resolution. Large files may take longer to process.
