# Key rotation and expiry API keys are meant to be rotated, not held forever. This guide covers how expiry works and the overlap-window pattern for rotating without downtime. ## Expiry defaults - **Lifetime:** every key issued from the portal lasts **90 days** from creation. You can't choose a different lifetime. - **Expiry date:** the portal's app page lists each key with its expiry date, and marks a key **Expired** once it has passed. The platform does not send expiry reminders, so record the date when you issue a key and alert yourself well before it — two weeks' notice is a sensible lead time. - **Maximum active keys per app:** 5. You'll always have room to run an overlap window; you won't accidentally rotate a key without cleaning up the old ones. Once a key expires, the API returns `401 API key has expired` on every request that uses it. There is no grace period on an already-expired key — regenerate first. ## The overlap-window pattern The point of rotation is to swap a credential without dropping a single request. The pattern: 1. **Generate a new key** in the portal (the existing key stays valid). 2. **Deploy** the new key alongside the old one — your integration reads whichever the config specifies. Some teams add a bit of config that tries the new key and falls back to the old; others rotate atomically by updating a single environment variable. 3. **Wait for propagation** — depending on your fleet, minutes to hours. The old key is still valid throughout. 4. **Revoke the old key** in the portal. The old key stays valid until you revoke it or it expires — the platform does not revoke it for you or remind you. Revoke it as soon as the new key is live everywhere; aim for within 24 hours, so you never have two working credentials for longer than the switch-over needs. ## Revocation is immediate When you revoke a key in the portal, the next request that uses it is rejected. There's no CDN cache, no async propagation delay. If you revoke a key you're still using in production, expect immediate `401`s. ## What happens on expiry - Requests using the key get `401 API key has expired`. - The key does **not** auto-renew. You must generate a new one — the existing key is inert. - Other keys on the same app are unaffected. - Webhook deliveries continue — webhook signing uses the subscription's signing secret, not the app's API key. ## Tracking expiry There is no public API endpoint for listing your keys or their expiry dates — check them on the portal's app page. If you want automated alerting, store each key's expiry date alongside the key in your secret store when you issue it, and alert from there. ## Runnable example — rotate without downtime ```bash # 1. Read the current key from your secret store (whatever your team uses) OLD_KEY=$(vault kv get -field=api-key secret/gallantree) # 2. Generate NEW_KEY in the portal, copy it into your secret store vault kv put secret/gallantree api-key="$NEW_KEY" # 3. Deploy — depending on your rollout style, this may be a rolling restart kubectl rollout restart deployment/gallantree-sync # 4. Verify the new key is live everywhere by tailing your logs for the prefix kubectl logs -l app=gallantree-sync | grep "$(echo "$NEW_KEY" | cut -c1-12)" # 5. Revoke the old key in the portal ```