Documents
The docs namespace manages PDF files in the Pdffillr SDK. Upload a PDF once to receive a numeric doc_id - that identifier drives every subsequent operation: checking status, fetching a URL, triggering the AI fill pipeline, or attaching the file to a chat session.
1. Overview
A document is a PDF you upload to your developer storage. On upload the SDK assigns a numeric doc_id that uniquely identifies the file under your API key. Every subsequent operation - checking fill status, generating a download URL, kicking off the AI pipeline, attaching the file to a chat session - refers to the document by that ID. Documents are scoped to your API key: other keys and accounts never see your files.
docs.upload(body)Upload a PDFStores the file and returns a doc_id. Every other operation starts here - you must upload before you can fill, preview, or attach.
docs.getURL(docID, query?)Get a download URLReturns either the raw S3 key path or a temporary presigned URL valid for 1 hour - ready for browser download or in-app preview.
docs.getMetadata(docID)Check document metadataRetrieves the filename, size, upload time, and fill status for a single document. Use this to poll for fill job completion.
docs.list()List all your documentsReturns every PDF stored under your API key, ordered newest first. Useful for building document management UIs.
docs.delete(docID)Delete a documentPermanently removes the file and its S3 storage object. Cannot be undone - download the filled PDF before deleting.
docs.uploadFilledInfo(params)Trigger AI form fillingUploads filled-in data and kicks off the AI fill pipeline against a blank PDF. Asynchronous - poll getMetadata() for the result.
sessions.attachDocument(sessionID, body)Attach to a chat sessionLinks an uploaded PDF to an active chat session so the AI can reference its content when answering questions.
import Pdffillr from '@pdffillr/sdk';
import fs from 'fs';
const client = new Pdffillr({
apiKey: process.env['PDFFILLR_API_KEY'],
});
// 1. upload() - store the PDF and receive a doc_id.
const doc = await client.sdk.docs.upload({
file: fs.createReadStream('form.pdf'),
});
console.log('Uploaded:', doc.doc_id);
// 2. list() - see every document stored under this API key.
const allDocs = await client.sdk.docs.list();
console.log(`${allDocs.length} documents on file`);
// 3. getMetadata() - check fill status before triggering a fill.
const meta = await client.sdk.docs.getMetadata(doc.doc_id);
console.log('Fill status:', meta.fill_status);
// 4. getURL() - get a presigned URL for browser preview (valid 1 hour).
const { url } = await client.sdk.docs.getURL(doc.doc_id, { presigned: true });
console.log('Preview URL:', url);
// 5. delete() - remove the document and its S3 object permanently.
await client.sdk.docs.delete(doc.doc_id);
console.log('Deleted.');2. Upload a Document
Uploads a PDF file to your developer storage and returns a numeric doc_id. That identifier is the entry point for every subsequent operation - filling, polling results, fetching a URL, and chat context. Files must be PDF format and no larger than 10 MB.
client.sdk.docs.upload(body, options?)POST /v1/sdk/docs/uploadPromise<DocRecord>body.file: Uploadable| Parameter | Type | Required | Description |
|---|---|---|---|
| file | Uploadable | Yes | The PDF file to upload. Pass fs.createReadStream(path) in Node.js or a File/Blob in browser environments. Must be PDF format, maximum 10 MB. |
import Pdffillr from '@pdffillr/sdk';
import fs from 'fs';
const client = new Pdffillr({
apiKey: process.env['PDFFILLR_API_KEY'],
});
// Upload a PDF - the returned doc_id is used in all subsequent operations.
const doc = await client.sdk.docs.upload({
file: fs.createReadStream('path/to/document.pdf'),
});
console.log('Uploaded doc_id:', doc.doc_id);doc_id returned by upload() is the only handle you have to the stored file. Save it in your database - the SDK provides no search-by-filename API.3. Get Document URL
Returns a URL for accessing the raw, unfilled PDF. By default (presigned=false) the response contains the stored S3 key path. Pass presigned: true to receive a temporary presigned S3 URL valid for one hour - suitable for direct browser download or in-app preview without exposing your credentials.
client.sdk.docs.getURL(docID, query?, options?)GET /v1/sdk/docs/{docId}/urlPromise<{ url: string }>docID: number| Parameter | Type | Default | Description |
|---|---|---|---|
| presigned | boolean | false | When false, returns the stored S3 key path. When true, returns a temporary presigned URL valid for 1 hour. |
import Pdffillr from '@pdffillr/sdk';
const client = new Pdffillr({
apiKey: process.env['PDFFILLR_API_KEY'],
});
// Default (presigned=false): returns the stored S3 key path.
const keyResult = await client.sdk.docs.getURL(42);
console.log('S3 key:', keyResult.url);
// presigned=true: returns a temporary URL valid for 1 hour.
// Use this when you need to serve the file directly in a browser.
const presignedResult = await client.sdk.docs.getURL(42, { presigned: true });
console.log('Presigned URL:', presignedResult.url);4. Get Document Metadata
Retrieves the stored metadata for a single document identified by its doc_id. The response includes the filename, MIME type, file size, upload timestamp, and the current fill_status. Check this status before initiating a fill job or before serving the filled PDF to a user.
client.sdk.docs.getMetadata(docID, options?)GET /v1/sdk/docs/{docId}Promise<DocRecord>docID: number| Field | Type | Description |
|---|---|---|
| doc_id | number | The unique numeric identifier for this document. |
| filename | string | The original filename as uploaded. |
| mime_type | string | The detected MIME type (application/pdf). |
| size_bytes | number | File size in bytes. |
| uploaded_at | string (ISO 8601) | When the document was uploaded. |
| fill_status | "pending" | "ready" | "failed" | Current state of the AI fill pipeline for this document. |
import Pdffillr from '@pdffillr/sdk';
const client = new Pdffillr({
apiKey: process.env['PDFFILLR_API_KEY'],
});
// Retrieve metadata for a single document by its doc_id.
const meta = await client.sdk.docs.getMetadata(42);
console.log('Filename: ', meta.filename);
console.log('MIME type: ', meta.mime_type);
console.log('Size: ', meta.size_bytes, 'bytes');
console.log('Fill status: ', meta.fill_status); // 'pending' | 'ready' | 'failed'
console.log('Uploaded at: ', meta.uploaded_at);getMetadata() is the recommended way to poll for fill job completion. Call it every 3-5 seconds after uploadFilledInfo() and wait for fill_status to become ready or failed.5. List All Documents
Returns every document uploaded under your API key, ordered by upload date descending (newest first). The response is strictly scoped to your key - documents belonging to other API keys or accounts are never returned. Each record includes the doc_id, filename, MIME type, size, upload timestamp, and fill status.
client.sdk.docs.list(options?)GET /v1/sdk/docsPromise<DocRecord[]>import Pdffillr from '@pdffillr/sdk';
const client = new Pdffillr({
apiKey: process.env['PDFFILLR_API_KEY'],
});
// Returns all documents uploaded under this API key - newest first.
const docs = await client.sdk.docs.list();
docs.forEach((d) => {
console.log(`[${d.fill_status}] ${d.doc_id} - ${d.filename}`);
console.log(` Size: ${d.size_bytes} bytes, Uploaded: ${d.uploaded_at}`);
});6. Delete a Document
Permanently deletes the document identified by docID and removes its associated S3 storage object. This action cannot be undone. Any in-progress fill jobs referencing the document will fail after deletion. Only the document specified is affected - all other documents under your API key remain untouched.
client.sdk.docs.delete(docID, options?)DELETE /v1/sdk/docs/{docId}Promise<void>docID: numberimport Pdffillr from '@pdffillr/sdk';
const client = new Pdffillr({
apiKey: process.env['PDFFILLR_API_KEY'],
});
// Permanently delete a document and its associated S3 object.
// This cannot be undone.
await client.sdk.docs.delete(42);
console.log('Document 42 deleted.');delete().7. Trigger AI Form Filling
Uploads a filled-info data file and queues the AI form-filling pipeline against an existing blank PDF. The pipeline is asynchronous - this call returns immediately after the job is queued. Poll getMetadata() every 3-5 seconds until fill_status becomes ready, then download the filled PDF via getURL() with presigned: true.
client.sdk.docs.uploadFilledInfo(params, options?)POST /v1/sdk/docs/upload-filled-infoPromise<void>pdf_doc_id, file| Parameter | Type | Required | Description |
|---|---|---|---|
| pdf_doc_id | number | Yes | The doc_id of the blank PDF template uploaded via docs.upload(). |
| file | Uploadable | Yes | The filled-info file (JSON or structured data) containing the values to inject into the form fields. |
import Pdffillr from '@pdffillr/sdk';
import fs from 'fs';
const client = new Pdffillr({
apiKey: process.env['PDFFILLR_API_KEY'],
});
// Step 1 - upload the blank PDF template.
const template = await client.sdk.docs.upload({
file: fs.createReadStream('blank-form.pdf'),
});
// Step 2 - upload filled-info data to trigger the AI fill pipeline.
await client.sdk.docs.uploadFilledInfo({
pdf_doc_id: template.doc_id,
file: fs.createReadStream('filled-data.json'),
});
console.log('Fill job queued - polling for result...');
// Step 3 - poll pollFillResult() every 3-5 seconds until status is 'ready'.
let result;
do {
await new Promise((r) => setTimeout(r, 3000));
result = await client.sdk.docs.pollFillResult(template.doc_id);
} while (result.status === 'processing');
if (result.status === 'ready') {
// Step 4 - download the filled PDF using the provided URL (expires 1 hr).
console.log('Filled PDF ready:', result.url);
} else {
console.error('Fill job failed:', result.error);
}uploadFilledInfo() queues the job and returns immediately. Do not assume the PDF is ready after this call - always poll getMetadata() until fill_status is no longer pending.8. Attach to a Session
Attaches a previously uploaded PDF to a chat session. Once attached, the AI can reference the document's content when answering questions in all subsequent messages within that session. The document must already exist - upload it first using docs.upload(). You can attach multiple documents to a single session by calling this method multiple times with different doc_id values.
client.sdk.chat.sessions.attachDocument(sessionID, body, options?)POST /v1/sdk/chat/sessions/{sessionId}/attach-documentPromise<void>sessionID, body.doc_id| Parameter | Type | Required | Description |
|---|---|---|---|
| doc_id | number | Yes | The doc_id of the PDF to attach - must have been uploaded via docs.upload() first. |
import Pdffillr from '@pdffillr/sdk';
import fs from 'fs';
const client = new Pdffillr({
apiKey: process.env['PDFFILLR_API_KEY'],
});
// 1. Upload the PDF to get a doc_id.
const doc = await client.sdk.docs.upload({
file: fs.createReadStream('contract.pdf'),
});
// 2. Create a chat session.
const session = await client.sdk.chat.sessions.create({ title: 'Contract Review' });
// 3. Attach the document to the session.
// Once attached, the AI can reference its content in all subsequent messages.
await client.sdk.chat.sessions.attachDocument(session.session_id, {
doc_id: doc.doc_id,
});
console.log('Document attached - the AI can now reference it in this session.');
// You can attach multiple documents by calling attachDocument again with a new doc_id.attachDocument() expects the PDF to already exist in storage. Always call docs.upload() first and use the returned doc_id in the body.What to read next
See how document upload fits into the Upload Document and URL import flows end to end.
Read moreConfigurationGlobal SDK options, timeouts, base URL overrides, and per-request settings.
Read morePDF FillingDeep dive into form-field detection, fill strategies, and how to download filled output.
Read morePDFFILLR.AI
The intelligent layer for modern fund
administration. Automating high-stakes
documentation with precision and speed.