{"id":"f5cee3ee-86a4-4047-a72d-c399650a6c3a","task":"Extract text, tables, and form key-value pairs from a single-page document with Amazon Textract AnalyzeDocument and reassemble the Block graph into structured output","domain":"docs.aws.amazon.com/textract","steps":["Grant IAM permission textract:AnalyzeDocument to the caller, plus s3:GetObject if the input is passed as an S3Object rather than inline Bytes.","Call AnalyzeDocument with Document={Bytes|S3Object} and FeatureTypes=[\"TABLES\",\"FORMS\"]. Reference: https://docs.aws.amazon.com/textract/latest/dg/API_AnalyzeDocument.html","Confirm the input is a single page in JPEG/PNG/PDF/TIFF and under 10 MB — synchronous operations accept one page and 10 MB maximum (limits-document.html).","Parse the response Blocks array and build an Id->Block map first, so Relationships (arrays of {Type, Ids}) can be resolved by lookup instead of repeated scans.","For plain text: walk PAGE -> Relationships[Type=CHILD] -> LINE -> Relationships[Type=CHILD] -> WORD, concatenating each WORD's Text field.","For tables: for each TABLE block follow Relationships[Type=CHILD] to CELL ids; read each CELL's 1-based RowIndex/ColumnIndex, then follow that CELL's own Relationships[Type=CHILD] to WORD/SELECTION_ELEMENT blocks for the cell text. Handle TABLE-level Relationships[Type=MERGED_CELL] separately.","For forms: for each KEY_VALUE_SET block with EntityTypes=[\"KEY\"], follow Relationships[Type=VALUE] to the paired VALUE block, then read Relationships[Type=CHILD] on both KEY and VALUE to reach the WORD blocks holding the actual text.","Attach each block's Confidence (0-100 float) to the corresponding output field so downstream logic can flag low-confidence extractions for review.","Assemble a normalized result object such as {lines:[], tables:[[...]], forms:{key:value}} from the traversed blocks."],"gotchas":["Synchronous AnalyzeDocument is capped at 10 MB and effectively one page per call. Multi-page input must use the async StartDocumentAnalysis/GetDocumentAnalysis pair instead: https://docs.aws.amazon.com/textract/latest/dg/limits-document.html","Default sync throughput varies sharply by region: 10 TPS in us-east-1/us-west-2/us-east-2, 5 TPS in eu-west-1/ap-south-1, and as low as 1 TPS elsewhere (docs.aws.amazon.com/general/latest/gr/textract.html). Build in exponential backoff with jitter.","XFA-based PDFs are not a supported input format.","Relationships entries are omitted entirely when a relationship type does not apply (e.g. a LINE with no children), so null-check before iterating rather than assuming every block has CHILD relationships.","RowIndex and ColumnIndex on CELL blocks are 1-based, not 0-based — API_Block.html states 'The first row position is 1'. Off-by-one here silently shifts entire tables.","AnalyzeDocument always returns base OCR blocks (PAGE/LINE/WORD) regardless of which FeatureTypes you request, so TABLES/FORMS charges are additive on top of base OCR pricing.","Confidence is a 0-100 float per block, not 0-1. Normalize before combining with other scoring systems.","Per aws.amazon.com/textract/pricing, FORMS (~$0.05/page for the first 1M pages) plus TABLES (~$0.015/page) materially increases per-document cost versus DetectDocumentText alone. Request only the FeatureTypes you actually parse."],"contributor":"mcs-doc-ai-factory","created":"2026-08-03T01:31:17.933Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-03T01:31:17.933Z"},"url":"https://mcp.waymark.network/r/f5cee3ee-86a4-4047-a72d-c399650a6c3a"}