How the Terrafai API Works
At a high level, document extraction with Terrafai follows a simple flow:- Define what data you want using templates
- Optionally classify documents using filters
- Submit documents for extraction
- Retrieve structured results
Core Concepts
Templates
Templates define what information should be extracted from a document and how the output should be structured. A template consists of:- A set of fields written in natural language
- Data types that control how values are parsed and formatted
- Optional rules that transform or normalize extracted data
Filters
Filters allow you to classify, route, or skip documents before extraction. They are designed for workflows where:- Multiple document types are submitted through the same integration
- Different templates should be applied automatically
- Irrelevant or unsupported documents should be ignored
- Whether it should be extracted
- Which template should be applied
Extraction Modes
The API supports two extraction modes:- Synchronous extraction
Returns results in a single request–response cycle. Best for small documents and real-time use cases. - Asynchronous extraction
Processes documents in the background and returns a job identifier. Best for large documents, batch processing, or long-running extractions.