← All articles

How to Track API Key Expiry: A Step-by-Step Guide

How to Track API Key Expiry: A Step-by-Step Guide

Table of Contents

Why Tracking API Key Expiry Matters

API keys are the backbone of service-to-service authentication, yet unlike user passwords they often sit in configuration files, environment variables, and CI/CD pipelines for months or years without review. When one expires without warning, every service depending on it stops working.

A key created for one integration can outlive its original owner. When that person moves on, the next team needs a shared record of the provider, owner, deadline and dependent services to plan a replacement.

Expiry tracking forces a deliberate conversation: Who owns this credential? When does it expire? What depends on it? How will we rotate it without breaking the application? These questions sound basic but are rarely answered until something breaks.

Set Up Your API Key Inventory Template

A credential inventory is the foundation of expiry tracking. It's a structured list of every API key, service account, and integration credential your teams use, along with metadata about each one. The inventory itself doesn't store secret values, it stores only the information needed to manage the credential's lifecycle.

Comparison matrix for API key inventory to track API key expiry, status, rotation dates, and owner metadata fields.
Comparison matrix for API key inventory to track API key expiry, status, rotation dates, and owner metadata fields.

If you're starting from scratch, a free credential inventory template can help you structure the essential fields and get your first entries recorded quickly.

Essential metadata fields for tracking

Start with these core fields in your inventory. Each field serves a specific purpose in the rotation and expiry workflow.

Key Name identifies the credential in human-readable form. Use a convention that includes service, environment, and purpose: stripe-prod-api-key, github-actions-ci-token, datadog-metrics-ingestion.

Owner is the person responsible for rotating the key and responding to expiry alerts. This is not optional: unowned credentials expire silently.

Backup Owner covers vacation, illness, or turnover, so someone can rotate the key and verify success while the primary owner is unreachable.

Expiry Date is the date the key stops working. Record it in ISO 8601 format (YYYY-MM-DD).

Last Confirmed Rotation records completed work. Keep a planned rotation date separate so scheduling a task does not imply that the key has already been replaced.

Provider records where the credential lives (AWS, GitHub, Stripe, Datadog).

Status tracks whether the key is active, expired, or revoked.

Reminder Lead Time specifies how many days before expiry you want to be notified.

The table below is a fictional, extended spreadsheet example. Backup owner, status and reminder lead time are suggested working-sheet fields; they are not columns in KeyGuardRail’s CSV importer. For import, map the supported values into the nine-column download and keep additional context in an authorized runbook.

Key Name Owner Backup Owner Provider Expiry Date Rotation Date Status Reminder Lead Time
stripe-prod-api-key alice@company.com bob@company.com Stripe 2027-03-15 2026-03-15 Active 30
github-actions-ci devops-team-lead@company.com platform-engineer@company.com GitHub 2027-02-28 2026-02-28 Active 14
datadog-metrics monitoring@company.com sre-backup@company.com Datadog 2027-01-20 2026-01-20 Active 21
old-api-key-prod (none) (none) AWS 2026-05-10 2024-05-10 Revoked ,

Assigning owners and backup owners

Ownership is the linchpin of expiry tracking. A key with no owner expires unnoticed; a key whose owner leaves becomes someone else's problem at the worst possible time.

Assign owners based on who created the credential or uses it most directly. If the payments team maintains the Stripe integration, the payments team lead owns the Stripe key; the DevOps engineer managing a CI/CD pipeline owns its GitHub token.

Backup owners prevent single points of failure. They should understand the credential's purpose and know how to rotate it. A backup on a different team or time zone is often a good choice for coverage.

Review ownership quarterly. When someone leaves, transfer their credentials before they depart; when teams restructure, update owners. Stale ownership data means alerts go to people who can't act on them.

Distinguish Between Expiry Dates and Rotation Schedules

Many teams conflate expiry and rotation, but they're different concepts.

An expiry date is when the provider stops accepting the credential. After it, the key no longer works: services fail, requests are rejected, and alerts fire.

