Skip to main content

Overview

This quickstart walks you through uploading your first document, creating a version, and generating a shareable link.
1

Install the SDK

Install the Factify SDK using your preferred package manager:
npm install @factify/sdk
2

Set Your API Key

Get your API key from the Developer Dashboard and set it as an environment variable:
export FACTIFY_KEY=ffy_live_xxxxxxxxxxxxxxxxxxxx
3

Upload a Document

Create your first document by uploading a PDF:
import { Factify } from "@factify/sdk";
import { openAsBlob } from "node:fs";

const factify = new Factify({ bearerAuth: process.env.FACTIFY_KEY });

const result = await factify.documents.create({
  payload: await openAsBlob("./contract.pdf"),
  title: "My First Document",
});

console.log(`Document ID: ${result.createDocumentResponse?.document.id}`);
4

Generate a Share Link

Create a secure, time-limited URL to share the document:
const entry = await factify.entryPages.generate({
  documentId: result.createDocumentResponse?.document.id,
});

console.log(`Share URL: ${entry.generateEntryPageResponse?.downloadUrl}`);

Complete Example

Here’s a complete working example:
import { Factify } from "@factify/sdk";
import { openAsBlob } from "node:fs";

async function main() {
  // Initialize client
  const factify = new Factify({ bearerAuth: process.env.FACTIFY_KEY });

  // Upload document
  const doc = await factify.documents.create({
    payload: await openAsBlob("./contract.pdf"),
    title: "Q4 Sales Agreement",
  });

  const documentId = doc.createDocumentResponse?.document.id;
  console.log(`Created document: ${documentId}`);

  // Generate share link
  const entry = await factify.entryPages.generate({
    documentId
  });

  console.log(`Share URL: ${entry.generateEntryPageResponse?.downloadUrl}`);

  // List all documents with auto-pagination
  for await (const page of await factify.documents.list({ pageSize: 10 })) {
    for (const d of page.listDocumentsResponse?.items ?? []) {
      console.log(`- ${d.title} (${d.id})`);
    }
  }
}

main();