8 min read

List Documents

List all processed documents with pagination, filtering, and sorting options

Retrieve a paginated list of all documents processed by your organization. Supports filtering by document type, status, and date range.

GET/v1/documents

Overview

Use this endpoint to:

  • Browse all processed documents
  • Filter documents by type or status
  • Search for specific documents
  • Export document history
  • Monitor processing queue

Request

Headers

ParameterTypeDescription
X-API-Keyrequired
stringYour DocuRift API key (format: frc_xxxxx)

Query Parameters

ParameterTypeDescription
page
numberPage number for pagination (1-indexed)
Default: 1
limit
numberNumber of documents per page (max 100)
Default: 20
documentType
stringFilter by document type (invoice, bill_of_lading, etc.)
status
stringFilter by status (queued, processing, completed, failed)
startDate
stringFilter documents created after this date (ISO 8601 format)
endDate
stringFilter documents created before this date (ISO 8601 format)
search
stringSearch by file name or document ID
sortBy
stringSort field: createdAt, processedAt, fileName, confidence
Default: createdAt
sortOrder
stringSort order: asc or desc
Default: desc

Code Examples

cURL

curl
curl -X GET "https://api.docurift.com/v1/documents" \
-H "X-API-Key: frc_your_api_key_here"

cURL (with filters)

curl_filtered
curl -X GET "https://api.docurift.com/v1/documents?documentType=invoice&status=completed&limit=50&sortBy=createdAt&sortOrder=desc" \
-H "X-API-Key: frc_your_api_key_here"

cURL (date range)

curl_date_range
curl -X GET "https://api.docurift.com/v1/documents?startDate=2024-01-01T00:00:00Z&endDate=2024-01-31T23:59:59Z" \
-H "X-API-Key: frc_your_api_key_here"

Python

list_documents.py
import requests
import os
from datetime import datetime, timedelta

API_KEY = os.getenv('DOCURIFT_API_KEY')
API_URL = 'https://api.docurift.com/v1'

def list_documents(
  page=1,
  limit=20,
  document_type=None,
  status=None,
  start_date=None,
  end_date=None,
  search=None,
  sort_by='createdAt',
  sort_order='desc'
):
  """List documents with optional filters."""
  headers = {
      'X-API-Key': API_KEY
  }

  params = {
      'page': page,
      'limit': limit,
      'sortBy': sort_by,
      'sortOrder': sort_order
  }

  if document_type:
      params['documentType'] = document_type
  if status:
      params['status'] = status
  if start_date:
      params['startDate'] = start_date
  if end_date:
      params['endDate'] = end_date
  if search:
      params['search'] = search

  response = requests.get(
      f'{API_URL}/documents',
      headers=headers,
      params=params
  )

  response.raise_for_status()
  return response.json()

# Example: List all completed invoices
result = list_documents(
  document_type='invoice',
  status='completed',
  limit=50
)

print(f"Total documents: {result['data']['pagination']['total']}")
for doc in result['data']['documents']:
  print(f"- {doc['fileName']} ({doc['status']}) - {doc['confidence']}")

# Example: List documents from last 7 days
end_date = datetime.utcnow()
start_date = end_date - timedelta(days=7)

recent_docs = list_documents(
  start_date=start_date.isoformat() + 'Z',
  end_date=end_date.isoformat() + 'Z'
)
print(f"Documents in last 7 days: {recent_docs['data']['pagination']['total']}")

JavaScript

listDocuments.js
const API_KEY = process.env.DOCURIFT_API_KEY;
const API_URL = 'https://api.docurift.com/v1';

async function listDocuments(options = {}) {
const params = new URLSearchParams({
  page: options.page || 1,
  limit: options.limit || 20,
  sortBy: options.sortBy || 'createdAt',
  sortOrder: options.sortOrder || 'desc'
});

if (options.documentType) params.append('documentType', options.documentType);
if (options.status) params.append('status', options.status);
if (options.startDate) params.append('startDate', options.startDate);
if (options.endDate) params.append('endDate', options.endDate);
if (options.search) params.append('search', options.search);

const response = await fetch(`${API_URL}/documents?${params}`, {
  headers: {
    'X-API-Key': API_KEY
  }
});

if (!response.ok) {
  const error = await response.json();
  throw new Error(error.error.message);
}

return response.json();
}

// Example: List completed invoices
const result = await listDocuments({
documentType: 'invoice',
status: 'completed',
limit: 50
});

console.log('Total:', result.data.pagination.total);
result.data.documents.forEach(doc => {
console.log(`- ${doc.fileName} (${doc.status})`);
});

// Example: Paginate through all documents
async function getAllDocuments() {
const allDocs = [];
let page = 1;
let hasMore = true;

while (hasMore) {
  const result = await listDocuments({ page, limit: 100 });
  allDocs.push(...result.data.documents);

  const { currentPage, totalPages } = result.data.pagination;
  hasMore = currentPage < totalPages;
  page++;
}

return allDocs;
}

Response

Success Response (200 OK)

