Redacting with Regex
Redaction applies one or more rules to a processed document with a POST /pdf/documents/{id}/redact call. Each rule is a regular expression (regex) plus an optional validator. Matching text is removed from the document's text layer, the OCR output and the metadata; the corresponding area of the page image is painted black at the pixel level as well.
Redacted text is not covered with a box, it is removed from the document. Nothing is left under the black area that could be copied, searched or brought back with a PDF editor. Incapon does not keep a copy of the redacted text either.
Preset Rules
There are preset rules for common kinds of personal data; naming one in the preset field is enough. The validator runs a regex match through an extra check to cut down false positives.
| Preset | Regex | Validator |
|---|---|---|
| tckn | \b[1-9]\d{10}\b | Checksum of the 10th and 11th digits |
| iban_tr | TR\d{2}(?:\s?\d{4}){5}\s?\d{2} | ISO 13616 mod-97 check |
| phone_tr | (?:\+90)?\s?0?5\d{2}\s?\d{3}\s?\d{2}\s?\d{2} | None |
| [\w.%+-]+@[\w.-]+\.[A-Za-z]{2,} | None |
Thanks to the checksum, the tckn rule does not mistake random 11-digit order or invoice numbers for ID numbers and redact them.
Redaction Request
{
"rules": [
{ "preset": "tckn" },
{ "preset": "iban_tr" },
{ "preset": "phone_tr" },
{ "preset": "email" },
{
"name": "registry_no",
"pattern": "SCL-\\d{6}",
"flags": "i"
}
],
"dry_run": false
}curl -X POST https://api.incapon.com/v2.4/pdf/documents/doc_4b7e/redact \
-H "Authorization: Bearer $INCAPON_API_KEY" \
-H 'Content-Type: application/json' \
-d '{"rules": [{"preset": "tckn"}, {"preset": "iban_tr"}], "dry_run": true}'Do a Dry Run First
A request sent with dry_run: true changes nothing; for each rule it returns the match count, the page numbers and a masked preview (TR33 **** **** ... 26). Dry runs are free.
Apply the Redaction
If the results look right, send the same rules with dry_run: false. When the job finishes, the document.redacted event is sent with an audit record holding the match count per rule. The charge is $0.005 per page redaction is applied to.
Export the Result
Download the redacted document in one of the formats on the Output Formats page. The audit record can be kept as the answer to the KVKK question "which data was deleted and when"; it does not contain the deleted values themselves.