API Reference

Split

Send one file that holds several documents. Each document is found, typed and extracted in one request.

Split

Send one file that holds several documents. Each document is found, typed and extracted in one request.


What it does

Some files hold more than one document: a scanned mail batch, a loan package, a month of invoices in one PDF. You send the file and the list of document types you expect. DeepRead:

  1. Finds where each document starts and ends.
  2. Says which of your types it is.
  3. Extracts each document with the schema of its type.

It is one job, and everything a /v1/process job can do works on it under the same plan rules: the preview link, field locations, a searchable PDF, human review, incognito, retention, webhooks and idempotency. Only speed is not offered.

Plans. Split is on the Standard and Enterprise plans. A request from the Free plan is refused with 402, and the body names the plan that has it.

You get an id back at once. Poll it with the same GET /v1/jobs/{job_id} as any other job, or wait for the same webhook.

When to use it

  • The file holds several documents and you need each one on its own.
  • The documents are of different types, each with its own fields.
  • The file holds many documents of the same type back to back, such as twenty statements, one per account.

For a file that is one document, use POST /v1/process.

Try it without writing code in the Split playground.


POST /v1/split

Endpoint

POST https://api.deepread.tech/v1/split

Authentication

Include your API key in the X-API-Key header:

X-API-Key: YOUR_API_KEY

Request

Headers

HeaderRequiredDescription
X-API-KeyYesYour API key
Content-TypeYesmultipart/form-data

Request Body (Multipart)

ParameterTypeRequiredDescription
filefileYesThe file holding the documents. Same file types and size limits as POST /v1/process
document_typesstringYesJSON array of the document types to look for. See document_types below
pipelinestringNoEngine: extract or deep-extract. If omitted, Free and Standard accounts run extract and other plans deep-extract. The older names fast and standard are still accepted
versionstringNoPipeline version for reproducibility (e.g., 1.0.0). If not specified, uses current default
webhook_urlstringNoURL that receives the result when the job completes or fails. Standard and Enterprise plans. Same rules as on /v1/process
previewstringNoSet true to get a shareable preview link: the pages of the file beside the documents found and their fields. Default: false. Same rules as on /v1/process
include_markersstringNoSet true to locate each extracted value on its page: location.bounding_box on every field. Default: false. Same rules as on /v1/process
searchable_pdfstringNoSet true to also produce a searchable PDF of the whole file. deep-extract only, Enterprise plans. Default: false
reviewer_emailstringNoHave people check the values in DeepRead's review screen: one email, or up to 10 separated by commas. Turns preview on; cannot be combined with incognito. See Human review
review_due_hoursstringNoWith reviewer_email: the review is due this many hours after submission (whole number, 1–8760). Default: no deadline
review_expiry_daysstringNoWith reviewer_email: an unfinished review closes this many days after submission (whole number, 1–365). Default: 30
incognitostringNoSet true to delete the file the moment the job finishes. Same rules as on /v1/process
retention_daysstringNoDelete the file and the results this many days after submission (integer, 1–365). Same rules as on /v1/process
idempotency_keystringNoA retry with the same key returns the job the first request created. The same key with a different file, options or document types is refused with 409

document_types

A JSON array of 1 to 50 document types. Each type has these fields:

FieldRequiredDescription
nameYes1 to 64 letters, digits, _ or -. Unique in the list, whatever the case. none, other and unassigned are reserved
descriptionYesWhat this type of document looks like. Up to 1,000 characters. A clear description gives a better split
split_byNoWhat tells one document of this type from the next. Up to 200 characters. See How split_by works
schemaNoJSON Schema for the fields to extract from each document of this type. Same rules and limits as schema on /v1/process. It must list at least one field under properties
blueprint_idNoA blueprint to extract with, instead of schema. Never both. Needs a plan with blueprints

A type with no schema and no blueprint_id is split out but not extracted. Read its text from the pages it lists.

Example Request

cURL Example
curl -X POST https://api.deepread.tech/v1/split \
-H "X-API-Key: $DEEPREAD_API_KEY" \
-F "file=@mail-batch.pdf" \
-F "pipeline=extract" \
-F "preview=true" \
-F "include_markers=true" \
-F 'document_types=[
{
"name": "invoice",
"description": "A supplier invoice with line items and a total",
"split_by": "invoice number",
"schema": {
"type": "object",
"properties": {
"invoice_number": {"type": "string", "description": "The invoice number"},
"total": {"type": "number", "description": "Total amount due"}
}
}
},
{"name": "remittance", "description": "A remittance advice or payment slip"}
]' \
-F "webhook_url=https://your-app.com/webhooks/deepread"

Response

Success Response (200 OK)

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "status": "queued"
}

Poll GET /v1/jobs/{job_id} with this id, or wait for your webhook. Both are the same as for /v1/process.

cURL Example
curl -X GET https://api.deepread.tech/v1/jobs/550e8400-e29b-41d4-a716-446655440000 \
-H "X-API-Key: $DEEPREAD_API_KEY"

Result

GET /v1/jobs/{job_id} and the webhook return the usual job response, with a split object. There is no top-level extraction. The text of every page is in pages[].

