API Reference
See the complete Datasets API reference for all endpoints and options.
Upload and manage data files for your analytics agent with user and context scoping.
Datasets allow you to upload data files (CSV, JSON) that the agent can reference when answering questions. Files can be scoped to individual users or shared across users matching a context value.
Datasets support two scoping methods:
| Scope | Description | Use case |
|---|---|---|
| User-scoped | Files accessible only to a specific user | Personal uploads, user-specific data |
| Context-scoped | Files shared with all users matching a context value | Organization-wide reference data, team resources |
For example:
userIdentifier: "user_123"orgId: "org_456" (all users in that org can access it)Use datasets when you want to:
The simplest way to upload datasets is through the Inconvo dashboard. This is ideal for static reference data that isn’t stored in your connected databases.
user_123)orgId: org_456)For programmatic uploads or allowing end-users to upload their own files, use the API. Files are uploaded using multipart/form-data. Supported formats are CSV and JSON, with a maximum size of 10MB per file.
Upload files that only a specific user can access.
import Inconvo from "@inconvoai/node";import fs from "fs";
const client = new Inconvo({ apiKey: process.env.INCONVO_API_KEY});
// Upload a file for a specific userconst result = await client.datasets.user.upload({ userIdentifier: "user_123", file: fs.createReadStream("./sales_data.csv"), notes: "Q4 2024 sales report"});
console.log(result.file);// { name: "sales_data.csv", path: "...", size: 2048576 }Upload files shared with all users matching a context value.
// Upload a file shared with all users in an organizationconst result = await client.datasets.context.upload({ contextKey: "orgId", contextValue: "org_456", file: fs.createReadStream("./company_pricing.csv"), notes: "2024 pricing sheet"});
console.log(result.file);// { name: "company_pricing.csv", path: "...", size: 1024000 }User-scoped endpoint: POST /datasets/user/{userIdentifier}
| Parameter | Required | Description |
|---|---|---|
userIdentifier | Yes | Path parameter - unique identifier for the user (1-256 chars) |
file | Yes | The file to upload (binary stream or File object) |
notes | No | Description or notes about the file |
Context-scoped endpoint: POST /datasets/context/{contextKey}/{contextValue}
| Parameter | Required | Description |
|---|---|---|
contextKey | Yes | Path parameter - the context key (e.g., orgId, teamId) |
contextValue | Yes | Path parameter - the context value (e.g., org_456) |
file | Yes | The file to upload (binary stream or File object) |
notes | No | Description or notes about the file |
Retrieve all files for a specific user or context.
// List user-scoped filesconst userFiles = await client.datasets.user.list({ userIdentifier: "user_123"});console.log(userFiles);// { files: ["sales_data.csv", "inventory.json"] }
// List context-scoped filesconst contextFiles = await client.datasets.context.list({ contextKey: "orgId", contextValue: "org_456"});console.log(contextFiles);// { files: ["company_pricing.csv", "policies.json"] }Remove a file by providing its filename and scope.
// Delete a user-scoped fileconst result = await client.datasets.user.delete({ userIdentifier: "user_123", filename: "sales_data.csv"});console.log(result);// { file: "sales_data.csv", success: true }
// Delete a context-scoped fileconst result2 = await client.datasets.context.delete({ contextKey: "orgId", contextValue: "org_456", filename: "old_pricing.csv"});When a user sends a message, the agent automatically has access to:
userIdentifieruserContext valuesThe agent can:
For example, if you upload a pricing.csv file as context-scoped for orgId: org_456, any user in that organization can ask:
“What’s the price for the Enterprise plan?”
Or if a user uploads their own targets.csv file, they can ask:
“How do our actual sales compare to the targets in my uploaded file?”
The agent will read both the database and the uploaded files to provide a combined analysis.
Here’s how to allow end-users to upload their own files through your application:
// Server endpoint for file uploads (using multer for multipart parsing)import Inconvo, { toFile } from "@inconvoai/node";import multer from "multer";
const client = new Inconvo({ apiKey: process.env.INCONVO_API_KEY });const upload = multer({ storage: multer.memoryStorage() });
app.post("/upload-dataset", upload.single("file"), async (req, res, next) => { // Get userIdentifier from session const userIdentifier = req.session.userId;
try { const result = await client.datasets.user.upload({ userIdentifier, // Use toFile() to convert buffer to uploadable format file: await toFile(req.file.buffer, req.file.originalname), notes: req.body.notes });
return res.json(result); } catch (error) { next(error); }});// Client-side file input handlerconst handleFileUpload = async (event) => { const file = event.target.files[0]; if (!file) return;
// Upload directly using FormData const formData = new FormData(); formData.append("file", file);
await fetch("/upload-dataset", { method: "POST", body: formData });};Files are stored with the following path structure:
| Scope | Path format |
|---|---|
| User-scoped | /{orgId}/agt_123/userIdentifier/{userIdentifier}/filename.csv |
| Context-scoped | /{orgId}/agt_123/userContext/{contextKey}:{contextValue}/filename.csv |
| Limit | Value |
|---|---|
| Max file size | 10MB per file |
| Supported formats | CSV, JSON |
API Reference
See the complete Datasets API reference for all endpoints and options.
User Context
Learn more about configuring your agent and setting up user context fields.