Back to changelog

Key Expiry Policies and Rolling from the API

Owners and admins can require every API key in the organization to expire within a set number of days. The master API, on Enterprise, can now set a key's expiry and roll its secret, so rotation runs from your own backend. The maximum key lifetime is part of Enterprise access control.

A glowing key turning inside a circular arrow on a circuit board chip, surrounded by an hourglass, a calendar, a shield and a padlock on small pedestals

A key that never expires is a key nobody rotates. Security reviews ask for a maximum lifetime, and until now that rule lived in a wiki page. Organizations can now enforce a maximum API key lifetime, and the master API can set expiry dates and roll secrets.

Maximum Key Lifetime

Set a limit of 1 to 3650 days under Settings → Policies → Maximum API Key Lifetime, or with maxApiKeyLifetimeDays on PATCH /orgs/{id}. While a limit of N days is set:

  • New keys must expire within N days. A later expiry is rejected with 400, and requests that omit one, from the CLI or the master API, default to N days.
  • An expiry cannot be removed or moved more than N days into the future.
  • Reactivating a key needs an expiry at most N days away.
  • Rolling a key keeps its current expiry.

Existing keys are not disabled when you set or lower the limit. A key that outlives it is flagged Exceeds max lifetime on the API Keys page, and the Policies page shows how many active keys are affected, so you can fix them on your own schedule. Every change is recorded in the audit log as organization.api_key_lifetime.update.

The auto-managed Lounge key is exempt from the limit. The maximum key lifetime is part of the Enterprise access control feature.

Expiry and Rolling in the Master API

With a master key, on the Enterprise plan, POST /v1/master/keys and PATCH /v1/master/keys/{id} accept expiresAt (ISO 8601), and a new endpoint replaces a key's secret in place:

1curl -X POST https://internal.llmgateway.io/v1/master/keys/$KEY_ID/roll \2  -H "Authorization: Bearer $MASTER_KEY"

The response carries the new token once. The old secret stops working immediately, with 401, while the key's name, limits, usage history, IAM rules, compliance policy and expiry stay as they were. Rolls are recorded as api_key.roll. Rolling also drops the credentials stored for the key's pending batches, so let active batches finish before a scheduled roll. Rolling keeps the expiry, so extend it with PATCH when a key is close to expiring. Rolling from the dashboard works on every plan.

You want to Use
Give a CI job a key for one day expiresAt on POST /v1/master/keys
Cut off a leaked secret, keep stats POST /v1/master/keys/{id}/roll
Make every key in the org expire Settings → Policies → Maximum API Key Lifetime

API key docs → | Master API docs →