DaletGuard supports civilians affected by armed conflict through Families Beyond War. All sides, no political affiliation. About our humanitarian work

Document Extraction API and Command Line

A document extraction API earns trust when the command line, the REST API and the workspace call one analysis function. DaletParse works that way across its 24 routes under /api/v1, so the result in the browser matches the result that your own system receives. The analyze endpoint, the tenant token routes, the limits and the single error shape below give a new caller everything needed for a first call from a small script or a service, behind the gateway and authentication your platform team already runs.

Illustration of plug, puzzle, code for document extraction api
Key takeaway

The command line, the REST API and the web workspace all call one analysis function, so every entry point returns the same type, outcome and flags.

Why one analysis core behind the API matters to every team

Many teams build intake in layers. First, a web app comes for the reviewers. The document extraction API arrives last, and by then it behaves a little differently from both.

Indeed, that drift causes real trouble. For example, the command line reports a flag that the API never shows. A batch route may skip a check that the web path runs. As a result, a test passes on one entry point and fails on another.

A document extraction API that wraps the same function as the workspace avoids these gaps. Therefore, your tests cover one behavior, not three. Overall, the answer that your analyst sees is the answer that your system gets.

A diagram with the topic at the centre and four connected parts: Analyze endpoint, OpenAPI document, REST.

How a single core serves each document extraction API call

DaletParse exposes one core action to every caller. It analyzes a document, then returns a qualified type and an outcome. An asynchronous version runs the work, and a synchronous wrapper serves callers that cannot wait on an event loop. Notably, the command line and the analyze endpoint call that action directly.

The web workspace also reaches it through its job runner. Specifically, the stages behind the call are described on the pipeline overview. The review workspace shows the same results in a browser.

Hub diagram of the web workspace, REST API and command line around one core
The workspace, the API and the command line share one analysis core.
DaletParse analyze route call screen

What the document extraction API gives each kind of caller

The document extraction API has three entry points. Each one reaches the same core, and each suits a different job. First, the command line suits local checks. Meanwhile, the analyze endpoint suits classification before any human step.

Tenant token routes suit systems that need extracted data back. However, they all share one analysis function, so the verdicts agree.

The command line is a thin wrapper over the core. First, you run the analyze command with a file path. In addition, a JSON flag prints the machine-readable result, and an output directory flag keeps the run files. A typical call runs the analyze command on one PDF with the JSON flag.

The process also exits with code 1 when the run fails. Use it for scripts and for single files before you wire a document extraction API integration. However, it needs the same model and OCR services as the server.

The analyze endpoint answers with a verdict for each document. A call takes one file in a multipart field named file. First, the request blocks while the whole pipeline runs. Long packs mean long requests, so set a generous client timeout.

The answer holds a success flag, a document count, the page total and an errors list. Each document entry holds the type, the type confidence, the outcome, the rejections, the flags, the pages and a status. The list is capped at 100 documents. Notably, the answer carries no file paths and no extracted values.

How a call proves who it is on a tenant route

Tenant token routes check two values per call. The first is a bearer token, and the second is a tenant identifier header.

Also, the tenant must be a canonical, non-nil UUID. Likewise, tokens must be 32 to 512 printable ASCII bytes. Tokens are compared in constant time. A service with no token registry answers 503.

For example, the statement route returns 202 and a run identifier. Next, you poll the status route with that identifier until the job ends. A multi-file variant takes up to 20 files in one call. The bank statement page explains what the job produces.

Illustration for Document Extraction API and Command Line

How a new client finds each document extraction API route

Two public routes serve new clients. First, the health route reports the service state. The types route lists the registered types, which number 80, of which 73 have specialist extractors.

One route serves the OpenAPI document, and another serves a Swagger page. In fact, the service has 24 routes under one version prefix in total. Generate your client from the OpenAPI document. Then check the OpenAPI document again after each upgrade.

Choosing a route in the document extraction API by need

Most integrations touch the routes listed here, each with its access rule and what comes back from the document extraction API.

  • The analyze route, POST /api/v1/analyze, sits behind your gateway, and it returns type, outcome, flags and pages.
  • The types route returns the list of registered types.
  • The statement route needs a tenant token, and it returns a run identifier to poll.
  • The multi-file statement route takes up to 20 files and returns one run identifier.
  • The jobs routes need a tenant token, and they return results for up to 100 identifiers.
  • The accounting evidence route needs a tenant token, and it returns a closed fact schema.

First, pick the analyze route to learn what a pack contains and how it was judged. Second, pick the tenant token routes when your system needs extracted data. Therefore, job results are filtered by owner, so one tenant cannot read the runs of another.

Example calls that show each step of a first integration

The calls show a host, a token and a tenant in angle brackets for you to fill in. However, never paste real secrets into scripts that you commit.

  1. Check the service state by sending a plain GET request to the health route.
  2. List the types with a GET request to the types route, to see the registry that your build knows.
  3. Analyze a pack by posting one file in the field named file, then wait for the verdict.
  4. Submit a statement job by adding a bearer header and a tenant header to the bank statement route.
  5. Poll the run by repeating the status call with the returned run identifier until the job ends.

For step 4, read the OpenAPI document for the exact form field name, since that name belongs to the contract. Also, a call with the wrong tenant header gets an error in the standard shape.

DaletParse Workflow: OpenAPI document screen

