This endpoint checks if there is any PII or PHI in a message, and if there is, returns the message with those pieces of data redacted, replaced with text of your choosing.
Endpoint
POST https://quanstyst.com/api/v1/pii-redaction
Usage
Headers
Authorization: Requires setting your API Key as the the authorization
header's Bearer.
Content-Type: application/json
Body
Content
The body requires a field content
. This field is a string.
Redaction Keys
An optional field redactions
can be included, which is an object of key value pairs.
The keys are the redaction keys - keys that get matched against content, for example 'medical_condition'.
The value is what you want the model to replace that content with. By default content that matches 'medication_conditions' will be replaced with 'REDACTED_MEDICAL_CONDITION'.
If you do not add a redactions
object to the request body, the default will be used. If you do, you must include all the keys and values that you want redacted.
For example, if you only want to redact names and birthdays, you would send:
{ date_of_birth: 'REDACTED_DATE_OF_BIRTH', person_name: 'REDACTED_PERSON_NAME', }
Default Values
{ age: 'REDACTED_AGE', credit_card_info: 'REDACTED_CREDIT_CARD_INFO', nationality: 'REDACTED_NATIONALITY', date: 'REDACTED_DATE', date_of_birth: 'REDACTED_DATE_OF_BIRTH', domain_name: 'REDACTED_DOMAIN_NAME', email_address: 'REDACTED_EMAIL_ADDRESS', demographic_group: 'REDACTED_DEMOGRAPHIC_GROUP', gender: 'REDACTED_GENDER', personal_id: 'REDACTED_PERSONAL_ID', other_id: 'REDACTED_OTHER_ID', banking_number: 'REDACTED_BANKING_NUMBER', medical_condition: 'REDACTED_MEDICAL_CONDITION', organization_name: 'REDACTED_ORGANIZATION_NAME', person_name: 'REDACTED_PERSON_NAME', phone_number: 'REDACTED_PHONE_NUMBER', street_address: 'REDACTED_STREET_ADDRESS', password: 'REDACTED_PASSWORD', secure_credential: 'REDACTED_SECURE_CREDENTIALS', religious_affiliation: 'REDACTED_RELIGIOUS_AFFILIATION', }
Response
The shape of the response is:
{ redacted: boolean, results: string }
The response will be an object with the field results
.
This results
field will contain an array with one item per message.
Each item contains the flagged
boolean, and a list
array.
The list
array will contain a list of filters with the filter key and score that were matched to your input.
The key is what type of filter - ex. "violence", "profanity", etc.
The score is how "sure" the model is of the match.
If there was no match, flagged
will be false, and the list will be an empty array.
Example
Request
curl --request POST \ --url https://quanstyst.com/api/v1/pii-redaction \ --header authorization: Bearer <Your API Token> \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --data ' { "content": "Hello, my name is Justin and you can contact me at contact@justin.com", "redactions": { "person_name": "*****", "email": "REDACTED_EMAIL" } } '
Response
{ results: 'Hello, my name is ***** and you can contact me at REDACTED_EMAIL', redacted: true }
Sample Usage
cURL
curl --request POST \ --url https://quanstyst.com/api/v1/pii-redaction \ --header authorization: Bearer <Your API Token> \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --data ' { "content": "Hello, my name is Justin and you can contact me at contact@justin.com" } '
JavaScript
const options = { method: 'POST', headers: { authorization: 'Bearer <Your API Token>', accept: 'application/json', 'content-type': 'application/json' }, body: JSON.stringify({ "content": "Hello, my name is Justin and you can contact me at contact@justin.com", }) }; fetch('https://quanstyst.com/api/v1/pii-redaction', options) .then(response => response.json()) .then(response => console.log(response)) .catch(err => console.error(err));
Python
import requests url = "https://quanstyst.com/api/v1/pii-redaction" payload = { "content": "Hello, my name is Justin and you can contact me at contact@justin.com", } headers = { "authorization": "Bearer <Your API Token>" "accept": "application/json", "content-type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response)