Skip to content

Text Anonymization on SipPulse AI

Overview

The Text Anonymization tool allows you to identify and redact sensitive information from text content, helping ensure privacy compliance and data protection. This feature is essential for organizations handling personal data that need to comply with regulations like GDPR, HIPAA, or LGPD.

How It Works

The anonymization engine uses advanced pattern recognition to automatically detect and redact various types of sensitive information from text. You can customize which types of data should be anonymized and view the redacted output in real-time.

Using the Anonymization Tool

  1. Navigate to the Anonymization section in the Playground
  2. Select your preferred language from the dropdown menu
  3. Enter or paste the text you want to anonymize in the input field
  4. Select which data types to anonymize by checking the appropriate boxes
  5. Click the Anonymize button to process the text
  6. View the anonymized version in the right panel

Available Anonymization Options

The following sensitive data types can be detected and redacted:

Data TypeDescriptionExample
Email AddressDetects and redacts email addressesjohn.doe@example.com → [EMAIL]
URLAnonymizes web addresses and linkshttps://example.com → [URL]
US SSNRedacts Social Security Numbers123-45-6789 → [SSN]
Credit CardMasks credit card numbers4111-1111-1111-1111 → [CREDIT_CARD]
PersonAnonymizes personal namesJohn Smith → [PERSON]
Date TimeRedacts dates and times2025-05-14 14:30 → [DATE_TIME]
LocationMasks location informationNew York, NY → [LOCATION]
IP AddressAnonymizes IP addresses192.168.1.1 → [IP_ADDRESS]
NumbersRedacts numeric sequencesAccount #12345 → Account #[NUMBER]

Search and Replace

For more granular control, you can use the Search and Replace feature to:

  1. Define custom patterns to search for
  2. Specify replacement text for matching patterns
  3. Create and save multiple search and replace rules

API Integration Examples

Python

python
import requests
import json

def anonymize_text(text, api_key, entities=None, search_and_replace=None, language="en"):
    """
    Anonymize text using SipPulse AI API
    
    Parameters:
    - text (str): The text to be anonymized
    - api_key (str): Your SipPulse API key
    - entities (list): List of entity types to anonymize
    - search_and_replace (list): Custom patterns to search and replace
    - language (str): Language code (en, pt, es, etc.)
    
    Returns:
    - dict: API response containing anonymized text
    """
    # Set default values
    if entities is None:
        entities = ["EMAIL_ADDRESS", "URL", "US_SSN", "CREDIT_CARD", "PERSON"]
    
    if search_and_replace is None:
        search_and_replace = []
        
    # API endpoint
    url = "https://api.sippulse.ai/anonymize"
    
    # Request data
    data = {
        "text": text,
        "entities": entities,
        "search_and_replace": search_and_replace,
        "language": language
    }
    
    # Headers
    headers = {
        "Content-Type": "application/json",
        "api-key": api_key
    }
    
    # Send request
    response = requests.post(url, headers=headers, data=json.dumps(data))
    
    # Process response
    if response.status_code == 200:
        return response.json()
    else:
        raise Exception(f"Error {response.status_code}: {response.text}")

# Example usage
api_key = "YOUR_SIPPULSE_API_KEY"

# Example 1: Basic anonymization
sample_text = """
Customer Information:
Name: John Smith
Email: john.smith@company.com
Phone: (555) 123-4567
SSN: 123-45-6789
Credit Card: 4111-1111-1111-1111
Address: 123 Main St, Boston, MA 02108
"""

# Basic anonymization with default entity types
result1 = anonymize_text(sample_text, api_key)
print("Basic Anonymization Results:")
print(result1["anonymized_text"])
print("\n" + "-"*50 + "\n")

# Example 2: Advanced anonymization with custom search and replace
advanced_text = """
Project Internal Code: PROJ-2025-XYZ
Client: Acme Corporation (ID: ACME-123)
Deployment Date: May 14, 2025
Contact: sarah.jones@acme.com
"""

