What is a Schema?
A schema defines the structure of data you want to extract from your documents. Parsefy uses JSON Schema to understand exactly what fields to extract, their types, and any validation rules.If you’re using our SDKs, you can define schemas using Pydantic models (Python) or Zod schemas (TypeScript) instead of raw JSON Schema.
Basic Structure
Every Parsefy schema is a JSON object with these key properties:Schema Properties
⚠️ Required vs Optional Fields (Critical for Billing)
How It Works
Why This Matters
If a required field returnsnull or falls below the confidence_threshold:
- The API automatically triggers the fallback model (Tier 2)
- Tier 2 is significantly more expensive
- Your costs increase unexpectedly
Best Practice: Mark Optional Fields
Field Types
Parsefy supports all standard JSON Schema types:String
String
Number
Number
Boolean
Boolean
Array
Array
Nested Object
Nested Object
Complete Financial Document Schema
Here’s a comprehensive invoice extraction schema with proper required/optional fields:Best Practices
Use Descriptions
Always add
description fields. They help the AI understand what to look for and where.Be Specific
“Invoice date in YYYY-MM-DD format” is better than just “date”.
Mark Optional Carefully
Fields missing in >20% of documents should be optional to avoid costly fallbacks.
Use Appropriate Types
Use
number for amounts, integer for counts, string for text.Do’s and Don’ts
- Do
- Don't
The _meta Field
Parsefy automatically injects a _meta field into every extraction response with field-level confidence:
You don’t need to include
_meta in your schema; it’s added automatically.Next Steps
Extraction Rules
Learn how to use custom rules to improve accuracy
Confidence Scores
Understanding the confidence scoring system
