Back to library
AI
best practice

Secure Your AI Infrastructure with Auto-Expiring API Keys and Reminders

Automate security compliance by setting expiration dates on your Claude API keys.

Use the new Claude Console 'Expiration' feature to set auto-expiry for API keys, complemented by automated email reminders.

Claude

The Scenario

You need to comply with organizational security policies that require API keys to be rotated every quarter to minimize the impact of potential leaks.

Before & after

The old way

Security teams manually tracked API key lifetimes in spreadsheets and rotated them by hand every 90 days, spending 20 minutes per key.

With AI

Setting an expiration date via the Claude Console (specifically the `expires_at` field) takes about 30 seconds and automates the deprecation process.

The Prompt

Explain how to use the Claude Admin API to programmatically list and check the [expires_at] field for my organization's keys to identify which ones need rotation. Provide a script example.

Claude now allows setting explicit expiration dates for API and Admin keys. For keys lasting 7+ days, Anthropic sends automated email reminders before they expire.

Source

Claude Platform - Claude Platform Docs
"You can now set an expiration when you create an API key... Anthropic emails the creator before expiration."