Configure API Key Expiration
By default, Guardrails API access keys never expire. This means a departed employee's keys continue to work indefinitely, a significant security risk for workspaces with public-facing endpoints. The recommended approach is to expire keys after a set period while excluding break glass accounts.
Prerequisites
- Access to Guardrails with
Turbot/Adminpermissions or higher. - A break glass user whose keys should not expire.
Approach
The safest way to implement key expiration is through a policy pack with a calculated policy. The calculated policy checks each key's parent user. If the user matches your break glass account, the key is skipped. Otherwise, it is set to expire.
Step 1: Set the Expiration Period
Navigate to Policies in the sidebar and click New Policy Setting in the top right to open the Create Policy Setting form.
For the Policy Type, search for Access Key Expiration Days and select Days (Turbot > IAM > Access Key > Expiration > Days).

For the Resource, select Turbot (the workspace root). Because this policy is an integer, the Setting is a number field. Enter the number of days until keys expire and click Create.

| Field | Description |
|---|---|
| Setting | The number of days until keys expire. Common values: 90 (quarterly rotation), 180 (semi-annual), 365 (annual). Toggle Enable calculated mode to compute the value instead. |
| Precedence | Required enforces the value on all descendants. Recommended allows exceptions. |
Step 2: Enable Expiration Enforcement
Click New Policy Setting again. For the Policy Type, search for Access Key Expiration and select Expiration (Turbot > IAM > Access Key), which is the parent of the Days policy you just set.
Select Turbot as the resource. For the value, you have two options:
Simple approach: select a standard value like Enforce: Deactivate expired with 7 day warning to apply expiration to all users uniformly.
Break glass exception: click Enable calculated mode, then Launch calculated policy builder, and use a template that skips break glass accounts:
Input Query (GraphQL):
{
key:resource {
user: parent {
email: get(path:"email")
}
}
}
Template (Nunjucks):
{%- set breakGlass = r/[email protected]/g -%}
{%- if breakGlass.test($.key.user.email) -%}
'Skip'
{%- else -%}
'Enforce: Deactivate expired with 7 day warning'
{%- endif -%}
Replace [email protected] with your break glass account's email address. Click Update to return to the form, then click Create.
Alternative: Via Terraform
You can also manage both policies as code using a policy pack:
resource "turbot_policy_pack" "breakglass_user_exceptions" {
parent = "tmod:@turbot/turbot#/"
title = "Breakglass User Exceptions"
description = "Expires API keys for all users except break glass accounts."
}
resource "turbot_policy_setting" "turbot_iam_access_key_expiration" {
resource = turbot_policy_pack.breakglass_user_exceptions.id
type = "tmod:@turbot/turbot-iam#/policy/types/accessKeyExpiration"
template_input = <<EOT
{
key:resource {
user: parent {
email: get(path:"email")
}
}
}
EOT
template = <<EOT
{%- set breakGlass = r/[email protected]/g -%}
{%- if breakGlass.test($.key.user.email) -%}
'Skip'
{%- else -%}
'Enforce: Deactivate expired with 7 day warning'
{%- endif -%}
EOT
}
resource "turbot_policy_setting" "turbot_iam_access_key_expiration_period" {
resource = turbot_policy_pack.breakglass_user_exceptions.id
type = "tmod:@turbot/turbot-iam#/policy/types/accessKeyExpirationDays"
value = "90"
}
After applying the Terraform, attach the policy pack to each directory that holds users whose keys should expire.
[!TIP] Before enabling expiration, use the "Aging Turbot Access Keys" report to see which keys will be affected. This helps you communicate the change to key holders before their access is interrupted.
[!WARNING] Always exclude break glass accounts from key expiration. If break glass API keys expire and the break glass user's password is also expired, you lose your emergency access path entirely.
Troubleshooting
| Issue | Solution |
|---|---|
| Break glass user's keys were deactivated | The calculated policy regex doesn't match the break glass email. Fix the regex and reactivate the keys manually. |
| Keys not expiring after policy is set | Verify the policy pack is attached to the correct directories. Check that the Expiration Days policy is also set. |
Next Steps
- Manage Access Keys: Create, deactivate, and delete individual access keys.
- Advanced IAM: Enterprise strategies including API auditing.