# Custom entities and search/replace patterns
custom_entities = ["EMAIL_ADDRESS", "DATE_TIME", "PERSON"]
custom_patterns = [
    {
        "search": r"PROJ-\d{4}-[A-Z]{3}",
        "replace": "[PROJECT_CODE]"
    },
    {
        "search": r"ACME-\d{3}",
        "replace": "[CLIENT_ID]"
    }
]

result2 = anonymize_text(
    advanced_text, 
    api_key, 
    entities=custom_entities,
    search_and_replace=custom_patterns
)

print("Advanced Anonymization Results:")
print(result2["anonymized_text"])

Output Example:

Customer Information:
Name: [PERSON]
Email: [EMAIL_ADDRESS]
Phone: (555) 123-4567
SSN: [SSN]
Credit Card: [CREDIT_CARD]
Address: 123 Main St, [LOCATION]

javascript

javascript
const axios = require('axios');

/**
 * Anonymize text using SipPulse AI API
 * 
 * @param {string} text - The text to be anonymized
 * @param {string} apiKey - Your SipPulse API key
 * @param {Array} entities - List of entity types to anonymize
 * @param {Array} searchAndReplace - Custom patterns to search and replace
 * @param {string} language - Language code (en, pt, es, etc.)
 * @returns {Promise} - Promise resolving to the API response
 */
async function anonymizeText(text, apiKey, entities = null, searchAndReplace = null, language = "en") {
  // Set default values
  if (!entities) {
    entities = ["EMAIL_ADDRESS", "URL", "US_SSN", "CREDIT_CARD", "PERSON"];
  }
  
  if (!searchAndReplace) {
    searchAndReplace = [];
  }
  
  // API endpoint
  const url = 'https://api.sippulse.ai/anonymize';
  
  // Request data
  const data = {
    text,
    entities,
    search_and_replace: searchAndReplace,
    language
  };
  
  // Headers
  const headers = {
    'Content-Type': 'application/json',
    'api-key': apiKey
  };
  
  try {
    const response = await axios.post(url, data, { headers });
    return response.data;
  } catch (error) {
    throw new Error(`Error: ${error.response ? error.response.data : error.message}`);
  }
}

// Example usage
(async () => {
  const apiKey = 'YOUR_SIPPULSE_API_KEY';
  
  // Example 1: Basic anonymization
  const sampleText = `
Customer Information:
Name: John Smith
Email: john.smith@company.com
Phone: (555) 123-4567
SSN: 123-45-6789
Credit Card: 4111-1111-1111-1111
Address: 123 Main St, Boston, MA 02108
  `;
  
  try {
    // Basic anonymization with default entity types
    const result1 = await anonymizeText(sampleText, apiKey);
    console.log("Basic Anonymization Results:");
    console.log(result1.anonymized_text);
    console.log("\n" + "-".repeat(50) + "\n");
    
    // Example 2: Advanced anonymization with custom search and replace
    const advancedText = `
Project Internal Code: PROJ-2025-XYZ
Client: Acme Corporation (ID: ACME-123)
Deployment Date: May 14, 2025
Contact: sarah.jones@acme.com
    `;
    
    // Custom entities and search/replace patterns
    const customEntities = ["EMAIL_ADDRESS", "DATE_TIME", "PERSON"];
    const customPatterns = [
      {
        search: "PROJ-\\d{4}-[A-Z]{3}",
        replace: "[PROJECT_CODE]"
      },
      {
        search: "ACME-\\d{3}",
        replace: "[CLIENT_ID]"
      }
    ];
    
    const result2 = await anonymizeText(
      advancedText, 
      apiKey, 
      customEntities, 
      customPatterns
    );
    
    console.log("Advanced Anonymization Results:");
    console.log(result2.anonymized_text);
  } catch (error) {
    console.error(error.message);
  }
})();