Redact PDF API
Category: pdf
Remove sensitive information from PDF files by redacting specified keywords. Matching text is permanently blacked out.
Endpoint
POST
https://anythingtext.com/api/tools/redactpdf
Authentication Required
Content-Type: multipart/form-data
Authentication
This API requires an API key. Generate one from the API Keys section in your dashboard settings.
Include the X-API-Key header in all API requests:
X-API-Key: atk_your_api_key_here
Rate Limiting
API requests are limited to 60 requests per minute per user. If you exceed this limit, the API returns a 429 Too Many Requests response.
Every response includes rate limit headers:
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 57
X-RateLimit-Reset: 42
When rate limited, the response body contains:
{ "error": "Rate limit exceeded. Maximum 60 requests per minute.", "retryAfter": 42, "limit": 60 }
Request Parameters
| Name | Type | Required | Description |
|---|---|---|---|
file
|
File | Required |
The PDF file to redact
Example: document.pdf
|
keywords
|
String | Required |
Comma-separated keywords to redact
Example: SSN,password,secret
|
Response
Content-Type: application/pdf
Redacted PDF with keywords blacked out
(binary PDF data)
Error Responses
| Status | Description | Body |
|---|---|---|
401 |
Not authenticated | {"error": "Please log in..."} |
400 |
Bad request / Missing required params | {"error": "... is required"} |
500 |
Internal server error | {"error": "Failed to ..."} |
cURL Example
curl -X POST https://anythingtext.com/api/tools/redactpdf \ -H "X-API-Key: your_api_key_here" \ -F "file=@document.pdf" \ -F "keywords=SSN,password,secret" \ --output redacted.pdf
Code Samples
const formData = new FormData();
formData.append('file', fileInput.files[0]);
formData.append('keywords', 'SSN,password,secret');
const response = await fetch('https://anythingtext.com/api/tools/redactpdf', {
method: 'POST',
headers: { 'X-API-Key': 'your_api_key_here' },
body: formData
});
const blob = await response.blob();
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'output.pdf';
a.click();
import requests
with open('input.pdf', 'rb') as f:
response = requests.post(
'https://anythingtext.com/api/tools/redactpdf',
files={'file': f},
data={'keywords': 'SSN,password,secret'},
headers={'X-API-Key': 'your_api_key_here'}
)
with open('output.pdf', 'wb') as f:
f.write(response.content)
print('Saved to output.pdf')
import java.net.URI;
import java.net.http.*;
import java.nio.file.*;
HttpClient client = HttpClient.newHttpClient();
// Build multipart form data with file + parameter
String boundary = "----Boundary" + System.currentTimeMillis();
byte[] fileBytes = Files.readAllBytes(Path.of("input.pdf"));
// See cURL example above for the equivalent command.
// For Java multipart uploads, consider using Apache HttpClient
// or Spring WebClient for simpler multipart handling.
// Example with Apache HttpClient:
// HttpEntity entity = MultipartEntityBuilder.create()
// .addBinaryBody("file", fileBytes)
// .addTextBody("keywords", "SSN,password,secret")
// .build();