curl --request GET \
--url https://api.example.com/api/batch/template{
"template": "<string>",
"columns": [
{
"name": "<string>",
"required": true,
"description": "<string>"
}
]
}Get CSV template with sample data for batch processing
curl --request GET \
--url https://api.example.com/api/batch/template{
"template": "<string>",
"columns": [
{
"name": "<string>",
"required": true,
"description": "<string>"
}
]
}Authorization: Bearer your_access_token
GET /api/batch/template
{
"template": "title,description,file_source_type,file_path,publishing_date,file_size\n\"Training Manual\",\"PMSPECIAL training document\",url,https://example.com/doc1.pdf,2025-01-15,1.2MB\n\"Annual Report 2024\",\"Financial report\",url,https://example.com/doc2.pdf,2024-12-31,2.5MB",
"columns": [
{
"name": "title",
"required": true,
"description": "Document title"
},
{
"name": "description",
"required": false,
"description": "Document description"
},
{
"name": "file_source_type",
"required": true,
"description": "Source type: url, s3, or local"
},
{
"name": "file_path",
"required": true,
"description": "Path or URL to the file"
},
{
"name": "publishing_date",
"required": false,
"description": "Publication date"
},
{
"name": "file_size",
"required": false,
"description": "File size"
}
]
}
url - HTTP/HTTPS URLs3 - Amazon S3 pathlocal - Local filesystem pathhttps://example.com/document.pdfs3://bucket-name/path/to/file.pdf or bucket-name/path/to/file.pdf/absolute/path/to/file.pdftitle,description,file_source_type,file_path,publishing_date,file_size
"Training Manual","PMSPECIAL training document",url,https://example.com/doc1.pdf,2025-01-15,1.2MB
"Annual Report 2024","Financial report",url,https://example.com/doc2.pdf,2024-12-31,2.5MB
curl -X GET "http://localhost:8000/api/batch/template" \
-H "Authorization: Bearer your_access_token" \
| jq -r '.template' > template.csv
interface CSVColumn {
name: string;
required: boolean;
description: string;
}
interface TemplateResponse {
template: string;
columns: CSVColumn[];
}
async function downloadTemplate(token: string): Promise<void> {
const response = await fetch('http://localhost:8000/api/batch/template', {
headers: {
'Authorization': `Bearer ${token}`,
},
});
if (!response.ok) {
throw new Error(`Failed to fetch template: ${response.statusText}`);
}
const data: TemplateResponse = await response.json();
// Create downloadable file
const blob = new Blob([data.template], { type: 'text/csv' });
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'batch_template.csv';
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);
document.body.removeChild(a);
// Display column info
console.log('CSV Columns:');
data.columns.forEach(col => {
const req = col.required ? '(required)' : '(optional)';
console.log(` ${col.name} ${req}: ${col.description}`);
});
}
// Usage
await downloadTemplate('your_access_token');
import requests
import csv
from io import StringIO
def download_template(token: str, output_file: str = "template.csv"):
response = requests.get(
"http://localhost:8000/api/batch/template",
headers={"Authorization": f"Bearer {token}"}
)
response.raise_for_status()
data = response.json()
# Save template to file
with open(output_file, 'w', newline='') as f:
f.write(data['template'])
print(f"Template saved to {output_file}")
print("\nColumns:")
for col in data['columns']:
req = "(required)" if col['required'] else "(optional)"
print(f" {col['name']} {req}: {col['description']}")
return data
# Usage
template_data = download_template("your_access_token")
title,description,file_source_type,file_path,publishing_date,file_size
"Employee Handbook 2025","Updated company policies",url,https://cdn.example.com/handbook.pdf,2025-01-01,3.5MB
"Q4 Financial Report","Quarterly earnings and analysis",s3,company-docs/reports/q4-2024.pdf,2024-12-31,1.8MB
"Marketing Strategy","2025 marketing plan and budget",local,/data/documents/marketing-2025.pdf,2025-01-15,2.1MB
"").title,description,file_source_type,file_path,publishing_date,file_size
"Document with, comma","Description with ""quotes""",url,https://example.com/doc.pdf,2025-01-15,1MB
file_source_type value matches the actual path format. Using url for an S3 path or vice versa will cause validation errors.