This example was sent with preview=true and include_markers=true: the preview link is in artifacts.preview_url, and each field's location has a bounding_box (0 to 1, from the top left of the page). Without include_markers, location has the page only.

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "status": "completed",
  "schema_version": "dp02",
  "pipeline": "extract",
  "product": "extract",
  "split": {
    "documents": [
      {
        "index": 1,
        "type": "invoice",
        "pages": [1, 2],
        "confidence": "high",
        "split_key": "INV-1042",
        "needs_review": false,
        "extraction": {
          "fields": [
            {
              "key": "invoice_number",
              "value": "INV-1042",
              "needs_review": false,
              "location": {
                "page": 1,
                "bounding_box": { "x": 0.62, "y": 0.08, "width": 0.21, "height": 0.03 }
              }
            },
            {
              "key": "total",
              "value": 1280.5,
              "needs_review": false,
              "location": {
                "page": 2,
                "bounding_box": { "x": 0.71, "y": 0.83, "width": 0.12, "height": 0.03 }
              }
            }
          ]
        }
      },
      {
        "index": 2,
        "type": "remittance",
        "pages": [3],
        "confidence": "low",
        "needs_review": true
      },
      {
        "index": 3,
        "type": "invoice",
        "pages": [4, 5, 6, 7],
        "confidence": "high",
        "split_key": "INV-1043",
        "needs_review": true,
        "error": "Fields could not be extracted from this document."
      }
    ],
    "unassigned_pages": [8, 9]
  },
  "pages": [
    {
      "page_number": 1,
      "content": { "format": "markdown", "text": "# Invoice INV-1042 ..." }
    }
  ],
  "artifacts": { "preview_url": "https://preview.deepread.tech/Xy7kP2mQ9aBc" },
  "review": { "needs_review": true }
}

split fields

FieldTypeDescription
split.documentsarrayThe documents found, in the order they appear in the file
split.documents[].indexintegerPosition of the document in the file, from 1
split.documents[].typestringThe name of the type it matched
split.documents[].pagesarrayIts pages. Page numbers start at 1 and count from the first page of the file. Read their text in pages[]
split.documents[].confidencestringhigh or low. See Low confidence
split.documents[].split_keystringThe split_by value of this document. Absent when the type has no split_by or no value was found
split.documents[].needs_reviewbooleantrue when confidence is low, the document has an error, or one of its fields needs review
split.documents[].extraction.fields[]arrayThe fields of the type's schema, in the same shape as extraction.fields[] on any job. Absent for a type without a schema, and when the extraction failed
split.documents[].errorstringWhy this document's fields could not be extracted. Absent when it worked
split.unassigned_pagesarrayPages that matched none of your types

Preview, field locations and review

preview, include_markers, searchable_pdf, reviewer_email, incognito, retention_days, webhook_url and idempotency_key behave exactly as they do on /v1/process, under the same plan rules.

The preview shows each document as its own section, with its type, pages and fields. Click a field to see where it was found on the page. A reviewer corrects the values there, as on any job.

In the preview and in a reviewer's corrections, a document's field is named by its address, documents[<position>].data.<field>, where <position> counts from 0: documents[0].data.total, documents[2].data.line_items[0].amount.


How split_by works

Many files hold several documents of the same type back to back. split_by names the value that changes from one to the next. A new document starts each time that value changes. The value is returned as the document's split_key.

Example: one PDF holds five invoices, 12 pages in all. You send one type:

[
  {
    "name": "invoice",
    "description": "A supplier invoice with line items and a total",
    "split_by": "invoice number"
  }
]

The invoice number changes five times, so you get five documents:

indextypepagessplit_key
1invoice[1, 2]INV-1042
2invoice[3]INV-1043
3invoice[4, 5, 6]INV-1044
4invoice[7, 8, 9]INV-1045
5invoice[10, 11, 12]INV-1046

Without split_by, a new document starts where a new one visibly begins: a new first page, a new letterhead.

Two documents in a row can print the same value: two monthly statements of one account, split by "account number", or two copies of one invoice. They are still returned as two documents when the second one opens again like a first page. A document where that could not be settled has confidence "low".


Unassigned pages

Blank pages, separator sheets and anything that matches none of your types end up in split.unassigned_pages. A blank page between two pages of one document stays in that document's pages. Unassigned pages are still read: any text on them is in pages[].

If real documents land there, add a type for them or sharpen a description.


Low confidence and needs_review

A document's confidence is low when the split is not sure of its type, or of where it starts and ends. Have a person check it.

A document's needs_review is true when any of these holds:

  • Its confidence is low.
  • It has an error.
  • One of its fields has needs_review: true.

review.needs_review on the job is true when any document needs review.


A failed document

If the fields of one document cannot be extracted, that document has an error and no extraction. Its type and pages are still returned, and its needs_review is true. The other documents are not affected, and the job still completes.

If the fields of every document cannot be extracted, the job is failed and is not charged.


Pricing

The engine's price plus $5 per 1,000 pages. That is $20 per 1,000 pages with Extract and $40 per 1,000 pages with Deep Extract.

Every page of the file counts once, whether or not it ends up in a document.

A negotiated split fee, when your account has one, is shown in Billing.


Limits

  • 1 to 50 document types per request.
  • Each schema meets the same limits as on /v1/process.
  • The file meets the same page, size and file-type limits as on /v1/process.
  • Submissions per minute and pages in flight are counted as for /v1/process. See Rate Limits.
  • All document types together, with their schemas, are at most 1 MB.
  • speed is not offered on a split job. Page text is always returned, so per_page and include_pages are not needed. Use preview, not the older include_images.

Status Codes

CodeDescription
200Job created
400Invalid document_types (the message names the type and the field), another invalid parameter, or a file over your plan's pages per document
401Invalid or missing API key
402You are on the Free plan (split needs Standard or Enterprise), credits do not cover the job, or an option is not on the plan; the body names what is needed
403Split is not available yet
404A blueprint_id that does not exist
409The idempotency_key was used with a different file, options or document types
413The file is over the hard maximum (2,000 pages or 500 MB)
415The file type is not accepted on your plan
429A rate limit or quota; Retry-After says when to try again
503Split pricing is not configured; no job was created

speed, mode, schema and blueprint_id sent at the top level are refused with 400: schemas and blueprints go inside each document type, a split job has no mode, and fast mode is not offered.