Skip to content

Text Anonymization

Synchronous endpoint for anonymizing plain text.

Endpoint

POST /anonymize/text

Try it live (desktop). The API Playground docked on the right is already set to this endpoint — enter your API key once and hit Send. Collapse it with the arrow; reopen it from the Playground tab on the edge.

Request

Headers

HeaderValue
Content-Typeapplication/json
AuthorizationBearer <token> (hosted demo only)

Body

json
{
  "text": "My name is John Doe and my email is john@example.com. The building is nearby.",
  "entities": "PERSON_NAME,EMAIL_ADDRESS",
  "start_index": 0,
  "custom_entities": [
    {"original": "building", "placeholder": "SECRET"}
  ]
}

Parameters

FieldTypeRequiredDefaultDescription
textstringYesText content to anonymize
entitiesstringNoallComma-separated entity type names
start_indexintNo0Starting index for placeholder numbering
custom_entitiesarrayNo[]Custom entity definitions

Response

200 OK

json
{
  "anonymized_text": "My name is [PERSON_NAME_1] and my email is [EMAIL_ADDRESS_2]. The [SECRET_3] is nearby.",
  "map": {
    "John Doe": "[PERSON_NAME_1]",
    "john@example.com": "[EMAIL_ADDRESS_2]",
    "building": "[SECRET_3]"
  },
  "entities": 3
}

Response Fields

FieldTypeDescription
anonymized_textstringText with entities replaced by placeholders
mapobjectOriginal value to placeholder mapping
entitiesintTotal count of entities detected and replaced

Examples

Default (All Entities)

json
{
  "text": "Contact Sarah at sarah@company.com or call +1-555-1234."
}

Response:

json
{
  "anonymized_text": "Contact [PERSON_NAME_1] at [EMAIL_ADDRESS_2] or call [PHONE_NUMBER_3].",
  "map": {
    "Sarah": "[PERSON_NAME_1]",
    "sarah@company.com": "[EMAIL_ADDRESS_2]",
    "+1-555-1234": "[PHONE_NUMBER_3]"
  },
  "entities": 3
}

Entity Filtering

json
{
  "text": "John lives in New York and works at Google.",
  "entities": "ORGANIZATION"
}

Response:

json
{
  "anonymized_text": "John lives in New York and works at [ORGANIZATION_1].",
  "map": {
    "Google": "[ORGANIZATION_1]"
  },
  "entities": 1
}

Custom Start Index

json
{
  "text": "Email Jane at jane@co.com.",
  "start_index": 10
}

Response:

json
{
  "anonymized_text": "Email [PERSON_NAME_11] at [EMAIL_ADDRESS_12].",
  "map": {
    "Jane": "[PERSON_NAME_11]",
    "jane@co.com": "[EMAIL_ADDRESS_12]"
  },
  "entities": 2
}

Custom Entities Only

json
{
  "text": "The launch of Operation Skyfall is June 1st.",
  "custom_entities": [
    {"original": "Operation Skyfall", "placeholder": "PROJECT"}
  ]
}

Response:

json
{
  "anonymized_text": "The launch of [PROJECT_1] is [DATE_2].",
  "map": {
    "Operation Skyfall": "[PROJECT_1]",
    "June 1st": "[DATE_2]"
  },
  "entities": 2
}

Error: Missing Required Field

400 Bad Request:

json
{
  "detail": "text field is required"
}

Questa AI documentation.