POST /api/v1/deidentify/text/proprietary/outputs/docx
De-identifies text content in a DOCX file using Guardian Layer. Text is replaced in-place within the document XML. Formatting, fonts, tables, and document structure are preserved. Returns a de-identified DOCX.
Request
POST /api/v1/deidentify/text/proprietary/outputs/docx
X-API-Key: cai_your_key_here
Content-Type: multipart/form-data
Form fields
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
file | file | Yes | — | A .docx file |
domain | string | No | General | General, Medical, Finance, or Custom |
masking_type | string | No | transform | redact or transform |
pii_entities | string | No | all | Comma-separated entity types. Leave empty for all |
Response
Returns application/vnd.openxmlformats-officedocument.wordprocessingml.document. The filename is prefixed with deid_.
Example
import requests
with open("report.docx", "rb") as f:
response = requests.post(
"https://api.custodianai.com/api/v1/deidentify/text/proprietary/outputs/docx",
headers={"X-API-Key": "cai_your_key_here"},
files={
"file": (
"report.docx",
f,
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
)
},
data={"domain": "General", "masking_type": "redact"},
)
with open("deid_report.docx", "wb") as out:
out.write(response.content)
Error responses
| Status | Description |
|---|---|
400 | File is not a .docx or is malformed |
401 | Missing or invalid API key |
403 | Key expired or character limit reached |