Skip to main content

Documentation Index

Fetch the complete documentation index at: https://assemblyai.com/docs/llms.txt

Use this file to discover all available pages before exploring further.



US & EU
The PII Redaction model lets you minimize sensitive information about individuals by automatically identifying and removing it from your transcript. Personal Identifiable Information (PII) is any information that can be used to identify a person, such as a name, email address, or phone number. To redact PII from text rather than audio, see Redact PII from Text Using LLM Gateway. When you enable the PII Redaction model, your transcript will look like this:
  • With hash substitution: Hi, my name is ####!
  • With entity_name substitution: Hi, my name is [PERSON_NAME]!
You can also Create redacted audio files to replace sensitive information in the audio with a beeping sound or silence.
Redacted PropertiesPII only redacts words in the text property. Properties from other features may still include PII, such as entities from Entity Detection or summary from Summarization.

Quickstart

Enable Topic Detection by setting redact_pii to True in the JSON payload.Set redact_pii_policies to specify the information you want to redact. For the full list of policies, see PII policies.Set redact_pii_sub to specify the replacement for redacted information.
import requests
import time

base_url = "https://api.assemblyai.com"

headers = {
    "authorization": "<YOUR_API_KEY>"
}

with open("./local_file.mp3", "rb") as f:
    response = requests.post(base_url + "/v2/upload",
                            headers=headers,
                            data=f)

upload_url = response.json()["upload_url"]

data = {
    "audio_url": upload_url, # You can also use a URL to an audio or video file on the web
    "speech_models": ["universal-3-pro", "universal-2"],
    "language_detection": True,
    "redact_pii": True,
    "redact_pii_policies": ["person_name", "organization", "occupation"],
    "redact_pii_sub": "hash"
}

url = base_url + "/v2/transcript"
response = requests.post(url, json=data, headers=headers)

transcript_id = response.json()['id']
polling_endpoint = base_url + "/v2/transcript/" + transcript_id

print(f"Transcript ID: {transcript_id}")

while True:
    transcription_result = requests.get(polling_endpoint, headers=headers).json()

    if transcription_result['status'] == 'completed':
        print(transcription_result['text'])
        break
    elif transcription_result['status'] == 'error':
        raise RuntimeError(f"Transcription failed: {transcription_result['error']}")
    else:
        time.sleep(3)

Example output

Smoke from hundreds of wildfires in Canada is triggering air quality alerts
throughout the US. Skylines from Maine to Maryland to Minnesota are gray and
smoggy. And in some places, the air quality warnings include the warning to stay
inside. We wanted to better understand what's happening here and why, so we
called ##### #######, an ######### ######### in the ########## ## #############
###### ### ########### at ##### ####### ##########. Good morning, #########.
Good morning. So what is it about the conditions right now that have caused this
round of wildfires to affect so many people so far away? Well, there's a couple
of things. The season has been pretty dry already, and then the fact that we're
getting hit in the US. Is because there's a couple of weather systems that ...
PII Redaction Using LLM GatewayIf you would like the option to use LLM Gateway for custom PII redaction, check out this guide Redact PII from Text Using LLM Gateway.

Create redacted audio files

In addition to redacting sensitive information from the transcription text, you can also generate a version of the original audio file with the PII “beeped” out. You can optionally use silence instead of a beep by setting override_audio_redaction_method to "silence" within redact_pii_audio_options.
Redacted Audio EndpointRetrieve the redacted audio file using the transcript_id for a transcript where redact_pii_audio was enabled during submission:Redacted audio files are only available for 24 hours. Make sure to download the file within this time frame.
To create a redacted version of the audio file, set redact_pii_audio to True on the JSON payload. Set redact_pii_audio_quality to specify the quality of the redacted audio file.Use the transcript ID to poll the GET redacted audio endpoint every few seconds to check the status of the redacted audio. Once the status is redacted_audio_ready, you can retrieve the audio URL from the API response.
data = {
    "audio_url": upload_url, # You can also use a URL to an audio or video file on the web
    "redact_pii": True,
    "redact_pii_policies": ["person_name", "organization", "occupation"],
    "redact_pii_sub": "hash",
    "redact_pii_audio": True,
    "redact_pii_audio_quality": "wav", # Optional. Defaults to "mp3"
    "redact_pii_audio_options": {
        "override_audio_redaction_method": "silence" # Optional. Omit for default (beep)
    }
}

# ...
redacted_audio_polling_endpoint = base_url + "/v2/transcript/" + transcript_id + "/redacted-audio"

