What are Templates?
Templates are reusable extraction schemas that define what data to extract from specific document types. Instead of providing a schema with each request, you can create templates once and reference them by ID.Benefits of Templates
Reusability
Define once, use many times across all your documents
Consistency
Ensure consistent extraction across all documents of the same type
Versioning
Track changes and maintain multiple versions
Team Collaboration
Share templates across your organization
Creating a Template
Templates require:- Name: Descriptive identifier for the template
- Schema: JSON Schema defining fields to extract
- Description: Purpose and use case
- Custom ID: Readable identifier instead of UUID
- Instruction: Additional guidance for the AI
- Config: Advanced processing settings (parser, chunking, citations)
For complete API details and request/response examples, see the Template API Reference.
Using Templates
Once created, reference templates by ID or custom_id in your predict requests instead of providing a schema. Using UUID:template_id: "550e8400-e29b-41d4-a716-446655440000"
template_id: "INVOICE"(more readable)
For complete request/response examples, see the Predict Async API Reference.
Managing Templates
Templates can be listed, retrieved, updated, and deleted through the API. Available operations:- List Templates - Get paginated list with optional search/filtering
- Get Template - Retrieve full template details including schema
- Update Template - Modify name, description, schema, or config
- Delete Template - Soft delete (can be restored)
For complete API details, see the Template Management API Reference.
Auto-Schema Generation
Generate JSON schemas automatically from natural language descriptions. Describe what fields you want to extract, and the API will create a properly formatted schema. Example input: “Extract invoice number, date, vendor name, total amount, and line items with description and quantity” Output: Properly formatted JSON Schema ready to use in template creationFor complete API details, see the Auto-Schema Generation API Reference.
Template Configuration Options
Templates can include configuration to control processing behavior. These settings become defaults for all documents processed with the template.Parser Configuration
Control parsing behavior and quality modes
Chunking Strategies
Split large documents for better processing
Citations
Track source of extracted data
For all configuration options, examples, and detailed explanations, see the Configuration Overview.
Schema Design Best Practices
Use Descriptive Field Names and Descriptions
Use Descriptive Field Names and Descriptions
Every property must include both Bad Example:
type and description. Use clear, specific field names and descriptions.Good Example:Specify Correct Data Types
Specify Correct Data Types
Use appropriate JSON Schema data types for your fields:Available Types:
string- Text values (names, addresses, IDs, dates as ISO strings)number- Numeric values including decimals (prices, percentages, measurements)integer- Whole numbers only (counts, quantities, IDs)boolean- True/false values (flags, status indicators)array- Lists of items (line items, transactions, tags)object- Nested structures (addresses, contact info, metadata)
enum- Restrict values to a specific set of allowed options
Handle Nested Structures
Handle Nested Structures
Schemas support nested objects and arrays up to 3 levels deep.Example (3 levels):
Handle Optional/Nullable Fields
Handle Optional/Nullable Fields
All fields must be listed in the In this example:
required array. To make a field optional (nullable), use anyOf to allow both the field type and null.- All fields are in the
requiredarray (OpenAI requirement) invoice_numberandtotalmust have valuesnotesanddiscountcan benullif not found in the document
Template Example
This example demonstrates all schema best practices in one comprehensive template:- ✅ Descriptive field names with descriptions for every property
- ✅ Multiple data types:
string,number,integer,boolean,array,object - ✅ Enum constraint for status field with predefined values
- ✅ Nested objects (vendor) and arrays (line_items) - 2 levels deep
- ✅ Optional/nullable field (notes) using
anyOfwithnull - ✅ All properties in
requiredarray (OpenAI requirement) - ✅ Custom ID for easy reference instead of UUID
Versioning Templates
Maintain multiple versions of templates:-
Use Custom IDs with Versions
-
Include Version in Name
-
Update Description with Changelog