DOCX Extraction
Agent Mask extracts text from DOCX files, detects configured entities, and
returns de-identified extracted text from a single mask() call. DOCX support
is text extraction and de-identification, not Word file redaction: DOCX inputs
do not return an edited or redacted .docx binary.
Use DOCX extraction when you need de-identified text from Word documents for analytics, QA, review, search, or downstream AI workflows and do not need to preserve the original Word layout.
Input requirements
Section titled “Input requirements”DOCX bytes must be base64-encoded and zlib-compressed before passing them to
mask().
Quick example
Section titled “Quick example”SELECT app_public.mask( '<compressed_base64_docx>', OBJECT_CONSTRUCT( 'document_extraction_mode', 'simple' ));The response includes:
columns[0].deidentified_text- de-identified extracted text.columns[0].original_text- extracted source text before replacement.columns[0].document_metadata.file_type-docx.
original_text can contain sensitive source values. Use
include_analyzer_results=false and include_entity_ledger=false when you only
need the de-identified text output and want to reduce response detail.
Structured vs simple extraction
Section titled “Structured vs simple extraction”Use simple extraction for fast flat text output. Use structured extraction when tables, headings, and list structure matter in the returned text:
OBJECT_CONSTRUCT( 'document_extraction_mode', 'structured', 'structured_output_format', 'markdown')"simple"— flat text, fastest, default."structured"— exports de-identified structured text as markdown, HTML, plain text, or JSON.
structured_output_format options are "markdown" (default), "html",
"text", and "json".
What gets de-identified
Section titled “What gets de-identified”Detected entities in the extracted DOCX text are replaced with the value
selected by your operator configuration, such as [PERSON_1], [REDACTED], a
hash, an encrypted value, or a faker value. The same language, entity, custom
entity, and operator settings used for plain text apply to DOCX extraction.
Values that are not detected remain in the extracted output. Values handled with
the keep operator also remain visible because keep reports detections
without changing the text.
Operator caveats
Section titled “Operator caveats”fakerandencryptproduce variable-length replacements that may alter line lengths.type_numberedproduces consistent placeholders across all occurrences.entity_typeremoves per-entity identity labels, but readers may still be able to count visible replacement occurrences.
Limitations and review
Section titled “Limitations and review”DOCX extraction returns text, not a replacement Word document. Fonts, images,
comments, tracked changes, headers, footers, exact pagination, and other Word
layout details are not preserved as a redacted .docx file.
Extraction quality depends on the document structure, embedded content, language, and configured entities. Review representative outputs before external sharing, regulated disclosure, or public release.