while True:
    redacted_audio_result = requests.get(redacted_audio_polling_endpoint, headers=headers).json()

    if redacted_audio_result['status'] == 'redacted_audio_ready':
        print(redacted_audio_result['redacted_audio_url'])
        break
    elif redacted_audio_result['status'] == 'error':
        raise RuntimeError(f"Transcription failed: {redacted_audio_result['error']}")
    else:
        time.sleep(3)
Maximum Audio File SizeYou can only create redacted versions of audio files if the original file is smaller than 1 GB. For files over 1 GB, see the Downsampling guide to reduce file size before redaction.
Redacted Audio for Silent FilesBy default, audio redaction provides redacted audio URLs only when speech is detected. However, if your use-case specifically requires redacted audio files even for silent audio files without any dialogue, you can now opt to receive these URLs. Enable this by setting the optional parameter "return_redacted_no_speech_audio": true within redact_pii_audio_options in your POST request body.
{
    "audio_url": "YOUR_AUDIO_URL",
    "redact_pii": true,
    "redact_pii_audio": true,
    "redact_pii_audio_options": {
          "return_redacted_no_speech_audio": true
     },
     "redact_pii_policies": ["credit_card_number"]
}

Example output

https://s3.us-west-2.amazonaws.com/api.assembly.ai.usw2/redacted-audio/ac06721c-d1ea-41a7-95f7-a9463421e6b1.mp3?AWSAccessKeyId=...

Return the unredacted transcript

If your workflow needs both the redacted and unredacted transcripts, you can request both in a single transcription call by setting redact_pii_return_unredacted to true. This avoids the need to send a second API request without redaction.
This is an opt-in convenience featureEnabling PII Redaction by itself does not return the unredacted transcript — the default behavior is to redact text, words, and utterances and return only the redacted versions. The unredacted transcript is only returned when you explicitly set redact_pii_return_unredacted to true, and redact_pii must also be true (otherwise the request is rejected with a 400).Only use this feature if your workflow specifically requires access to both the redacted and unredacted transcripts from the same request. If you only need the redacted transcript, leave this parameter off. When redact_pii_return_unredacted is false or omitted, the three unredacted_* fields are not included in the response at all.
When redact_pii_return_unredacted is true, the response includes three additional fields alongside their redacted counterparts:
FieldTypeDescription
unredacted_textstringThe original transcript text before PII redaction was applied.
unredacted_wordsarray of WordThe original word objects before redaction. Same shape as words.
unredacted_utterancesarray of UtteranceThe original utterance objects before redaction. Same shape as utterances.
Set redact_pii_return_unredacted to True alongside the existing PII parameters. The completed transcript will include unredacted_text, unredacted_words, and unredacted_utterances in addition to the redacted versions.
data = {
    "audio_url": upload_url, # You can also use a URL to an audio or video file on the web
    "redact_pii": True,
    "redact_pii_policies": ["person_name", "phone_number", "email_address"],
    "redact_pii_sub": "entity_name",
    "redact_pii_return_unredacted": True
}

# ...
# After polling completes:
print("Redacted:  ", transcription_result["text"])
print("Original:  ", transcription_result["unredacted_text"])

Example response

{
  "text": "[PERSON_NAME] called from [PHONE_NUMBER]...",
  "words": [{ "text": "[PERSON_NAME]", "start": 250, "end": 650, "confidence": 0.98 }],
  "utterances": [{ "text": "[PERSON_NAME] called from [PHONE_NUMBER]...", "start": 250, "end": 4820, "speaker": "A" }],
  "redact_pii_return_unredacted": true,
  "unredacted_text": "Mary called from 555-0123...",
  "unredacted_words": [{ "text": "Mary", "start": 250, "end": 650, "confidence": 0.98 }],
  "unredacted_utterances": [{ "text": "Mary called from 555-0123...", "start": 250, "end": 4820, "speaker": "A" }]
}

API reference

Request

curl https://api.assemblyai.com/v2/transcript \
--header "Authorization: <YOUR_API_KEY>" \
--header "Content-Type: application/json" \
--data '{
  "audio_url": "YOUR_AUDIO_URL",
  "redact_pii": true,
  "redact_pii_policies": ["us_social_security_number", "credit_card_number"],
  "redact_pii_sub": "hash",
  "redact_pii_audio": true,
  "redact_pii_audio_quality": "mp3",
  "redact_pii_audio_options": {
    "override_audio_redaction_method": "silence"
  }
}'
KeyTypeDescription
redact_piibooleanEnable PII Redaction.
redact_pii_policiesarrayPII policies for what information to redact.
redact_pii_substringMethod used to substitute PII in the transcript. Can be entity_name or hash.
redact_pii_audiobooleanCreate a redacted version of the audio file.
redact_pii_audio_qualitystringQuality of the redacted PII audio file. Can be mp3 or wav.
redact_pii_audio_optionsobjectOptions for PII-redacted audio. See Create redacted audio files.
redact_pii_audio_options.override_audio_redaction_methodstringThe method used to redact audio. Set to silence to replace PII with silence instead of the default beep.
redact_pii_return_unredactedbooleanOpt-in. When true, returns the unredacted transcript alongside the redacted one. Requires redact_pii: true. Defaults to false, in which case only the redacted transcript is returned.

