Documentation Index
Fetch the complete documentation index at: https://developers.factify.com/llms.txt
Use this file to discover all available pages before exploring further.
Overview
In Factify, a Document is a container that holds one or more immutable file versions. This design ensures a complete audit trail for legal and compliance purposes.
Creating Documents
When you upload a file, Factify creates a Document with Version 1:
const result = await factify.documents.create({
payload: await openAsBlob("./contract.pdf"),
title: "Q4 Sales Agreement",
description: "Annual sales contract for Q4 2024", // Optional
});
const document = result.createDocumentResponse?.document;
console.log(`ID: ${document.id}`);
console.log(`Title: ${document.title}`);
console.log(`Current version: ${document.currentVersion?.id}`);
Immutability & Versioning
Files in Factify are immutable - you cannot modify or overwrite them. Instead, create a new version:
// Upload a new version
const result = await factify.versions.create({
documentId: "doc_01h2xcejqtf2nbrexx3vqjhp41",
body: {
payload: await openAsBlob("./contract-v2.pdf"),
description: "Updated payment terms in section 4.2" // Optional
}
});
console.log(`New version ID: ${result.createDocumentVersionResponse?.version?.id}`);
Why Immutability?
| Benefit | Description |
|---|
| Audit Trail | Every change is recorded with timestamp and metadata |
| Legal Compliance | Original documents are preserved for legal proceedings |
| Rollback | Access any previous version at any time |
| Non-repudiation | Prove what was signed and when |
Retrieving Documents
Get a Single Document
const result = await factify.documents.get({
documentId: "doc_01h2xcejqtf2nbrexx3vqjhp41"
});
const doc = result.getDocumentResponse?.document;
console.log(doc?.title);
console.log(doc?.currentVersion?.id);
console.log(doc?.createdAt);
List All Documents
// Auto-pagination
for await (const page of await factify.documents.list({})) {
for (const doc of page.listDocumentsResponse?.items ?? []) {
console.log(`${doc.id}: ${doc.title}`);
}
}
Version History
List All Versions
// Auto-pagination
for await (const page of await factify.versions.list({
documentId: "doc_01h2xcejqtf2nbrexx3vqjhp41"
})) {
for (const v of page.listVersionsResponse?.items ?? []) {
console.log(`${v.id} - ${v.createdAt}`);
if (v.description) {
console.log(` Change: ${v.description}`);
}
}
}
Get a Specific Version
const result = await factify.versions.get({
versionId: "ver_01h2abcd1234efgh5678jkmnpt"
});
const version = result.getVersionResponse?.version;
console.log(version?.createdAt);
console.log(version?.documentId);
Update document title and description without creating a new version:
await factify.documents.update({
documentId: "doc_01h2xcejqtf2nbrexx3vqjhp41",
body: {
title: "Q4 Sales Agreement (Final)",
description: "Approved by legal team"
}
});