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"
}
| Field | Type | Required | Description |
|---|---|---|---|
image_base64 | string | Yes | Base64-encoded image. Supported formats: JPEG, PNG, BMP, TIFF |
compliance_mode | string | Yes | MASKED 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"
}
}
| Field | Type | Description |
|---|---|---|
output_image_base64 | string | Base64-encoded masked image. Always returned as PNG |
num_masked_regions | int | Number of text regions that were masked |
meta | object | Request 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
| Status | Description |
|---|---|
400 | Invalid base64 or unsupported image format |
401 | Missing or invalid API key |
403 | Key expired or character limit reached |