response.json
{
"success": true,
"data": {
  "documents": [
    {
      "id": "doc_abc123xyz456",
      "fileName": "invoice-jan-2024.pdf",
      "fileType": "application/pdf",
      "fileSize": 245678,
      "documentType": "invoice",
      "status": "completed",
      "pagesProcessed": 2,
      "confidence": 0.96,
      "createdAt": "2024-01-26T10:30:00Z",
      "processedAt": "2024-01-26T10:30:02Z"
    },
    {
      "id": "doc_def456uvw789",
      "fileName": "bill-of-lading.pdf",
      "fileType": "application/pdf",
      "fileSize": 512000,
      "documentType": "bill_of_lading",
      "status": "completed",
      "pagesProcessed": 3,
      "confidence": 0.94,
      "createdAt": "2024-01-25T14:22:00Z",
      "processedAt": "2024-01-25T14:22:05Z"
    },
    {
      "id": "doc_ghi789rst012",
      "fileName": "packing-list.png",
      "fileType": "image/png",
      "fileSize": 1234567,
      "documentType": "packing_list",
      "status": "processing",
      "pagesProcessed": 0,
      "confidence": null,
      "createdAt": "2024-01-26T11:00:00Z",
      "processedAt": null
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 20,
    "total": 156,
    "totalPages": 8,
    "hasNextPage": true,
    "hasPreviousPage": false
  },
  "filters": {
    "documentType": null,
    "status": null,
    "startDate": null,
    "endDate": null
  }
}
}

Response Fields

Document Object

ParameterTypeDescription
id
stringUnique document identifier
fileName
stringOriginal uploaded file name
fileType
stringMIME type of the file
fileSize
numberFile size in bytes
documentType
stringDocument type used for processing
status
stringProcessing status
pagesProcessed
numberNumber of pages processed
confidence
numberExtraction confidence (null if not completed)
createdAt
stringISO 8601 timestamp of upload
processedAt
stringISO 8601 timestamp of completion

Pagination Object

ParameterTypeDescription
page
numberCurrent page number
limit
numberItems per page
total
numberTotal number of documents matching filters
totalPages
numberTotal number of pages
hasNextPage
booleanWhether there are more pages
hasPreviousPage
booleanWhether there are previous pages

Filter Options

Document Types

| Value | Description | |-------|-------------| | generic | Auto-detected documents | | invoice | Commercial invoices | | bill_of_lading | Bills of lading | | packing_list | Packing lists | | customs_declaration | Customs forms | | certificate_of_origin | Origin certificates | | delivery_order | Delivery orders | | freight_invoice | Freight invoices | | air_waybill | Air cargo waybills | | sea_waybill | Ocean cargo waybills |

Status Values

| Value | Description | |-------|-------------| | queued | Waiting in processing queue | | processing | Currently being processed | | completed | Successfully processed | | failed | Processing failed |

Sort Options

| Field | Description | |-------|-------------| | createdAt | Sort by upload date (default) | | processedAt | Sort by completion date | | fileName | Sort alphabetically by file name | | confidence | Sort by extraction confidence |

Error Responses

400 Bad Request

error_400.json
{
"success": false,
"error": {
  "code": "INVALID_PARAMETER",
  "message": "Invalid sortBy value. Must be one of: createdAt, processedAt, fileName, confidence"
}
}

401 Unauthorized

error_401.json
{
"success": false,
"error": {
  "code": "INVALID_API_KEY",
  "message": "Invalid API key"
}
}

Error Codes Reference

| Code | HTTP Status | Description | Solution | |------|-------------|-------------|----------| | INVALID_API_KEY | 401 | API key invalid or expired | Verify API key | | INVALID_PARAMETER | 400 | Invalid query parameter value | Check parameter values | | INVALID_DATE_FORMAT | 400 | Date not in ISO 8601 format | Use format: 2024-01-26T00:00:00Z |

Best Practices

Efficient Pagination

efficient_pagination.py
async def iterate_all_documents(filters=None):
  """
  Efficiently iterate through all documents.
  Uses generator pattern to avoid loading all documents into memory.
  """
  page = 1

  while True:
      result = list_documents(page=page, limit=100, **(filters or {}))

      for doc in result['data']['documents']:
          yield doc

      if not result['data']['pagination']['hasNextPage']:
          break

      page += 1

# Usage
async for doc in iterate_all_documents({'status': 'completed'}):
  process_document(doc)

Caching List Results

caching.js
// Cache list results for short periods to reduce API calls
const cache = new Map();
const CACHE_TTL = 60000; // 1 minute

async function listDocumentsCached(options = {}) {
const cacheKey = JSON.stringify(options);
const cached = cache.get(cacheKey);

if (cached && Date.now() - cached.timestamp < CACHE_TTL) {
  return cached.data;
}

const result = await listDocuments(options);
cache.set(cacheKey, { data: result, timestamp: Date.now() });

return result;
}

Filtering by Date Range

date_filtering.js
// Get documents from this month
const now = new Date();
const startOfMonth = new Date(now.getFullYear(), now.getMonth(), 1);
const endOfMonth = new Date(now.getFullYear(), now.getMonth() + 1, 0, 23, 59, 59);

const monthlyDocs = await listDocuments({
startDate: startOfMonth.toISOString(),
endDate: endOfMonth.toISOString()
});

// Get documents from last 24 hours
const yesterday = new Date(Date.now() - 24 * 60 * 60 * 1000);
const recentDocs = await listDocuments({
startDate: yesterday.toISOString()
});
💡

Performance

For large document collections, use specific filters to reduce response size. The API limits results to 100 documents per page maximum.

⚠️

Rate Limiting

List requests count toward your rate limit. Consider caching results when possible.