API Reference

PII Removal

API reference for the PII removal endpoints

PII Removal

Detect and redact PII from documents using AI-powered analysis.

Enterprise plans. A request from another plan is refused with 402 naming the plan that has it — the same body as every plan-gated feature (documented under the status codes in the OCR reference).


POST /v1/pii/redact

Upload a document for PII detection and redaction.

Endpoint

POST https://api.deepread.tech/v1/pii/redact

Authentication

Include your API key in the X-API-Key header:

X-API-Key: YOUR_API_KEY

Request

Headers

HeaderRequiredDescription
X-API-KeyYesYour API key
Content-TypeYesmultipart/form-data

Request Body (Multipart)

ParameterTypeRequiredDefaultDescription
filefileYes-Document to redact (PDF, PNG, JPEG, or TXT)
redaction_stylestringNoblack_barRedaction style: black_bar
webhook_urlstringNo-HTTPS URL to receive job completion notifications
languagestringNoenDocument language: en, zh, es, hi, ar

Example Request

cURL Example
curl -X POST https://api.deepread.tech/v1/pii/redact \
-H "X-API-Key: $DEEPREAD_API_KEY" \
-F "file=@contract.pdf" \
-F "redaction_style=black_bar" \
-F "language=en" \
-F "webhook_url=https://your-app.com/webhooks/pii"

Response

Success Response (200 OK)

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "status": "queued"
}

Response Fields

FieldTypeDescription
idstringUnique job identifier (UUID)
statusstringInitial job status (queued)

Status Codes

CodeDescription
200Job created successfully
400Invalid input (unsupported file type, a file whose content does not match its declared type, invalid parameters)
401Invalid or missing API key
402PII redaction is not on the plan, or the credits do not cover the job; the body names what is needed
413File over the size limit or the 500 MB hard maximum
429Submissions per minute or pages in flight exceeded; Retry-After says when to try again
500Internal server error
503The API key could not be checked because our database did not answer; retry after Retry-After (5 s). A bad key is 401

GET /v1/pii/{job_id}

Retrieve the status and results of a PII redaction job.

Endpoint

GET https://api.deepread.tech/v1/pii/{job_id}

Authentication

X-API-Key: YOUR_API_KEY

Path Parameters

ParameterTypeDescription
job_idUUIDThe job ID returned from POST /v1/pii/redact

Example Request

cURL Example
curl https://api.deepread.tech/v1/pii/550e8400-e29b-41d4-a716-446655440000 \
-H "X-API-Key: $DEEPREAD_API_KEY"

Response

Success Response (200 OK)

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "status": "completed",
  "progress_percent": 100,
  "redacted_file_url": "https://storage.deepread.tech/redacted/abc123.pdf",
  "report": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "page_count": 3,
    "processing_time_ms": 4200,
    "total_redactions": 8,
    "redaction_policy": "black_bar",
    "confidence_threshold_used": 0.85,
    "pii_detected": {
      "EMAIL": {
        "count": 3,
        "pages": [1, 2],
        "confidence_avg": 0.97,
        "confidence_min": 0.91
      },
      "PHONE": {
        "count": 2,
        "pages": [1],
        "confidence_avg": 0.94,
        "confidence_min": 0.89
      },
      "SSN": {
        "count": 1,
        "pages": [2],
        "confidence_avg": 0.99,
        "confidence_min": 0.99
      },
      "NAME": {
        "count": 2,
        "pages": [1, 3],
        "confidence_avg": 0.91,
        "confidence_min": 0.86
      }
    }
  }
}

Response Fields

FieldTypeDescription
idstringJob identifier
statusstringqueued, processing, completed, or failed
progress_percentintegerProcessing progress (0-100)
redacted_file_urlstringSigned URL to download redacted document (when completed)
reportobjectDetection report (when completed)
errorobjectError details (when failed)

Report Fields

FieldTypeDescription
idstringJob identifier
page_countintegerNumber of pages processed
processing_time_msintegerProcessing time in milliseconds
total_redactionsintegerTotal number of PII instances redacted
redaction_policystringRedaction style used
confidence_threshold_usednumberConfidence threshold applied
pii_detectedobjectDetections grouped by PII type

PII Detection Summary (per type)

FieldTypeDescription
countintegerNumber of instances detected
pagesarrayPage numbers where detected
confidence_avgnumberAverage confidence score
confidence_minnumberMinimum confidence score

Status Codes

CodeDescription
200Job found
400Invalid job ID format
401Invalid or missing API key
404Job not found
429Polling limit for the plan (Free 20 a minute, Standard 60, Enterprise 150); Retry-After says when to try again

Webhooks

When you provide a webhook_url, DeepRead sends a POST request when the job completes:

{
  "job_id": "550e8400-e29b-41d4-a716-446655440000",
  "status": "completed",
  "redacted_file_url": "https://storage.deepread.tech/redacted/abc123.pdf",
  "report": {
    "page_count": 3,
    "total_redactions": 8,
    "pii_detected": { ... }
  }
}

For failed jobs:

{
  "job_id": "550e8400-e29b-41d4-a716-446655440000",
  "status": "failed",
  "error": {
    "code": "DOCUMENT_CORRUPTED",
    "message": "Unable to parse the uploaded document"
  }
}

Webhook URLs must use HTTPS. Private IP addresses, localhost, and loopback addresses are rejected.


PII Types

The following PII types may appear as keys in the pii_detected report object:

TypeDescription
NAMEPersonal names
EMAILEmail addresses
PHONEPhone numbers
SSNSocial Security Numbers, national IDs
CREDIT_CARDCredit/debit card numbers, payment references
ADDRESSPhysical addresses
DATE_OF_BIRTHDates of birth
PASSPORT_NUMBERPassport numbers
DRIVER_LICENSEDriver's license, vehicle registration numbers
BANK_ACCOUNTBank account numbers, routing numbers
IBANInternational Bank Account Numbers
IP_ADDRESSIP addresses (IPv4/IPv6)
URLWeb addresses
MEDICAL_RECORDMedical record numbers, patient IDs

Supported File Types

MIME TypeExtensionDescription
application/pdf.pdfPDF documents
image/png.pngPNG images
image/jpeg.jpg, .jpegJPEG images
text/plain.txtPlain text files

Rate Limits

Limits are per plan. Past a limit the request is refused with 429 and a Retry-After header saying when to try again.

PlanPOST /v1/pii/redact per minuteGET /v1/pii/{job_id} per minute
Free1020
Standard10060
Enterprise500150

A redaction job's pages count towards the account's pages in flight (16 on Free, 200 on Standard, 500 on Enterprise), shared with OCR and form-fill jobs. No document over 2,000 pages or 500 MB is accepted on any plan (413).

Response headers include:

  • X-RateLimit-Limit: Maximum requests per period
  • X-RateLimit-Remaining: Remaining requests
  • X-RateLimit-Reset: Unix timestamp when limit resets

Error Codes

CodeDescription
INVALID_REQUESTMissing or invalid parameters
UNSUPPORTED_FORMATFile type not supported
DOCUMENT_CORRUPTEDUnable to parse the document
PASSWORD_PROTECTEDDocument is password protected
EMPTY_DOCUMENTUploaded file is empty
FILE_TOO_LARGEFile exceeds size limit
UNAUTHORIZEDInvalid or missing API key
RATE_LIMITEDToo many requests
INTERNAL_ERRORServer error