Read a box drawn on a sample page
const url = 'http://localhost:8080/v1/extraction-templates/read-region';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"sampleId":"example","pageNo":1,"box":{"x":1,"y":1,"w":1,"h":1},"field":"example","docType":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url http://localhost:8080/v1/extraction-templates/read-region \ --header 'Content-Type: application/json' \ --data '{ "sampleId": "example", "pageNo": 1, "box": { "x": 1, "y": 1, "w": 1, "h": 1 }, "field": "example", "docType": "example" }'Takes sampleId, pageNo and box (page fractions x, y, w, h, origin top-left) and returns what the engine reads inside it, the tight box of those words and the label it proposes as the anchor. With field (a canonical field name) it also returns the region rule the box becomes and the value that rule extracts from the sample, proved with nothing else in play (docType scopes the proof; default other). 400 for a box off the page or an unknown field; 404 for an unknown sample. Administrators only.
Request Bodyrequired
Section titled “Request Bodyrequired”Body of POST /v1/extraction-templates/read-region: a box drawn on a page of an uploaded sample, and optionally the field it names.
object
The canonical field the box is for; when null the box is only read (for a title, say).
The document type the rule will belong to, for the proof extraction; defaults to other.
Examplegenerated
{ "sampleId": "example", "pageNo": 1, "box": { "x": 1, "y": 1, "w": 1, "h": 1 }, "field": "example", "docType": "example"}Responses
Section titled “Responses”OK
What a drawn box reads, the region rule it becomes, and the value that rule extracts from the sample.
object
What a drawn region contains: the text inside it in reading order, the tight box of those words, the anchor the engine proposes (null when nothing label-like sits beside or above it), and whether the page was recognised by OCR.
object
Page-relative box: fractions of page width/height, origin top-left, so it survives any render scale.
object
A label the engine can find again near a region; its printed text and where it sat on the sample (page fractions); so the region follows the label when a scan is offset or a form re-flows.
object
Page-relative box: fractions of page width/height, origin top-left, so it survives any render scale.
object
One declarative extraction rule; the serialised form of the engine’s rule types. string TemplateRuleSpec.Type is one of
TemplateRuleTypes; string? TemplateRuleSpec.Pattern/string? TemplateRuleSpec.ValuePattern are.NET regexes and a
sentence pattern must capture the value as (?<v>…). A region rule; the studio’s
point-and-name mapping; carries the int? TemplateRuleSpec.Page and BoundingBox? TemplateRuleSpec.Box that was drawn (page fractions,
origin top-left) and the RegionAnchor? TemplateRuleSpec.Anchor label the engine follows when the page shifts.
object
A label the engine can find again near a region; its printed text and where it sat on the sample (page fractions); so the region follows the label when a scan is offset or a form re-flows.
object
Page-relative box: fractions of page width/height, origin top-left, so it survives any render scale.
object
object
Example
{ "rule": { "requireBold": true }}