Timeouts and long requests need a worker on your own side

The analyze endpoint runs the whole pipeline inline. For example, a single-page paystub is a short job. A scanned loan pack with many pages is a long one, and the code promises no timing. Therefore, set your client timeout from an implementation run, not from a guess.

Also, put the call in a background worker so that a slow pack never blocks a user. On tenant token routes, polling spreads the wait over many short calls instead. In addition, each poll is cheap, and your system decides how often to ask.

Limits and errors that every client has to handle well

The service accepts PDF, JPEG, PNG, TIFF and WEBP files. However, an upload above 50 MiB gets a 413 answer. File names are cleaned first, and they must stay within 255 bytes. An empty file is refused.

Every error is returned in one shape, which holds an error, a detail and a code. Therefore, your client can parse that shape once and handle all failures the same way. Also, responses do not carry server paths, owner digests or raw exceptions.

Moreover, run retention differs by route. The analyze endpoint deletes its working run directory before it returns.

Tenant runs are removed after a window. It defaults to 168 hours and can be set between 1 and 720. The security controls page gives the wider picture.

Retired routes answer 404 and the spec file omits them

Older routes were retired from the document extraction API. They exposed raw extraction, full extraction, batch, coherence and speculative configuration. These now answer 404, and they are left out of the OpenAPI document. The remaining routes also carry tenant checks and filtered responses.

Therefore, do not build on a path from an old note. However, some workflows behind the retired routes remain available through the command line and the library. Name the workflow you need during an implementation. Then ask which entry point serves it today.

The accounting evidence route returns a closed schema. It accepts at most 20 documents and 1,000 lines, and the response stays within 8 MiB. Moreover, it never invents missing values, zero amounts or a paid state.

A separate payment-card route exists in the code. It reads one card image in memory and returns a masked receipt.

DaletParse Workflow: Command line screen

An example of a platform team that routes uploads by type

A platform team wants to sort uploads early, with every file typed before any human sees it, and builds the flow on the document extraction API.

First, the team places a gateway in front of the service and adds its own authentication. Second, a small worker posts each upload to the analyze endpoint. Then it reads the document type and the outcome, and it files the upload under a queue.

Next, bank statements go to a second step in the document extraction API flow. The worker calls a tenant token route with its token, polls the run, and stores the returned records. Reviewers are sent to the workspace for the exceptions that the worker cannot settle.

How to secure the document extraction API before real use

Every deployment runs behind the controls your platform team sets, and the document extraction API fits an internal service model from day one.

  • Put the analyze endpoint behind the gateway that authenticates every document extraction API caller.
  • Generate long random tokens for tenant token routes, and store them in a secret manager.
  • Set your own Flask secret key and meeting credentials for each deployment.
  • Place the run directory on encrypted storage, and limit who reads it.
  • Choose where inference runs, because the model wrapper calls only the endpoints you configure.

Meanwhile, callers poll the status routes, and results leave as JSON, CSV and ZIP that any ERP, RPA or workflow tool can read. The integrations page maps the connected services, and an implementation plan sets each control in place.

What engineers gain when they automate intake on one core

One analysis core changes how engineers build intake.

  • One outcome everywhere: the CLI, the document extraction API and the workspace return the same outcome.
  • Fast triage: the analyze endpoint classifies a pack without returning extracted values.
  • Rich data on demand: tenant token routes return full records under bearer tokens and tenant checks.
  • Generated clients: the OpenAPI document lets you generate each API client.
  • Clean surface: retired routes answer 404 instead of lingering as hidden paths.
  • One error shape: every failure your client handles has the same structure.

Callers that must choose between routes can read the intake route choice page first. It compares the command line, the API and the web workspace.

Test the document extraction API with your own real files

A handful of real files and a small client suffice. A fair comparison of a document extraction API uses your own documents. First, send a clean PDF, a poor scan, a long mixed pack and a file that you expect to fail. Compare each answer with what the classification stage should find.

Ask for a meeting, and bring the document extraction API question that matters most to your engineers.

Questions and answers on this topic from the product team

How is the analyze endpoint secured?

It sits behind the gateway that authenticates every caller. The bank statement, job and accounting routes also check a bearer token and a tenant identifier.

What does the analyze endpoint return?

It returns a success flag, a document count, the total pages, an errors list and one entry per document. Each entry holds the document type, its confidence, the outcome, rejections, flags, pages and status, and the working run directory is deleted before the answer goes out.

Can I submit many files in one call?

Yes. The multi-file bank-statement route accepts up to 20 files in one call and returns run identifiers, and the analyze endpoint takes a single file in the form field named file.

Which routes were retired from the API?

Raw extraction, full extraction, batch, coherence and speculative configuration routes were retired. They answer 404 and no longer appear in the OpenAPI document. Some workflows remain available through the command line and the library.

How does a caller learn that a job has ended?

Bank statement jobs return a run identifier, and your system polls the status route until the job ends. The analyze route answers in the same call.

What file types and sizes are accepted?

The service accepts PDF, JPEG, PNG, TIFF and WEBP files, up to 50 MiB per upload. A larger upload gets a 413 answer. Error responses use one shape with an error, a detail and a code.

See how DaletParse fits the providers your team uses today

Book a short meeting for a walkthrough with your own providers in mind, or join an in-person class to learn the method first.