Introduction
Generative AI creates human-like content that must align with organizational standards and safety guidelines. Amazon Bedrock Guardrails helps organizations implement customized safeguards for their AI applications by filtering harmful content, blocking denied topics, and removing sensitive information.
The ApplyGuardrail API enables content validation without invoking foundation models. This API offers three key benefits.
- Evaluate text against your defined rules, including topic avoidance, content filters, and PII detection
- Validate data at any point in your application flow, from user input to final output
- Assess content without calling foundation models, giving you control over your application's security workflow
In this article, you will learn how to use the Amazon Bedrock ApplyGuardrail API to enforce responsible API behaviour by detecting and masking sensitive information like names, addresses, emails, and more, directly in your application inputs.
Guardrail Configuration JSON
{
"name": "test_guardrail_vijai_test",
"guardrailId": "xxxx0xx9x6xx",
"guardrailArn": "arn:aws:bedrock:us-east-1:11111111111:guardrail/xxxx0xx9x6xx",
"version": "DRAFT",
"status": "READY",
"contentPolicy": {
"filters": [
{
"type": "VIOLENCE",
"inputStrength": "HIGH",
"outputStrength": "HIGH",
"inputAction": "BLOCK",
"outputAction": "BLOCK"
},
{
"type": "PROMPT_ATTACK",
"inputStrength": "HIGH",
"outputStrength": "NONE",
"inputAction": "BLOCK"
},
{
"type": "MISCONDUCT",
"inputStrength": "HIGH",
"outputStrength": "HIGH",
"inputAction": "BLOCK",
"outputAction": "BLOCK"
},
{
"type": "HATE",
"inputStrength": "HIGH",
"outputStrength": "HIGH",
"inputAction": "BLOCK",
"outputAction": "BLOCK"
},
{
"type": "SEXUAL",
"inputStrength": "HIGH",
"outputStrength": "HIGH",
"inputAction": "BLOCK",
"outputAction": "BLOCK"
},
{
"type": "INSULTS",
"inputStrength": "HIGH",
"outputStrength": "HIGH",
"inputAction": "BLOCK",
"outputAction": "BLOCK"
}
]
},
"sensitiveInformationPolicy": {
"piiEntities": [
{
"type": "NAME",
"action": "BLOCK",
"inputAction": "ANONYMIZE",
"outputAction": "ANONYMIZE",
"inputEnabled": true,
"outputEnabled": true
},
{
"type": "EMAIL",
"action": "BLOCK",
"inputAction": "ANONYMIZE",
"outputAction": "ANONYMIZE",
"inputEnabled": true,
"outputEnabled": true
},
{
"type": "CREDIT_DEBIT_CARD_NUMBER",
"action": "BLOCK",
"inputAction": "ANONYMIZE",
"outputAction": "ANONYMIZE",
"inputEnabled": true,
"outputEnabled": true
},
{
"type": "ADDRESS",
"action": "BLOCK",
"inputAction": "ANONYMIZE",
"outputAction": "ANONYMIZE",
"inputEnabled": true,
"outputEnabled": true
},
{
"type": "PASSWORD",
"action": "BLOCK",
"inputAction": "BLOCK",
"outputAction": "BLOCK",
"inputEnabled": true,
"outputEnabled": true
}
],
"regexes": []
},
"createdAt": "2025-06-17T15:13:12.089441+00:00",
"updatedAt": "2025-06-17T15:19:59.408396+00:00",
"statusReasons": [],
"failureRecommendations": [],
"blockedInputMessaging": "Sorry, the model cannot answer this question.",
"blockedOutputsMessaging": "Sorry, the model cannot answer this question."
}
Join the conversation! Your thoughts help the community grow.