API Reference
See the complete Datasets API reference for all endpoints and options.
Upload and manage user-specific data files for your analytics agent.
Datasets allow you to upload data files (CSV, JSON) that the agent can reference when answering questions. Files are scoped by user context, ensuring multi-tenant isolation.
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.
organisationId: 1)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.
import Inconvo from "@inconvoai/node";import fs from "fs";
const client = new Inconvo({ apiKey: process.env.INCONVO_API_KEY});
// Upload with user context (must be JSON stringified)const result = await client.datasets.upload({ file: fs.createReadStream("./sales_data.csv"), userContext: JSON.stringify({ userId: 123 }), notes: "Q4 2024 sales report"});
console.log(result.file);// { name: "sales_data.csv", path: "...", size: 2048576 }| Parameter | Required | Description |
|---|---|---|
file | Yes | The file to upload (binary stream or File object) |
userContext | Yes | Context values as a JSON string (e.g., JSON.stringify({ userId: 123 })) |
notes | No | Description or notes about the file |
Retrieve all files for a specific user context.
const files = await client.datasets.list({ userContext: { userId: 123 }});
console.log(files);// { files: ["sales_data.csv", "inventory.json"] }Remove a file by providing its filename and the matching user context.
const result = await client.datasets.delete("sales_data.csv", { userContext: { userId: 123 }});
console.log(result);// { file: "sales_data.csv", success: true }When a user sends a message, the agent automatically has access to any dataset files matching the user context. The agent can:
For example, if you upload a pricing.csv file with product pricing through the dashboard, users can ask:
“What’s the price for the Enterprise plan?”
Or if a user uploads their own targets.csv file with sales targets, 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 CSV 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 user context from session const context = { userId: req.session.userId };
try { const result = await client.datasets.upload({ // Use toFile() to convert buffer to uploadable format file: await toFile(req.file.buffer, req.file.originalname), userContext: JSON.stringify(context), 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 });};| 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.