DokuBrain
Guides

Extraction Templates

Define custom schemas for extracting structured data from your documents.

Extraction Templates

Templates define the fields you want to extract from a document type. DokuBrain includes 12+ built-in templates, and you can create custom ones for any document type.

Built-in templates

DokuBrain ships with templates for common document types. Use them directly by referencing their ID:

Template IDDocument typeKey fields
invoiceInvoicesvendor, number, date, amounts, line items
contractContractsparties, dates, clauses, obligations
receiptReceiptsmerchant, date, total, items
bank_statementBank statementsaccount, period, balance, transactions
tax_returnTax returnsfiler, year, income, deductions
pay_stubPay stubsemployee, employer, earnings, deductions
employment_letterEmployment lettersemployee, position, salary, dates
ndaNDAsparties, term, scope, exceptions
purchase_orderPurchase ordersbuyer, seller, items, delivery
insurance_policyInsurancepolicyholder, coverage, premium, limits
utility_billUtility billsprovider, account, period, amount
government_idGovernment IDsname, number, dates, issuer

Creating a custom template

Define a custom extraction schema for your document type:

Create a custom template
curl -X POST https://api.dokubrain.com/api/v1/templates \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Lease Agreement",
    "description": "Extract fields from commercial lease agreements",
    "fields": [
      { "name": "landlord", "type": "string", "description": "Name of the landlord/lessor" },
      { "name": "tenant", "type": "string", "description": "Name of the tenant/lessee" },
      { "name": "property_address", "type": "string", "description": "Full address of the leased property" },
      { "name": "monthly_rent", "type": "number", "description": "Monthly rent amount" },
      { "name": "lease_start", "type": "date", "description": "Lease commencement date" },
      { "name": "lease_end", "type": "date", "description": "Lease expiration date" },
      { "name": "security_deposit", "type": "number", "description": "Security deposit amount" },
      { "name": "renewal_terms", "type": "string", "description": "Renewal or extension terms" }
    ]
  }'

Field types

TypeDescriptionExample
stringFree-form text"Acme Corp"
numberNumeric value1250.00
dateDate value"2026-03-15"
booleanTrue/falsetrue
arrayList of values["item1", "item2"]
objectNested fields{ "name": "...", "amount": 100 }

Using custom templates

Once created, use your template ID when extracting:

curl -X POST https://api.dokubrain.com/api/v1/documents/doc_abc123/extract \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "templateId": "tmpl_custom123" }'

On this page