POST
/v1/inbound/tokenizeInbound Tokenization
Scrub and tokenize Protected Health Information from clinical text before it reaches any cloud LLM.
<10ms latency
Description
This endpoint uses a two-stage pipeline to detect and replace PHI entities:
- Local Regex Patterns: high-speed pattern matching for Zimbabwe national IDs, MRNs, phone numbers, addresses, dates of birth, email addresses and card numbers.
- spaCy NER Model: spaCy's general English Named Entity Recognition model (en_core_web_lg), run through Microsoft Presidio, to identify patient and physician names.
Detected entities are replaced with deterministic tokens (e.g., "Tendai Moyo" becomes <PERSON_1>). Tokens are reversible only by the originating EnorAI instance.
Important
Tokenization runs locally. No raw PHI is transmitted to EnorAI cloud services.
Request body
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
input_text | string | Required | The raw clinical text containing PHI to be scrubbed and tokenized. |
fhir_context | string | Optional | Optional EHR reference (e.g. a FHIR R4 Patient ID). Accepted for future audit linking; not used yet. |
Response
Response fields
| Name | Type | Required | Description |
|---|---|---|---|
status | string | Required | "success" when the text was scrubbed. |
scrubbed_text | string | Required | Input text with PHI replaced by reversible tokens such as <PERSON_1>. |
entities_found | integer | Required | Number of PHI entities detected and tokenized. |
processing_time_ms | number | Required | Processing time in milliseconds. |
token_map_id | string | Required | ID of the stored token map (kept 24 hours) used by /v1/inbound/detokenize. |
token_map_id | string | Required | UUID reference to stored token map for de-tokenization. |
Request
curl -X POST \
https://api.enorai.com/v1/inbound/tokenize \
-H "Authorization: Bearer $ENORAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input_text": "Patient Tendai Moyo, ID 63-123456A73, phone 0772 123 456, presents with a persistent fever of 39.2°C.",
"fhir_context": "Patient/p-28491"
}'Response · 200 OK
{
"status": "success",
"scrubbed_text": "Patient <PERSON_1>, ID <NATIONAL_ID_1>, phone <PHONE_1>, presents with a persistent fever of 39.2°C.",
"entities_found": 3,
"processing_time_ms": 6.2,
"token_map_id": "tmap_a1b2c3d4-e5f6-7890"
}