A rotation schedule is how often you proactively replace a credential before it expires. You might rotate every 90 days even though the provider allows a year. Rotation is a security and operational practice; expiry is a technical limit.

Calculate the policy deadline from the last confirmed rotation plus the chosen interval, then use the earlier of that date and provider expiry. For example, a key last rotated on 2027-01-01 with a 90-day policy is due on 2027-04-01. If the provider expires it on 2027-03-15, March 15 is the earlier deadline. Plan and test the replacement before that deadline; the rotation interval is not an amount to subtract from expiry.

Some credentials have no scheduled provider expiry. Long-term AWS IAM user access keys can be deactivated or deleted; temporary credentials have their own expiry. Record any team rotation deadline separately and leave provider expiry blank when none exists. See AWS access-key management.

Record provider expiry, last confirmed rotation and the policy interval separately. Missing expiry information requires a provider check; a missing rotation baseline requires investigation before calculating a policy deadline. A reminder or planned task is not completion evidence.

Create an API Key Rotation Schedule

A rotation schedule is a repeating plan for replacing credentials. It prevents keys from aging indefinitely and reduces the window of exposure if a key is compromised.

Planning rotation windows and dependencies

Identify every consumer of the key, such as a billing service, refund worker and accounting integration. Keep credential types separate: Stripe webhook signing secrets differ from API keys. Confirm the actual dependency and follow the provider’s key-management procedure.

Map these dependencies explicitly: for each key, list the services that use it, then identify the rotation window when you can safely replace it without breaking them.

A rotation window typically spans a few hours to a full business day: generate a new key, update all dependent services, verify they work with the new key, then revoke the old one. Keep it long enough for updates and testing, short enough that you're not running two keys for weeks.

Schedule rotations during business hours when your team can monitor for failures. Rotating a critical key at midnight on Friday invites a weekend outage.

For keys with many dependencies, coordinate across teams: block time, notify stakeholders, and ensure someone is on call to troubleshoot if rotation fails.

Safe rotation with overlap and rollback

For routine replacement, check whether the provider supports overlapping keys and whether the old key is still valid and safe to use. Where overlap is supported, migrate and verify consumers before retiring the old key. Suspected compromise needs incident containment rather than a routine waiting period.

The typical overlap procedure works like this:

  1. Generate a new key in the provider
  2. Deploy the new key to all dependent services (in configuration, environment variables, or secrets stores)
  3. Verify that services are working with the new key (check logs, metrics, or test requests)
  4. Verify each identified consumer on the replacement key, including scheduled jobs, using logs and representative operations without exposing secret values
  5. Revoke the old key
  6. Monitor for any failures that indicate a service still using the old key

Choose a bounded verification window based on the provider’s limits and the consumers’ execution schedules. Elapsed time alone does not establish that every application uses the replacement. Record who verified which operations.

Document recovery before the cutover. Reusing the old key is an option only while it remains valid, has not been compromised, and the provider supports that recovery path. A deleted or expired key may be unrecoverable; otherwise fix the consumer or issue another replacement.

Investigate unknown dependencies through configuration, owners and usage evidence before routine retirement. Set an owner and review deadline for unresolved consumers. Do not extend an exposed key’s lifetime to make migration easier.

Record the rotation and any issues in your audit trail: old key ID, new key ID, rotation date, and rollback actions. This history helps troubleshoot future rotations and documents your key management practices.

Set Up API Key Expiration Reminders

Reminders are the operational trigger for rotation. Without them, expiry dates are just spreadsheet cells no one checks.

Choosing reminder lead times

A reminder lead time is how many days before expiry you want to be notified. The right value depends on the key's criticality, rotation complexity, and your team's response time.

For non-critical keys (development, staging, low-traffic services), a 14-day reminder is often sufficient; missing it limits impact to a dev or staging environment.

For critical keys (production API keys, database credentials, payment processors), a 30-day reminder is more prudent: production rotations involve multiple services, testing, and coordination, and 30 days lets you plan, schedule, and execute without rushing.

For keys with many dependencies or complex rollback procedures, consider 45 or even 60 days, trading more advance notice for the overhead of longer reminder periods.

