POST
/v1/process
Process text to detect and protect PII using automatic or specified privacy methods.
Request Headers
| Header | Type | Required | Description |
|---|---|---|---|
Authorization |
string | Yes | Bearer token with your API key |
Content-Type |
string | Yes | Must be application/json |
Request Body
{
"data": "string | object | array", // Required: Data to process
"method": "auto | redaction | masking | tokenization | differential_privacy | k_anonymity",
"format": "text | json | csv",
"confidence_threshold": 0.85, // Min confidence for detection (0.0-1.0)
"custom_patterns": [
{
"name": "CUSTOM_ID",
"pattern": "regex_pattern"
}
],
"return_metrics": true,
"preserve_context": false
}
Response
{
"request_id": "req_abc123def456",
"timestamp": "2024-01-15T10:30:00Z",
"processed_data": "My name is [PERSON_NAME], SSN [SSN_REDACTED]",
"entities_detected": [
{
"text": "John Smith",
"type": "PERSON_NAME",
"start": 11,
"end": 21,
"confidence": 0.98,
"replacement": "[PERSON_NAME]"
},
{
"text": "123-45-6789",
"type": "SSN",
"start": 27,
"end": 38,
"confidence": 0.99,
"replacement": "[SSN_REDACTED]"
}
],
"processing_time_ms": 12.5,
"method_used": "redaction",
"compliance": {
"gdpr": true,
"ccpa": true,
"hipaa": true,
"pci_dss": true
},
"risk_score": 0.85
}
Example Request
curl -X POST https://api.safekeylab.com/v1/process \
-H "Authorization: Bearer sk_live_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"data": "Contact John Smith at [email protected] or 555-123-4567",
"method": "auto",
"format": "text",
"return_metrics": true
}'
POST
/v1/detect
Detect PII without modifying the original data. Useful for analysis and compliance reporting.
Request Body
{
"data": "string | object | array",
"confidence_threshold": 0.85,
"custom_patterns": [],
"include_positions": true
}
Response
{
"request_id": "req_xyz789",
"entities": [
{
"text": "[email protected]",
"type": "EMAIL",
"confidence": 0.99,
"start": 22,
"end": 38
}
],
"summary": {
"total_entities": 3,
"by_type": {
"EMAIL": 1,
"PHONE": 1,
"PERSON_NAME": 1
},
"risk_score": 0.75
}
}
POST
/v1/batch
Process multiple documents in a single request for improved performance.
Request Body
{
"documents": [
{
"id": "doc_1",
"data": "First document text..."
},
{
"id": "doc_2",
"data": "Second document text..."
}
],
"method": "auto",
"parallel": true
}
Response
{
"batch_id": "batch_abc123",
"results": [
{
"document_id": "doc_1",
"processed_data": "...",
"entities_detected": 5
},
{
"document_id": "doc_2",
"processed_data": "...",
"entities_detected": 3
}
],
"total_processing_time_ms": 45.2
}
GET
/v1/audit-logs
Retrieve audit logs for compliance and security monitoring.
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
start_date |
ISO 8601 | No | Start of time range |
end_date |
ISO 8601 | No | End of time range |
limit |
integer | No | Max results (default: 100) |
offset |
integer | No | Pagination offset |
Response
{
"logs": [
{
"timestamp": "2024-01-15T10:30:00Z",
"request_id": "req_abc123",
"action": "process",
"entities_detected": 5,
"method_used": "redaction",
"user_agent": "Python/3.9 safekeylab-sdk/1.0",
"ip_address": "192.168.1.1"
}
],
"pagination": {
"total": 1523,
"limit": 100,
"offset": 0
}
}
Rate Limits
API rate limits vary by plan:
| Plan | Requests/Second | Requests/Month | Burst Limit |
|---|---|---|---|
| Starter | 100 | 10M | 500 |
| Growth | 1,000 | 100M | 5,000 |
| Enterprise | 10,000 | Unlimited | 50,000 |
Rate Limit Headers
Every response includes rate limit information:
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 998
X-RateLimit-Reset: 1642248000
Error Codes
Standard HTTP status codes and custom error responses:
| Status | Error Code | Description |
|---|---|---|
| 400 | invalid_request |
Malformed request or missing parameters |
| 401 | unauthorized |
Invalid or missing API key |
| 403 | forbidden |
API key lacks required permissions |
| 429 | rate_limit_exceeded |
Too many requests |
| 500 | internal_error |
Server error, please retry |
Error Response Format
{
"error": {
"code": "invalid_request",
"message": "Missing required parameter: data",
"details": {
"parameter": "data",
"type": "missing"
}
},
"request_id": "req_error123"
}