Back to index

POST: Anonymize Text

POST: https://api.compliantchatgpt.com/v1/anonymize

This endpoint is used to replace any PHI (Protected Health Information) in your text with tokens. The original text is not stored on our systems.

Request Headers

  • x-compliantchatgpt-key: API key for the CompliantChatGPT service. (Required)
  • Content-Type: The format of the request payload. Must be 'application/json'.

Request Body

  • text: The text which needs to be anonymized by replacing PHI with appropriate tokens.

Response

  • anonymized_text: The text after anonymization, with all PHI replaced by tokens.
  • identified_phi: A list of dictionaries, each containing the start and end positions, the entity type, and the original word of the identified PHI in the original text.

Error Responses

  • 400: Invalid request body or missing CompliantChatGPT API key.
  • 500: Server error, details in the description.

Example Request

      
        import requests
        import json


        url = "https://api.compliantchatgpt.com/v1/anonymize"


        headers = {
        'x-compliantchatgpt-key': '{your_CompliantChatGPT_key}',
        'Content-Type': 'application/json'
        }


        data = {
        "text": "Patient John Doe is at Hospital Florence."
        }


        response = requests.post(url, headers=headers, data=json.dumps(data))


        print(response.json())
      
    

Example Response

      
        {
          "anonymized_text": "Patient {PATIENT1} is at {HOSPITAL1}",
          "identified_phi": [
            {
              "end": 16,
              "entity": "PATIENT",
              "start": 8,
              "word": "John Doe"
            },
            {
              "end": 40,
              "entity": "HOSPITAL",
              "start": 23,
              "word": "\"Hospital Florence”"
            }
          ]
        }