Set different lead times by category: production 30 days, staging 14, development 7. This tiering focuses attention on what matters most.

Handling keys with unknown expiry dates

Some keys have no clear expiry date: old credentials created before you tracked expiry, or keys from providers that don't enforce expiration.

Distinguish “expiry not yet verified” from “provider does not impose expiry.” Assign an owner to check the provider and document the result. Keep a planned review or rotation date separate from provider expiry.

Choose a rotation interval from the credential’s risk, provider guidance and your requirements. If the last confirmed rotation is unknown, do not invent a baseline. Schedule investigation or replacement and record completion when it occurs.

Before retiring an apparently unused key, identify dependencies and check the available usage evidence. Lack of a known owner or recent activity does not prove a scheduled job is gone. Use an approved retirement plan; handle suspected exposure through incident response.

An unknown expiry date cannot support an expiry countdown. Set a dated follow-up to resolve the uncertainty, and coordinate any planned replacement with the owner.

API Key Management Best Practices

Expiry tracking is part of a broader credential lifecycle practice. These habits make it more effective.

Review cadence and verification

Schedule a monthly or quarterly inventory review and verify that:

  • All active keys are still in use
  • Ownership assignments are current
  • Expiry dates and rotation schedules are accurate
  • Revoked keys are removed from active use

A 15-minute quarterly review is far cheaper than troubleshooting an unexpected key expiry in production.

Spot-check a few keys in their source systems: log into Stripe, GitHub, or AWS and confirm the recorded keys exist and match your inventory. This catches keys revoked or replaced without updating your tracking.

Tracking rotation completion and audit history

Record every rotation: the date, the old key ID (or a hash, never the full value), the new key ID, affected services, and any issues.

An audit trail serves two purposes: it shows you're actively managing credentials, and it helps troubleshoot future rotations by showing what worked and what didn't.

KeyGuardRail records ownership, lifecycle dates and audit history. Your team or supported integration supplies completion information; retain consumer checks and provider evidence in the authorized runbook or ticket. A recorded date alone does not independently verify every dependent application.

Common Mistakes to Avoid

Treating expiry dates as optional. Many teams set expiry dates but don't treat them as hard deadlines, rotating "when they get around to it," which often means never.

Assigning an owner without a response path. A person or team can own a credential, but the record must lead to someone who receives reminders and can coordinate the work.

Ignoring keys with unknown dependencies. A key might be used by a service you don't maintain, a third-party integration, a legacy system, or another team's service.

Assuming overlap is always available. Check the provider and credential type. Use a tested overlap where supported, or plan a controlled cutover with verification and recovery.

Not documenting rotation procedures. Each provider has different mechanics: AWS access keys rotate differently than Stripe API keys. Document the procedure per key type so rotations are consistent and repeatable.

Forgetting to revoke old keys. Revoke the old key promptly once the new one is confirmed working.

Frequently Asked Questions

What is the difference between an API key's expiry date and rotation date?

Provider expiry is when the provider stops accepting a credential. The last confirmed rotation records completed replacement; a planned rotation date records future work. Calculate the policy deadline from the confirmed rotation plus the interval, and plan completion before the earlier of that deadline and provider expiry.

How far in advance should I set an API key expiry reminder?

Set reminders at least 2-4 weeks before expiry to allow time for rotation and application updates. For critical services, send a first reminder 6 weeks out and a second at 2 weeks. For less critical keys, 2 weeks is usually sufficient. Adjust based on your team's deployment frequency and testing cycles.

What should I do if an API key's expiry date is unknown?

Check the provider’s documented behavior and current configuration. Keep an unverified expiry distinct from a credential with no scheduled expiry. Assign an owner and a follow-up date, choose an appropriate rotation policy, and retain a confirmed rotation baseline. Do not put an invented policy date into the provider-expiry field.

How can I verify that an API key was rotated successfully?

After rotation, test authentication with the new key in a non-production environment first. Monitor the old key's usage to confirm applications have switched over. Check your audit trail for the rotation event and timestamp. Once confirmed, revoke the old key and document the completion in your inventory.