Introduction
The RedactionAPI.net API provides a robust, enterprise-grade solution for detecting and removing Personally Identifiable Information (PII) and other sensitive data from text and documents. Built for compliance with GDPR, CCPA, HIPAA, PCI DSS, and SOX, it processes content in real-time and returns both fully redacted and masked versions.
233 Data Types
Detect PII, PHI, PCI, and proprietary data across 12 categories.
Real-Time Processing
Sub-100ms average response time for text redaction requests.
End-to-End Encryption
AES-256 encryption at rest and TLS 1.3 in transit.
Compliance Ready
GDPR, CCPA, HIPAA, PCI DSS, SOX, FERPA compliant.
POST to https://www.redactionapi.net/api/redact.php (also reachable as /api/moderate.php). The API accepts JSON request bodies and returns JSON responses.
Authentication
All API requests require authentication via an API key. Include your key as the api_key field inside the JSON request body. No headers, tokens, or OAuth flows are needed — authentication is just this one field.
{
"api_key": "your_api_key_here",
...
}
API keys are available through our subscription plans. After subscribing, retrieve your unique API key from your dashboard.
| Field / Header | Value | Required |
|---|---|---|
api_key (JSON body field) |
Your unique API key | Required |
Content-Type (HTTP header) |
application/json |
Required |
Quick Start
Get up and running with the Redaction API in three simple steps.
-
Get Your API Key
Sign up at redactionapi.net/pricing and retrieve your API key from the dashboard.
-
Send Your First Request
Make a POST request to the redaction endpoint with your text, your API key, and
"api_type": "anonymization". -
Process the Response
The API returns the anonymized text in
anonymized_textwith labeled placeholders like[EMAIL],[SSN], plus adetected_entitieslist with positions and confidence scores.
curl -X POST https://www.redactionapi.net/api/redact.php \
-H "Content-Type: application/json" \
-d '{
"text": "Contact John at [email protected] or 555-123-4567",
"api_key": "your_api_key_here",
"api_type": "anonymization"
}'
total_words, words_used and remaining_words.Text Anonymization Endpoint
/api/redact.php
Submit text content for PII detection and redaction with "api_type": "anonymization". The API analyzes the text, identifies sensitive data, and returns the anonymized text together with a list of detected entities (type, matched text, position, confidence).
Request Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
text |
string | Required | The text content to scan and redact. content is accepted as an alias. Maximum 100,000 words per request; anonymization processes the first 16,000 words. |
api_key |
string | Required | Your API key. Authentication happens through this field — no headers or tokens. |
api_type |
string | Required | anonymization for PII redaction. moderation selects the content moderation mode. |
entities |
array | Optional | Entity types to detect, e.g. ["PII", "PHI", "EMAIL", "PHONE", "CREDIT_CARD", "SSN"] (this is the default). See Supported Data Types. |
exclude_entities |
array | Optional | Entity types that must NEVER be anonymized — they are preserved as-is in the output (e.g. ["URL", "COUNTRY"]). |
mask_mode |
string | Optional | How detected data is masked: replace (typed placeholders like [EMAIL], default), redact (everything becomes [REDACTED]), or hash (placeholders like [HASH_EMAIL_X7Y8Z9]). |
Example Request
{
"text": "Employee Sarah Johnson ([email protected])\nSSN: 123-45-6789 | Phone: +1 (555) 123-4567\nCredit Card: 4111 1111 1111 1111\nIP Address: 192.168.1.42",
"api_key": "your_api_key_here",
"api_type": "anonymization",
"entities": [
"PII", "EMAIL", "PHONE",
"CREDIT_CARD", "SSN", "IP_ADDRESS"
],
"mask_mode": "replace"
}
Content Moderation Mode
/api/redact.php
The same endpoint also provides text content moderation. Send "api_type": "moderation" to scan text for harmful or unwanted content categories instead of anonymizing it.
| Parameter | Type | Required | Description |
|---|---|---|---|
content |
string | Required | The text to moderate. |
api_key |
string | Required | Your API key. |
api_type |
string | Required | Set to moderation. |
content_type |
string | Required | text, or text_custom_instruction to moderate against your own instruction (paid plans). |
moderate |
string | Required | "standard" for the default categories, or a comma-separated list of custom words/categories (max 50). |
custom_instruction |
string | Optional | Your moderation instruction. Required when content_type is text_custom_instruction. |
moderation object with per-category results, a moderation_words array for any custom categories, and (when a custom instruction is used) moderation_custom_instruction — plus the same usage fields (total_words, words_used, remaining_words) as anonymization responses.
Supported Data Types
Our API detects 233 sensitive data types organized across 12 categories. Use the key values below in the entities array to focus detection, or in exclude_entities to preserve specific types. If you omit entities, the default set ["PII", "PHI", "EMAIL", "PHONE", "CREDIT_CARD", "SSN"] is used — PII and PHI act as broad catch-all categories.
Code Examples
Production-ready integration examples for the most popular languages and tools.
import requests
# Configuration
API_URL = "https://www.redactionapi.net/api/redact.php"
API_KEY = "your_api_key_here"
def redact_text(text, entities=None, mask_mode="replace"):
"""Redact sensitive data from text using RedactionAPI."""
payload = {
"text": text,
"api_key": API_KEY,
"api_type": "anonymization",
"mask_mode": mask_mode
}
if entities:
payload["entities"] = entities
response = requests.post(API_URL, json=payload)
result = response.json()
# Errors are reported in the JSON body via "status" / "error"
if result.get("status") != 200:
raise RuntimeError(result.get("error", "Unknown API error"))
return result
# Example usage
text = """Employee: Sarah Johnson ([email protected])
SSN: 123-45-6789 | Phone: +1 (555) 123-4567
Credit Card: 4111 1111 1111 1111"""
entities = ["PII", "EMAIL", "PHONE", "CREDIT_CARD", "SSN"]
result = redact_text(text, entities)
print("Anonymized:", result["anonymized_text"])
print("Entities detected:", result["entities_detected"])
print("Details:", result["detected_entities"])
print("Words remaining:", result["remaining_words"])
// Uses the built-in fetch API (Node.js 18+ or any modern browser context)
const API_URL = 'https://www.redactionapi.net/api/redact.php';
const API_KEY = 'your_api_key_here';
async function redactText(text, entities) {
const response = await fetch(API_URL, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
text: text,
api_key: API_KEY,
api_type: 'anonymization',
entities: entities,
mask_mode: 'replace'
})
});
const result = await response.json();
// Errors are reported in the JSON body via "status" / "error"
if (result.status !== 200) {
throw new Error(`API error ${result.status}: ${result.error}`);
}
return result;
}
// Example usage
(async () => {
const result = await redactText(
'Contact [email protected] or call 555-123-4567',
['PII', 'EMAIL', 'PHONE']
);
console.log('Anonymized:', result.anonymized_text);
console.log('Entities:', result.detected_entities);
console.log('Words remaining:', result.remaining_words);
})();
curl -X POST https://www.redactionapi.net/api/redact.php \
-H "Content-Type: application/json" \
-d '{
"text": "Employee Sarah Johnson ([email protected])\nSSN: 123-45-6789\nPhone: +1 (555) 123-4567\nCredit Card: 4111 1111 1111 1111\nIP: 192.168.1.42",
"api_key": "your_api_key_here",
"api_type": "anonymization",
"entities": [
"PII",
"EMAIL",
"PHONE",
"CREDIT_CARD",
"SSN",
"IP_ADDRESS"
],
"mask_mode": "replace"
}'
<?php
$apiUrl = 'https://www.redactionapi.net/api/redact.php';
$apiKey = 'your_api_key_here';
$payload = json_encode([
'text' => 'Contact [email protected], SSN: 123-45-6789',
'api_key' => $apiKey,
'api_type' => 'anonymization',
'entities' => ['PII', 'EMAIL', 'SSN', 'PHONE'],
'mask_mode' => 'replace'
]);
$ch = curl_init($apiUrl);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json'
]
]);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
// Errors are reported in the JSON body via "status" / "error"
if (isset($result['status']) && $result['status'] === 200) {
echo "Anonymized: " . $result['anonymized_text'] . "\n";
echo "Entities detected: " . $result['entities_detected'] . "\n";
echo "Words remaining: " . $result['remaining_words'] . "\n";
} else {
echo "Error: " . ($result['error'] ?? 'unknown') . "\n";
}
?>
import java.net.http.*;
import java.net.URI;
public class RedactionApiExample {
private static final String API_URL = "https://www.redactionapi.net/api/redact.php";
private static final String API_KEY = "your_api_key_here";
public static void main(String[] args) throws Exception {
String jsonBody = """
{
"text": "Contact [email protected], SSN: 123-45-6789",
"api_key": "%s",
"api_type": "anonymization",
"entities": ["PII", "EMAIL", "SSN", "PHONE"],
"mask_mode": "replace"
}
""".formatted(API_KEY);
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(API_URL))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(jsonBody))
.build();
HttpResponse<String> response = client.send(
request, HttpResponse.BodyHandlers.ofString()
);
System.out.println("Status: " + response.statusCode());
System.out.println("Body: " + response.body());
}
}
Response Format
All successful requests return a JSON object with the following structure:
{
"anonymized_text": "Employee [NAME] ([EMAIL])\nSSN: [SSN] | Phone: [PHONE]\nCredit Card: [CREDIT_CARD]\nIP: [IP_ADDRESS]",
"detected_entities": [
{
"type": "PII",
"text": "Sarah Johnson",
"start": 9,
"end": 22,
"confidence": 0.98
},
{
"type": "EMAIL",
"text": "[email protected]",
"start": 24,
"end": 50,
"confidence": 0.99
}
],
"entities_detected": 5,
"mask_mode_used": "replace",
"processing_time_ms": 152,
"original_length": 128,
"anonymized_length": 96,
"status": 200,
"total_words": 100000,
"words_used": 1520,
"remaining_words": 98480
}
Response Fields
| Field | Type | Description |
|---|---|---|
anonymized_text |
string | The processed text with sensitive data masked according to mask_mode (e.g., [EMAIL] placeholders). |
detected_entities |
array | One object per detected entity with type, text, start, end, and confidence. |
entities_detected |
integer | Number of entities detected in the text. |
mask_mode_used |
string | The mask mode applied: replace, redact, or hash. |
processing_time_ms |
integer | Server-side processing time in milliseconds. |
original_length / anonymized_length |
integer | Character length of the input text and the anonymized output. |
status |
integer | Result status code in the JSON body. 200 indicates success; errors carry 4xx/5xx values here (see Error Handling). |
total_words / words_used / remaining_words |
integer | Your plan's word quota, words consumed so far, and words remaining after this request. Legacy aliases total_pages, pages_used, remaining_pages are also present for older integrations. |
Error Handling
Errors are returned as a JSON body with an error message and a status code. Important: the HTTP transport status is generally 200 — always check the status field inside the JSON response, not the HTTP status code.
{
"error": "Invalid API key. The provided API key was not found in any of the user tables or the API_keys table. Please check your API key or purchase a subscription.",
"status": 401
}
HTTP Status Codes
| Status | Meaning | Description |
|---|---|---|
| 200 | Success | Request processed successfully. Response contains the anonymized output. |
| 400 | Bad Request | Missing api_key, missing text/content, invalid api_type (must be moderation or anonymization), invalid mask_mode, or malformed JSON. |
| 401 | Invalid API Key | The api_key provided was not found. Check your key or purchase a subscription. |
| 402 | Insufficient Words | Your remaining word quota is not enough for this request (words in text + 1,500-word instruction allowance). The response includes required_tokens, remaining_words, and total_words. |
| 413 | Text Too Large | Request exceeds the maximum of 100,000 words. Split your content into smaller requests. (Anonymization processes the first 16,000 words of each request.) |
| 429 | Too Many Requests | Rate limit exceeded. See Rate Limits below. |
| 500 | Server Error | Internal error while processing the request. Retry after a short delay or contact support. |
Rate Limits
Requests are rate-limited per client IP address. The default limit is 30 requests per 60 seconds (trial accounts have a lower limit). Exceeding the limit returns a 429 error in the response body.
{
"detail": "Too many requests. Rate limit is 30 requests per 60 seconds (note that trial accounts have lower limit). If you need higher rate limit please contact us per email."
}
If you need a higher rate limit for your workload, contact us by email and we will raise it for your account.
total_words, words_used, and remaining_words so you can track quota consumption in real time and slow down before running out.