Response

{
  text: "Smoke from hundreds of wildfires in Canada is triggering air quality alerts throughout the US. Skylines from Maine to Maryland to Minnesota are gray and smoggy. And in some places, the air quality warnings include the warning to stay inside. We wanted to better understand what's happening here and why, so we called ##### #######, an ######### ######### in the ########## ## ############# ###### ### ########### at ##### ####### ##########. Good morning, #########. Good morning. So what is it about the conditions right now that have caused this round of wildfires to affect so many people so far away? Well, there's a couple of things. The season has been pretty dry already, and then the fact that we're getting hit in the US. Is because there's a couple of weather systems that are essentially channeling the smoke from those Canadian wildfires through Pennsylvania into the Mid Atlantic and the Northeast and kind of just dropping the smoke there. So what is it in this haze that makes it harmful? And I'm assuming it is is it is the levels outside right now in Baltimore are considered unhealthy. And most of that is due to what's called particulate matter, which are tiny particles, microscopic smaller than the width of your hair, that can get into your lungs and impact your respiratory system, your cardiovascular system, and even your neurological your brain. What makes this particularly harmful? Is it the volume of particulate? Is it something in particular? What is it exactly? Can you just drill down on that a little bit more? Yeah. So the concentration of particulate matter I was looking at some of the monitors that we have was reaching levels of what are, in ####### speak, 150 micrograms per meter cubed, which is more than ten times what the annual average should be, and about four times higher than what you're supposed to have on a 24 hours average. And so the concentrations of these particles in the air are just much, much higher than we typically see. And exposure to those high levels can lead to a host of health problems. And who is most vulnerable? I noticed that in New York City, for example, they're canceling outdoor activities, and so here it is in the early days of summer, and they have to keep all the kids inside. So who tends to be vulnerable in a situation like this? It's the youngest. So children, obviously, whose bodies are still developing. The elderly who know their bodies are more in decline, and they're more susceptible to the health impacts of breathing, the poor air quality. And then people who have preexisting health conditions, people with respiratory conditions or heart conditions can be triggered by high levels of air pollution. Could this get worse? That's a good in some areas, it's much worse than others. And it just depends on kind of where the smoke is concentrated. I think New York has some of the higher concentrations right now, but that's going to change as that air moves away from the New York area. But over the course of the next few days, we will see different areas being hit at different times with the highest concentrations. I was going to ask you, more fires start burning, I don't expect the concentrations to go up too much higher. I was going to ask you and you started to answer this, but how much longer could this last? Or forgive me if I'm asking you to speculate, but what do you think? Well, I think the fires are going to burn for a little bit longer, but the key for us in the US. Is the weather system changing. And so right now, it's kind of the weather systems that are pulling that air into our mid Atlantic and Northeast region. As those weather systems change and shift, we'll see that smoke going elsewhere and not impact us in this region as much. And so I think that's going to be the defining factor. And I think the next couple of days we're going to see a shift in that weather pattern and start to push the smoke away from where we are. And finally, with the impacts of climate change, we are seeing more wildfires. Will we be seeing more of these kinds of wide ranging air quality consequences or circumstances? I mean, that is one of the predictions for climate change. Looking into the future, the fire season is starting earlier and lasting longer and we're seeing more frequent fires. So, yeah, this is probably something that we'll be seeing more frequently. This tends to be much more of an issue in the Western US. So the Eastern US getting hit right now is a little bit new. But yeah, I think with climate change moving forward, this is something that is going to happen more frequently. That's ##### #######, ######### ######### in the ########## ## ############# ###### ### ########### at ##### ####### ##########. ######## #####, thanks so much for joining us and sharing this expertise with us. Thank you for having me.",
}
KeyTypeDescription
textstringTranscript with redacted PII.
The response also includes the request parameters used to generate the transcript.

Request for Redacted Audio

In the request URL, replace transcript_id with the ID of the transcript where redact_pii_audio is set to true.
curl https://api.assemblyai.com/v2/transcript/transcript_id/redacted-audio \
--header "Authorization: <YOUR_API_KEY>"

Response for Redacted Audio

