Documents
Manage the document library with the de.iterate SDK.
Overview
The documents resource provides operations for managing your organization's document library, including policies, procedures, evidence, and supporting documentation.
List Documents
typescript
// List all documents
const response = await client.documents.list();
console.log(`Found ${response.documents.length} documents`);
// Filter by type
const policies = await client.documents.list({
filter: { docType: 'Policy' }
});
// Filter by status
const currentDocs = await client.documents.list({
filter: { status: 'Current' }
});Response Example
json
{
"statusCode": 200,
"message": "Success",
"documents": [
{
"id": "DOC-001",
"type": "document",
"fileName": "Information Security Policy.pdf",
"displayName": "Information Security Policy",
"docType": "Policy",
"documentType": "Policy",
"status": "Current",
"owner": "security-team",
"classification": "Internal",
"nextReviewDate": "2025-06-01T00:00:00Z",
"lastReviewDate": "2024-06-01T00:00:00Z",
"dateUploaded": "2023-06-01T10:30:00Z",
"comments": "Annual review required"
}
]
}Search Documents
typescript
// Search by query
const results = await client.documents.search({
query: 'security policy',
searchField: ['fileName', 'comments'],
});
console.log(`Found ${results.documents.length} matching documents`);Search Parameters
| Parameter | Type | Description |
|---|---|---|
query | string | Search query string |
searchField | string | string[] | Fields to search (optional) |
page | { number, size } | Pagination options |
sort | string | Sort field |
Get Document
typescript
const doc = await client.documents.get('DOC-001');
console.log(doc.fileName); // "Information Security Policy.pdf"
console.log(doc.status); // "Current"
console.log(doc.nextReviewDate); // Date objectCreate Document
typescript
const doc = await client.documents.create({
fileName: 'Incident Response Plan.docx',
docType: 'Procedure',
owner: 'security-team',
classification: 'Confidential',
nextReviewDate: new Date('2025-12-01'),
});
console.log(`Created document: ${doc.id}`);CreateDocumentInput
| Field | Type | Required | Description |
|---|---|---|---|
fileName | string | ✅ | Document file name |
docType | string | ✅ | Document type (Policy, Procedure, Form, etc.) |
owner | string | ❌ | Document owner |
classification | string | ❌ | Classification level |
nextReviewDate | Date | ❌ | Next review date |
Update Document
typescript
const updated = await client.documents.update('DOC-001', {
status: 'Current',
owner: 'new-owner@company.com',
nextReviewDate: new Date('2026-06-01'),
});UpdateDocumentInput
| Field | Type | Description |
|---|---|---|
fileName | string | File name |
docType | string | Document type |
owner | string | Owner |
classification | string | Classification |
status | 'Current' | 'Draft' | 'Expired' | Status |
nextReviewDate | Date | Review date |
Delete Document
typescript
await client.documents.delete('DOC-001');Document Type
typescript
interface Document {
id: string;
type: 'document';
fileName: string;
docType?: string;
documentType?: string;
displayName?: string;
status: 'Current' | 'Draft' | 'Expired' | 'Published' | 'Active' | 'In Review';
owner?: string;
classification?: string;
nextReviewDate?: Date;
lastReviewDate?: Date;
createdAt: Date;
updatedAt: Date;
dateUploaded?: Date;
comments?: string;
componentId?: string;
docID?: string;
metadata?: Record<string, unknown>;
}Examples
Document Review Report
typescript
async function documentReviewReport() {
const response = await client.documents.list();
const now = new Date();
const overdue: Document[] = [];
const dueSoon: Document[] = [];
const current: Document[] = [];
for (const doc of response.documents) {
if (!doc.nextReviewDate) {
current.push(doc);
continue;
}
const reviewDate = new Date(doc.nextReviewDate);
const daysUntil = (reviewDate.getTime() - now.getTime()) / (1000 * 60 * 60 * 24);
if (daysUntil < 0) {
overdue.push(doc);
} else if (daysUntil < 30) {
dueSoon.push(doc);
} else {
current.push(doc);
}
}
console.log('Document Review Report');
console.log('======================');
console.log(`🔴 Overdue: ${overdue.length}`);
console.log(`🟡 Due within 30 days: ${dueSoon.length}`);
console.log(`🟢 Current: ${current.length}`);
}Find Expired Documents
typescript
async function findExpiredDocuments() {
const response = await client.documents.list({
filter: { status: 'Expired' }
});
console.log('Expired Documents:');
for (const doc of response.documents) {
console.log(` • ${doc.fileName}`);
console.log(` Owner: ${doc.owner || 'Unassigned'}`);
console.log(` Last Review: ${doc.lastReviewDate}`);
}
}Export Document Inventory
typescript
async function exportDocumentInventory() {
const response = await client.documents.list();
const inventory = response.documents.map(doc => ({
id: doc.id,
name: doc.displayName || doc.fileName,
type: doc.docType,
status: doc.status,
owner: doc.owner,
nextReview: doc.nextReviewDate,
}));
// Export to CSV, JSON, etc.
console.log(JSON.stringify(inventory, null, 2));
}Next Steps
- Policies - Policy management
- Compliance - Document review calendar
- Audits - Audit evidence