Skip to main content

Overview

This guide covers best practices for designing JSON schemas used with the /schema endpoint.

Schema Format

The schema_config.input_schema field uses the JSON Schema specification (OpenAPI 3.1 compatible). This is the same schema format used by OpenAI’s structured outputs and other LLM providers.

Key JSON Schema Properties

Don’t write schemas by hand! Use the Schema Editor in the Pulse Platform to generate and refine schemas interactively.
The Schema Editor provides two powerful ways to create schemas:

1. Generate from Prompt

Describe what you want to extract in natural language, and the editor will generate a properly formatted JSON Schema for you.
“Extract the account holder name, account number, statement period, opening and closing balances, and all transactions with date, description, and amount.”

2. Interactive Editor

  • Visually add, remove, and reorder fields
  • Set field types and descriptions
  • Mark fields as required
  • Preview the generated schema in real-time
  • Test against sample documents
Once you’re happy with your schema, copy it directly into your API requests. The recommended approach is a two-step flow:
  1. Extract the document via /extract to get an extraction_id
  2. Apply a schema via /schema using the extraction_id
The schema_config object contains:

Bank Statement Example

Here’s an example extracting key fields from a bank statement: Step 1: Extract
Step 2: Apply Schema
Response (schema_output):

SDK Examples

Schema Format

Schemas follow the JSON Schema specification. Each field is defined with:

Data Types

Schema Design Principles

1. Start Simple

Begin with basic fields and gradually add complexity:
Then expand with nested objects and arrays:

2. Use Descriptions

Add description fields to guide extraction:

3. Use schema_prompt for Context

The schema_prompt field provides natural language guidance to help the model understand nuances:

Common Schema Patterns

Invoice / Financial Documents

Medical Records

Advanced Techniques

Conditional Extraction

Use schema_prompt to guide conditional extraction:

Hierarchical Data

For documents with deeply nested structures:

Performance Tips

Keep Schemas Focused

Extract only what you need. Avoid extracting entire documents as single fields.

Use Descriptions

Add description fields to guide the model on ambiguous fields or specific formats.

Leverage schema_prompt

Use schema_prompt to provide context that can’t be expressed in the schema structure alone.

Extract, then apply a schema

Error Handling

Common Schema Errors

Debugging Tips

  1. Start with a minimal schema and add fields incrementally
  2. Use schema_prompt to provide context and clarify ambiguous fields
  3. Check extracted markdown without schema first to see available content
  4. Verify field names match document terminology

Best Practices Summary

  • Use the /schema endpoint for structured output
  • Provide descriptive schema_prompt instructions
  • Use descriptive field names matching document terminology
  • Start simple and iterate
  • Test with real documents
  • Use appropriate data types (number for numeric values)
  • Create overly complex nested structures
  • Use generic field names
  • Extract entire documents as single fields
  • Assume all fields will always exist

Next Steps

Quickstart Guide

See more examples

Schema Endpoint

Apply schemas to extracted documents