{
  status: "redacted_audio_ready",
  redacted_audio_url:
    "https://s3.us-west-2.amazonaws.com/api.assembly.ai.usw2/redacted-audio/785efd9e-0e20-45e1-967b-3db17770ed9f.wav?AWSAccessKeyId=aws-access-key0id&Signature=signature&x-amz-security-token=security-token&Expires=1698966551",
}
KeyTypeDescription
statusstringThe status of the redacted audio.
redacted_audio_urlstringThe URL of the redacted audio file.

PII policies

Policy nameDescriptionExample
account_numberCustomer account or membership identification numberPolicy No. 10042992; Member ID: HZ-5235-001
banking_informationBanking information, including account and routing numbers
blood_typeBlood typeO-, AB positive
credit_card_cvvCredit card verification codeCVV: 080
credit_card_expirationExpiration date of a credit card
credit_card_numberCredit card number
dateSpecific calendar dateDecember 18
date_intervalBroader time periods, including date ranges, months, seasons, years, and decades2020-2021, 5-9 May, January 1984
date_of_birthDate of birthDate of Birth: March 7, 1961
drivers_licenseDriver’s license numberDL# 356933-540
drugMedications, vitamins, or supplementsAdvil, Acetaminophen, Panadol
durationMeasurements of time expressed as a numerical value plus a unit8 months, 2 years
email_addressEmail addresssupport@assemblyai.com
eventName of an event or holidayOlympics, Yom Kippur
filenameNames of computer files, including the extension or filepathTaxes/2012/brad-tax-returns.pdf
gender_sexualityTerms indicating gender identity or sexual orientation, including slang termsfemale, bisexual, trans
healthcare_numberHealthcare numbers and health plan beneficiary numbersPolicy No.: 5584-486-674-YM
injuryBodily injuryI broke my arm, I have a sprained wrist
ip_addressInternet IP address, including IPv4 and IPv6 formats192.168.0.1
languageName of a natural languageSpanish, French
locationAny Location reference including mailing address, postal code, city, state, province, country, or coordinates.Lake Victoria, 145 Windsor St., 90210
marital_statusTerms indicating marital statusSingle, common-law, ex-wife, married
medical_conditionName of a medical condition, disease, syndrome, deficit, or disorderchronic fatigue syndrome, arrhythmia, depression
medical_processMedical process, including treatments, procedures, and testsheart surgery, CT scan
money_amountName and/or amount of currency15 pesos, $94.50
nationalityTerms indicating nationality, ethnicity, or raceAmerican, Asian, Caucasian
number_sequenceNumerical PII (including alphanumeric strings) that doesn’t fall under other categories
occupationJob title or professionprofessor, actors, engineer, CPA
organizationName of an organizationCNN, McDonalds, University of Alaska, Northwest General Hospital
passport_numberPassport numbers, issued by any countryPA4568332, NU3C6L86S12
passwordAccount passwords, PINs, access keys, or verification answers27%alfalfa, temp1234, My mother’s maiden name is Smith
person_ageNumber associated with an age27, 75
person_nameName of a personBob, Doug Jones, Dr. Kay Martinez, MD
phone_numberTelephone or fax number
physical_attributeDistinctive bodily attributes, including raceI’m 190cm tall
political_affiliationTerms referring to a political party, movement, or ideologyRepublican, Liberal
religionTerms indicating religious affiliationHindu, Catholic
statisticsMedical statistics18%, 18 percent
timeExpressions indicating clock times19:37:28, 10pm EST
urlInternet addresseshttps://www.assemblyai.com/
us_social_security_numberSocial Security Number or equivalent
usernameUsernames, login names, or handles@AssemblyAI
vehicle_idVehicle identification numbers (VINs), vehicle serial numbers, and license plate numbers5FNRL38918B111818, BIF7547
zodiac_signNames of Zodiac signsAries, Taurus

Troubleshooting

Make sure that at least one PII policy has been specified in your request, using the redact_pii_policies parameter. If you’re still experiencing issues, please reach out to our support team for assistance.
There could be several reasons why your webhook isn’t being sent, such as a misconfigured URL, an unreachable endpoint, or an issue with the authentication headers. Double-check your request and ensure that the webhook_url parameter is included with a valid URL that can be reached by AssemblyAI’s API. If you’re using custom authentication headers, ensure that the webhook_auth_header_name and webhook_auth_header_value parameters are included and are correct. If you’re still having issues, please contact our support team for assistance.
By default, the API returns redacted audio files in MP3 format, a lossy format. Lossy formats remove audio information to reduce file size, which may cause a reduction in quality. The difference may be particularly noticeable if the submitted audio is in a lossless file format. To retain as much quality as possible, you can instead return your redacted audio files in a lossless format, by setting redact_pii_audio_quality to wav.