Base URL: /api/data
The Data Files API allows you to upload, store, and manage data files (primarily CSV format) that can be used for document generation and email campaigns. All endpoints require JWT authentication.
All endpoints require authentication:
Authorization: Bearer
---
Save/upload a new data file.
Request:
{
"fileName": "customers.csv",
"fileType": "csv",
"fileContent": "Name,Email,Company\\nJohn Doe,john@example.com,Acme Corp\\nJane Smith,jane@example.com,Tech Inc"
}
Required Fields:
fileName (string): Name of the file
fileType (string): Type of file (typically 'csv')
fileContent (string): Complete file content
Success Response (201):
{
"success": true,
"file": {
"Id": "uuid-of-new-file",
"UserId": "uuid-of-user",
"FileName": "customers.csv",
"FileType": "csv",
"CreatedAt": "2026-02-12T10:30:00Z",
"UpdatedAt": "2026-02-12T10:30:00Z"
},
"message": "Data file saved successfully"
}
Error Responses:
400 - Missing Fields:
{
"message": "Missing required fields: fileName, fileType, fileContent"
}
401 - Unauthorized:
{
"message": "User not authenticated"
}
---
Retrieve all data files for the authenticated user.
Success Response (200):
{
"success": true,
"files": [
{
"Id": "uuid-1",
"FileName": "customers.csv",
"FileType": "csv",
"CreatedAt": "2026-02-12T10:30:00Z",
"UpdatedAt": "2026-02-12T10:30:00Z"
},
{
"Id": "uuid-2",
"FileName": "products.csv",
"FileType": "csv",
"CreatedAt": "2026-02-11T09:15:00Z",
"UpdatedAt": "2026-02-11T09:15:00Z"
}
],
"count": 2
}
Note: File content is NOT included in list responses for performance.
---
Retrieve a specific data file by ID, including full content.
URL Parameters:
id (uuid): The file ID
Success Response (200):
{
"success": true,
"file": {
"Id": "uuid-1",
"UserId": "user-uuid",
"FileName": "customers.csv",
"FileType": "csv",
"FileContent": "Name,Email,Company\\nJohn Doe,john@example.com,Acme Corp\\nJane Smith,jane@example.com,Tech Inc",
"CreatedAt": "2026-02-12T10:30:00Z",
"UpdatedAt": "2026-02-12T10:30:00Z"
}
}
Error Responses:
404 - Not Found:
{
"message": "Data file not found"
}
403 - Forbidden (file belongs to different user):
{
"message": "Access denied"
}
---
Update an existing data file.
URL Parameters:
id (uuid): The file ID
Request:
{
"fileName": "customers_updated.csv",
"fileType": "csv",
"fileContent": "Name,Email,Company,Phone\\nJohn Doe,john@example.com,Acme Corp,555-0100"
}
Success Response (200):
{
"success": true,
"file": {
"Id": "uuid-1",
"FileName": "customers_updated.csv",
"FileType": "csv",
"UpdatedAt": "2026-02-12T11:45:00Z"
},
"message": "Data file updated successfully"
}
Error Responses:
404 - Not Found:
{
"message": "Data file not found"
}
403 - Forbidden:
{
"message": "Access denied"
}
---
Delete a data file.
URL Parameters:
id (uuid): The file ID
Success Response (200):
{
"success": true,
"message": "Data file deleted successfully"
}
Error Responses:
404 - Not Found:
{
"message": "Data file not found"
}
403 - Forbidden:
{
"message": "Access denied"
}
---
The Data Files API is complemented by CSV-specific operations at /api/csv:
Upload CSV via multipart/form-data (for large files).
Form Data:
file: CSV file upload
metadata: Optional JSON metadata
Response:
{
"success": true,
"fileId": "uuid",
"fileName": "customers.csv",
"rowCount": 150
}
---
Data files can be used in:
---
---
Name,Email,Company,Title
John Doe,john@example.com,Acme Corp,CEO
Jane Smith,jane@example.com,Tech Inc,CTO
Bob Johnson,bob@example.com,StartUp LLC,Developer
Tips:
"Company, Inc"
customers_2026_q1.csv
/api/csv/upload for files > 1MB
---
// 1. Upload data file
const uploadResponse = await fetch('http://localhost:3001/api/data', {
method: 'POST',
headers: {
'Authorization': 'Bearer ' + token,
'Content-Type': 'application/json'
},
body: JSON.stringify({
fileName: 'customers.csv',
fileType: 'csv',
fileContent: 'Name,Email\\nJohn,john@example.com\\nJane,jane@example.com'
})
});
const { file } = await uploadResponse.json();
console.log('File ID:', file.Id);
// 2. Retrieve file list
const listResponse = await fetch('http://localhost:3001/api/data', {
headers: {
'Authorization': 'Bearer ' + token
}
});
const { files } = await listResponse.json();
console.log('Total files:', files.length);
// 3. Get specific file with content
const detailResponse = await fetch(http://localhost:3001/api/data/${file.Id}, {
headers: {
'Authorization': 'Bearer ' + token
}
});
const { file: fullFile } = await detailResponse.json();
console.log('File content:', fullFile.FileContent);
// 4. Update file
await fetch(http://localhost:3001/api/data/${file.Id}, {
method: 'PUT',
headers: {
'Authorization': 'Bearer ' + token,
'Content-Type': 'application/json'
},
body: JSON.stringify({
fileName: 'customers_updated.csv',
fileType: 'csv',
fileContent: 'Name,Email,Phone\\nJohn,john@example.com,555-0100'
})
});
// 5. Delete file
await fetch(http://localhost:3001/api/data/${file.Id}, {
method: 'DELETE',
headers: {
'Authorization': 'Bearer ' + token
}
});
---