Core concepts / Templates

Templates

A template is a reusable definition of the fields you want to extract. Create it once, then run it against any number of documents.

Overview

Each template has a name, an optional prompt that guides the model, and a list of fields. Every field becomes a key in the extraction’s JSON response, coerced to the type you declare.

Fields & types

NAMETYPEDESCRIPTION
stringtypeFree text — names, identifiers, addresses.
numbertypeNumeric values; returned as JSON numbers.
datetypeCalendar dates, normalized to ISO 8601 (YYYY-MM-DD).
booleantypetrue / false flags.
objecttypeJSON object values, such as checkbox-group maps where each option is true or false.
arraytypeRepeating rows (e.g. line items). Use columns to define each row’s keys.
Descriptions improve accuracyAdd a description to any field to tell the model exactly what to look for. It is the single biggest lever on extraction quality.

Detect fields

POST/v1/templates/detections

Submit one or more representative samples (PDF, PNG, or JPG) and DocMind builds a reusable template: it analyzes every page, proposes fields, checkbox/radio options, and dynamic table columns, verifies that every visible blank line and checkbox is covered, and grounds every bounding box in the document's text layer. Upload the same form in several languages and each extra document is mapped onto the default document's schema as a language variant.

Detection runs asynchronously — the request returns 202 with a job id immediately. Poll GET /v1/templates/detections/:id until status is completed; multi-page documents typically take one to a few minutes. Bounding boxes are returned in a normalized coordinate space: x, y, width, and height are fractions (0–1) of the page, so multiplying by any rendered page size positions them exactly.

Request body
POST /v1/templates/detections
{
  "prompt": "Map every fillable field and table.",
  "documents": [
    { "language_code": "en", "language_name": "English", "is_default": true,
      "filename": "proposal-en.pdf",
      "file": "data:application/pdf;base64,JVBERi0xLjcK..." },
    { "language_code": "rw", "language_name": "Kinyarwanda",
      "filename": "proposal-rw.pdf",
      "file": "data:application/pdf;base64,JVBERi0xLjcK..." }
  ]
}
Job lifecycle
202 Accepted
{ "id": "6f6e2c7e-…", "status": "queued", "created_at": "2026-07-04T08:36:16Z" }

GET /v1/templates/detections/6f6e2c7e-…
{
  "id": "6f6e2c7e-…",
  "status": "completed",
  "result": {
    "document_type": "insurance_proposal",
    "document_title": "EDUCATION INSURANCE PROPOSAL (v2025)",
    "sections": [ /* ... */ ],
    "fields": [
      { "name": "full_names", "type": "string",
        "config": {
          "title": "Names: Mr/Mrs/Miss",
          "bounding_box": { "page": 1, "x": 0.095, "y": 0.061, "width": 0.16, "height": 0.017 },
          "coordinate_space": { "type": "normalized", "page": 1, "width": 1, "height": 1 },
          "variants": { "rw": { "title": "Amazina", "bounding_box": { /* ... */ } } }
        } }
    ]
  }
}
Legacy endpointPOST /v1/templates/detect-fields (single document, single pass, synchronous) still works but is deprecated — new integrations should use detections jobs, which are more thorough and return text-anchored boxes.

Create a template

POST/v1/templates
Request body
POST /v1/templates
{
  "name": "Commercial Invoice",
  "category": "Invoice",
  "prompt": "Extract header fields and line items.",
  "fields": [
    { "name": "invoice_number", "type": "string", "required": true,
      "description": "The invoice identifier, often top-right." },
    { "name": "total_amount", "type": "number" },
    { "name": "issue_date", "type": "date" },
    { "name": "line_items", "type": "array",
      "columns": ["description", "quantity", "amount"] }
  ]
}
201 Created
{
  "id": "9f2a3c91-7d94-4401-94fe-cfbd6fed63f9",
  "name": "Commercial Invoice",
  "slug": "commercial-invoice-7cj1",
  "category": "Invoice",
  "status": "active",
  "fields": [ /* ... */ ],
  "created_at": "2026-06-07T10:14:02Z"
}

List, update, delete

GET/v1/templates

Returns your templates with a field count and run count for each.

GET/v1/templates/:id

Returns one template including its full field list.

PATCH/v1/templates/:id

Update name, category, prompt, status, or replace fields wholesale.

DELETE/v1/templates/:id

Permanently removes the template. Past extractions are unaffected.