Skip to main content

POST /api/v1/deidentify/image

:::warning Pending public release Image de-identification is not yet publicly available. This endpoint will be accessible in a future update. :::

De-identifies text in an image using OCR-based detection. Detected text regions are covered with filled rectangles. Returns a masked PNG.


Request

POST /api/v1/deidentify/image
X-API-Key: cai_your_key_here
Content-Type: application/json

Body

{
"image_base64": "<base64-encoded image>",
"compliance_mode": "MASKED"
}
FieldTypeRequiredDescription
image_base64stringYesBase64-encoded image. Supported formats: JPEG, PNG, BMP, TIFF
compliance_modestringYesMASKED or PROPRIETARY. Other values return the image unchanged

Response 200 OK

{
"output_image_base64": "<base64-encoded PNG>",
"num_masked_regions": 3,
"meta": {
"compliance_mode": "MASKED"
}
}
FieldTypeDescription
output_image_base64stringBase64-encoded masked image. Always returned as PNG
num_masked_regionsintNumber of text regions that were masked
metaobjectRequest metadata

Example

import base64, requests

with open("scanned-form.png", "rb") as f:
image_b64 = base64.b64encode(f.read()).decode()

response = requests.post(
"https://api.custodianai.com/api/v1/deidentify/image",
headers={
"X-API-Key": "cai_your_key_here",
"Content-Type": "application/json",
},
json={
"image_base64": image_b64,
"compliance_mode": "MASKED",
},
).json()

output_bytes = base64.b64decode(response["output_image_base64"])
with open("masked-form.png", "wb") as out:
out.write(output_bytes)

print(f"{response['num_masked_regions']} region(s) masked")

Error responses

StatusDescription
400Invalid base64 or unsupported image format
401Missing or invalid API key
403Key expired or character limit reached