Skip to main content

Overview

For automation pipelines, you need to detect when a human has reviewed and corrected an extraction. This guide shows how to implement efficient, robust polling to wait for the is_reviewed flag to become true.

The Review Lifecycle

1

Extraction Flagged

AI extraction completes with needs_review = true due to low-confidence fields.
2

Reviewer Notified

Human reviewer sees the extraction in the pending reviews queue.
3

Review Completed

Reviewer corrects fields and saves, setting is_reviewed = true.
4

Automation Resumes

Your polling detects the change and retrieves reviewed_results.

Basic Polling Implementation

Python Example

Node.js/TypeScript Example

Advanced Polling Strategies

Exponential Backoff

Reduce API calls by increasing poll interval over time:
Exponential backoff is ideal when you don’t know how long reviews will take. It starts fast for quick reviews but backs off for longer ones.

Batch Polling

Poll multiple documents efficiently:

Concurrent Polling

Use asyncio for efficient concurrent polling:

Best Practices

Balance responsiveness vs API usage:
10-15 second intervals work well for most automation scenarios.
Set realistic timeouts based on your review SLA:
Don’t let transient errors stop your polling:
Track polling for debugging and optimization:

Query Options

Filter by Document ID

Most efficient for single-document polling:

Filter by Status

For batch polling of pending reviews:

Filter by Date Range

Poll for documents extracted in a specific timeframe:

Monitoring & Alerting

Track these metrics:
If timeout rate exceeds 20%, review your timeout settings or alert your review team about delays.

Complete Example

Here’s a production-ready polling implementation:

Next Steps

List Extractions

Learn all query options for the extractions endpoint

Understanding Reviews

Deep dive into how review flagging works

Automation Patterns

See complete automation workflow examples