Skip to main content

POST /api/v1/deidentify/text/proprietary/outputs/csv

De-identifies every cell in a CSV file using Guardian Layer. Returns a de-identified CSV with the same structure as the input.


Request

POST /api/v1/deidentify/text/proprietary/outputs/csv
X-API-Key: cai_your_key_here
Content-Type: multipart/form-data

Form fields

FieldTypeRequiredDefaultDescription
filefileYesA .csv file
domainstringNoGeneralGeneral, Medical, Finance, or Custom
masking_typestringNotransformredact or transform
pii_entitiesstringNoallComma-separated entity types, e.g. "PERSON,EMAIL_ADDRESS". Leave empty for all

Response

Returns text/csv. The filename is prefixed with deid_.

HeaderValue
Content-Typetext/csv
Content-Dispositionattachment; filename="deid_<original-filename>.csv"

Example

import requests

with open("employees.csv", "rb") as f:
response = requests.post(
"https://api.custodianai.com/api/v1/deidentify/text/proprietary/outputs/csv",
headers={"X-API-Key": "cai_your_key_here"},
files={"file": ("employees.csv", f, "text/csv")},
data={
"domain": "General",
"masking_type": "redact",
"pii_entities": "PERSON,EMAIL_ADDRESS,PHONE_NUMBER",
},
)

with open("deid_employees.csv", "wb") as out:
out.write(response.content)

Error responses

StatusDescription
400File is not a .csv or is invalid
401Missing or invalid API key
403Key expired or character limit reached