Optionaloptions: { env?: string; host?: string; token?: string }ProtectedenvProtectedhostProtectedtokenConvert data between different formats (JSON, CSV, Excel)
Supports structured data when converting from JSON format with:
header, items, and footer propertiesRaw data to convert
Conversion parameters including structured data options
Promise resolving to converted data
// Convert JSON to CSV
const jsonData = [
{ name: "John Doe", age: 30, email: "john@example.com" },
{ name: "Jane Smith", age: 25, email: "jane@example.com" }
];
const csvResult = await dms.convertData(libraryRef, jsonData, {
from: 'json',
to: 'csv'
});
console.log(csvResult.data); // CSV string
// Convert structured JSON with header as comments
const structuredData = {
header: {
content: {
report_title: "Monthly Sales Report",
generated_by: "Sales System"
}
},
items: [
{ product: "Widget A", sales: 100 },
{ product: "Widget B", sales: 150 }
],
footer: {
content: {
total_sales: 250
}
}
};
const csvWithComments = await dms.convertData(libraryRef, structuredData, {
from: 'json',
to: 'csv',
header_as_comment: true,
separator_rows: 2
});
// Convert JSON to Excel with custom sheet name
const excelResult = await dms.convertData(libraryRef, jsonData, {
from: 'json',
to: 'excel',
sheet_name: 'Customer Data'
});
// excelResult.data is a Blob
Create a library export archive (a snapshot of the project's library or a directory within it)
The library is resolved server-side from the project in the auth context — there is a single library per project.
Optionalpayload: LibraryExportCreatePayloadOptional export scope/format options
{ mode, export } when the export is queued asynchronously.
Depending on server-side sizing, the endpoint may instead stream the
archive back directly as a binary response body (not this JSON shape).
Create a custom reminder for a specific file
Media UUID
Reminder details (note, notify_at, optional recipient)
Create a recurring reminder (notification rule) for a media file
Recurring reminder definition (media_uuid/file_key, frequency, start_at, ...)
Convert CSV data to Excel (.xlsx) format
CSV data string (with headers in first row)
Optionaloptions: ConversionOptionsOptional conversion options
Promise resolving to Excel file as Blob
const csvString = `name,age,email
John Doe,30,john@example.com
Jane Smith,25,jane@example.com`;
const excelResponse = await dms.csvToExcel(libraryRef, csvString, {
sheet_name: 'Imported Data'
});
// Handle the Excel blob
const blob = excelResponse.data;
const url = URL.createObjectURL(blob);
// Use url for download or further processing
Convert CSV data to JSON format
CSV data string (with headers in first row)
Promise resolving to JSON array
const csvString = `name,age,email
John Doe,30,john@example.com
Jane Smith,25,jane@example.com`;
const jsonResponse = await dms.csvToJson(libraryRef, csvString);
console.log(jsonResponse.data);
// Output:
// [
// { name: "John Doe", age: "30", email: "john@example.com" },
// { name: "Jane Smith", age: "25", email: "jane@example.com" }
// ]
Remove a directory-level policy override (directory falls back to the library policy)
Directory path
Cancel/delete a custom file reminder
Notification UUID
Delete a notification rule
Notification rule UUID
Convert Excel (.xlsx) data to CSV format
Excel file data as Blob or ArrayBuffer
Optionaloptions: ConversionOptionsOptional conversion options
Promise resolving to CSV string
// From file input
const fileInput = document.querySelector('input[type="file"]');
const file = fileInput.files[0]; // Excel file
const csvResponse = await dms.excelToCsv(libraryRef, file, {
sheet_name: 'Data' // optional, defaults to first sheet
});
console.log(csvResponse.data);
// Output: CSV string with data from Excel sheet
// Save as CSV file
const csvBlob = new Blob([csvResponse.data], { type: 'text/csv' });
const url = URL.createObjectURL(csvBlob);
const link = document.createElement('a');
link.href = url;
link.download = 'converted.csv';
link.click();
Convert Excel (.xlsx) data to JSON format
Excel file data as Blob or ArrayBuffer
Optionaloptions: ConversionOptionsOptional conversion options
Promise resolving to JSON array
// From file input
const fileInput = document.querySelector('input[type="file"]');
const file = fileInput.files[0]; // Excel file
const jsonResponse = await dms.excelToJson(libraryRef, file, {
sheet_name: 'Sheet1' // optional, defaults to first sheet
});
console.log(jsonResponse.data);
// Output: JSON array with data from Excel sheet
// From ArrayBuffer
const arrayBuffer = await file.arrayBuffer();
const jsonFromBuffer = await dms.excelToJson(libraryRef, arrayBuffer);
Extract text from any document format
Supports PDF, DOCX, XLSX, PPTX, ODT, RTF, EPUB, CSV, images, and 40+ other formats. Provide either a DMS file path or base64-encoded file data.
File path or base64 data to extract text from
Extracted text content and character count
// From a DMS file path
const result = await dms.extractText({ input_path: 'uploads/contract.pdf' });
console.log(result.data.text);
console.log(result.data.char_count);
// From base64 data
const result = await dms.extractText({
file_data: 'data:application/pdf;base64,...',
file_name: 'invoice.pdf'
});
Get information about data format and structure
Raw data to analyze
Analysis parameters
Promise resolving to data information
const jsonData = [
{ name: "John", age: 30, email: "john@example.com" },
{ name: "Jane", age: 25, email: "jane@example.com" }
];
const dataInfo = await dms.getDataInfo(libraryRef, jsonData, {
format: 'json'
});
console.log(dataInfo.data);
// Output:
// {
// format: "json",
// size_bytes: 245,
// record_count: 2,
// field_count: 3,
// fields: ["name", "age", "email"],
// library_ref: "98bee1cb-0f21-4582-a832-7c32b4b61831"
// }
Get the directory-level policy (resolves platform-default → library → dir)
Directory path
Get a single export archive (an archived snapshot of a library/dir)
Export UUID
{ export, download_url }
Get the effective library-level policy for the project's library
Convert JSON data to CSV format
This method supports both regular JSON arrays and structured data with auto-detection:
JSON data (array of objects or structured data)
Optionaloptions: ConversionOptionsPromise resolving to CSV string
// Regular JSON to CSV
const jsonData = [
{ name: "John Doe", age: 30, email: "john@example.com" },
{ name: "Jane Smith", age: 25, email: "jane@example.com" }
];
const csvResponse = await dms.jsonToCsv(libraryRef, jsonData);
console.log(csvResponse.data);
// Output:
// name,age,email
// John Doe,30,john@example.com
// Jane Smith,25,jane@example.com
// Structured JSON with auto-detection
const structuredData = [
{ metadata: "EMPLOYEE REPORT\nGenerated: 2025-10-08" },
{ name: "John Doe", age: 30, position: "Developer" },
{ name: "Jane Smith", age: 25, position: "Designer" },
{ name: "Total Employees:", age: null, position: "2 people" }
];
const structuredCsv = await dms.jsonToCsv(libraryRef, structuredData);
// Auto-detects header, items, and footer sections
Convert JSON data to Excel (.xlsx) format
Supports both regular JSON arrays and structured data patterns. Excel files are always generated with .xlsx extension.
JSON data (array of objects or structured data)
Optionaloptions: ConversionOptionsOptional conversion options
Promise resolving to Excel file as Blob
// Regular JSON to Excel
const jsonData = [
{ name: "John Doe", age: 30, email: "john@example.com" },
{ name: "Jane Smith", age: 25, email: "jane@example.com" }
];
// Basic conversion
const excelResponse = await dms.jsonToExcel(libraryRef, jsonData);
const blob = excelResponse.data; // Blob for download
// With custom sheet name
const excelWithOptions = await dms.jsonToExcel(libraryRef, jsonData, {
sheet_name: 'Customer Data'
});
// Structured data with explicit sections
const structuredData = {
header: { content: { title: "Monthly Report" } },
items: [{ product: "Widget A", sales: 100 }],
footer: { content: { total_sales: 100 } }
};
const structuredExcel = await dms.jsonToExcel(libraryRef, structuredData);
// Create download link
const url = URL.createObjectURL(structuredExcel.data);
const link = document.createElement('a');
link.href = url;
link.download = 'report.xlsx'; // Always .xlsx extension
link.click();
Optionalparams: DocumentListParamsOptionalparams: DocumentListParamsList export archives for the project's library
List custom reminders scheduled for a specific file
Media UUID
List notification rules for the project's library
Run OCR extraction on an image using a saved model
Crops each labeled region from the image and runs OCR to extract text. Returns structured key-value results.
Model UUID, image (base64 or DMS key), and optional document boundary
Extraction results as label-text pairs
// From a DMS file
const result = await dms.ocrExtract({
model_uuid: 'model-uuid',
image_key: 'uploads/scan.jpg',
document_boundary: { x: 0.05, y: 0.08, width: 0.9, height: 0.85 }
});
console.log(result.data.results);
// { name: "John Smith", date_of_birth: "01.01.1990", id_number: "123456789" }
// From base64
const result = await dms.ocrExtract({
model_uuid: 'model-uuid',
image: 'data:image/jpeg;base64,...'
});
Read a slice of a stored file without transferring the whole object.
Uses an HTTP Range request, so only the requested bytes cross the wire. Slicing is positional and format-agnostic — it works on any file.
// First 64 KiB
const head = await dms.readRange('reports/big.csv', { length: 65536 })
// Continue from where that stopped
const next = await dms.readRange('reports/big.csv', { offset: head.end + 1, length: 65536 })
// Final 1 KiB
const tail = await dms.readRange('reports/big.csv', { suffix: 1024 })
The server caps how much a single call may return, so length is an upper
bound rather than a guarantee: always advance using the returned end
rather than assuming the window you asked for. eof tells you when to stop.
Byte ranges are not meaningful for .xlsx, .zip or .gz — their contents are compressed as a unit, so no byte window corresponds to a range of rows.
Path of the file within the library
Which bytes to read
Optionalparams: anyOptionalparams: anyOptionalparams: anySet/update the directory-level policy
Directory path
Policy fields to set (only fields provided override the library policy)
Set/update the library-level policy for the project's library
Policy fields to set
Read a file as a sequence of byte windows, newest request issued only when the previous window has been consumed.
This is the memory-bounded way to process a large file: the whole object is never held at once, and a caller can stop early simply by breaking out.
for await (const chunk of dms.streamRanges('logs/huge.ndjson', { chunkSize: 1 << 20 })) {
process(chunk.data) // one window at a time
if (foundWhatIWanted) break // no further requests are made
}
Windows are contiguous and non-overlapping, so concatenating every data
reproduces the file byte for byte. A record spanning a window boundary is
the caller's to reassemble — this yields bytes, not records.
An empty object yields nothing rather than throwing.
Path of the file within the library
Where to start and how large each window should be
Upload files using multipart form data
Upload configuration with files, directory, and options
Upload response from the server
Upload files using base64-encoded content
Upload payload with base64-encoded files
Upload response from the server
Validate data format without performing conversion
Raw data to validate
Validation parameters
Promise resolving to validation result
const jsonData = [{ name: "John", age: 30 }];
const validation = await dms.validateData(libraryRef, jsonData, {
format: 'json'
});
console.log(validation.data);
// Output:
// {
// valid: true,
// message: "Data is valid JSON format",
// library_ref: "98bee1cb-0f21-4582-a832-7c32b4b61831"
// }
// Handle invalid data
try {
const invalidValidation = await dms.validateData(libraryRef, "invalid json", {
format: 'json'
});
} catch (error) {
console.error('Validation failed:', error.response?.data?.message);
}
Document Management System (DMS) API client
Provides comprehensive document and media management capabilities including:
Data Conversion Features
The DMS class includes powerful data conversion capabilities that allow you to:
Supported Formats
Structured Data Support
When converting from JSON, the API supports:
Explicit Structure: JSON with dedicated sections
Auto-Detection: Mixed arrays with metadata and summary objects
Error Handling
All conversion methods may throw errors with code 3003 for conversion failures. Always wrap calls in try-catch blocks for production use.
Example