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 SSNs, MRNs, phone numbers, and dates of birth.
- spaCy NER Model — A fine-tuned Named Entity Recognition model trained on clinical corpora to identify patient names, physician names, and locations.
Detected entities are replaced with deterministic tokens (e.g., "Patient Forgive" → [ID_001]). 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 system reference for FHIR R4 compliance audit linking. |
Response
Response fields
| Name | Type | Required | Description |
|---|---|---|---|
tokenized_text | string | Required | Input text with PHI replaced by deterministic tokens. |
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 | 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 Forgive presents with a fever of 39.2°C.",
"fhir_context": "Patient/p-28491"
}'Response · 200 OK
{
"status": "success",
"scrubbed_text": "Patient [ID_001] presents with a fever of 39.2°C.",
"entities_found": 1,
"processing_time_ms": 6.2,
"token_map_id": "tmap_a1b2c3d4-e5f6-7890"
}