Get Masking Report
Get the PII masking report for a job that ran with mask_pii: true. Returns a signed download link (valid for up to 300 seconds) and an entity count for each report object; the masked values themselves are only in the downloaded objects. Reports are kept for 90 days after the job ran, then expire automatically (410). Requires a key with the index permission.
Path parameters
ID of the job whose masking report to act on, as returned by the indexing endpoint that started it.
Response
Successful Response
Always retained on a 200.
Entities across all files.
Lifetime of every url in the response (up to 300).
falsetrue while the job is still running or reported failed files, so objects may still be missing.
falsetrue when only the first 500 of the job’s report objects are listed.
The engine the request selected: jev or presidio. For jobs that used the earlier names: captain-presidio when every file was masked by Presidio, captain-jev otherwise. Null for jobs that predate engine reporting.
jevpresidiocaptain-jevcaptain-presidioTrue when at least one file in the job was masked by a fallback engine. Null for jobs that predate fallback reporting.
Errors
import requests
import json
BASE_URL = "https://api.captain.dev"
API_KEY = "your_api_key"
JOB_ID = "job_01HZP5G8N3"
headers = {
"Authorization": f"Bearer {API_KEY}",
}
response = requests.get(
f"{BASE_URL}/v2/jobs/{JOB_ID}/pii",
headers=headers,
timeout=30.0
)
if response.status_code == 200:
data = response.json()
print(f"{data['entity_count']} masked entities across {len(data['files'])} file(s)")
for f in data["files"]:
for obj in f["objects"]:
report = requests.get(obj["url"], timeout=30.0).json()
print(f" {f['file_id']}/{obj['key_suffix']}: {report['entity_count']} entities")
elif response.status_code == 410:
print(f"Report gone: {response.json()['code']}")
else:
print(f"Error: {response.status_code} {response.json().get('code')}"){
"job_id": "job_01HZP5G8N3",
"state": "retained",
"entity_count": 24,
"files": [
{
"file_id": "f05d93c3da314ab4fa24077afc08bd04",
"entity_count": 24,
"truncated": false,
"objects": [
{
"key_suffix": "doc.json",
"url": "https://captain-pii-reports.s3.us-east-1.amazonaws.com/org_01HZP4/job_01HZP5G8N3/f05d93c3da314ab4fa24077afc08bd04/doc.json?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Expires=300&X-Amz-Signature=3b9f0c2a1e",
"expires_at": "2025-01-20T08:25:00Z"
}
]
}
],
"expires_in_seconds": 300,
"incomplete": false,
"truncated_objects": false
}