August 2026 · Quota watch series

How to Detect When an API Key Expires or Silently Fails

The answer: make one small authenticated call with the key on a schedule, against the vendor’s cheapest endpoint, and classify the response instead of just checking for “not 200”. A 401 or 403 means the key itself is dead. A 429 or an empty usage counter means the key is fine but the budget behind it is gone. Anything else that answers but no longer looks like the response you expect is its own alarm. You need the scheduled call because nothing else will tell you: vendors email an expiry notice to whoever created the key, if they send one at all, and most application code swallows auth errors inside retry loops until someone asks why yesterday’s data is missing.

Why a dead key never announces itself

An expired key does not throw an alarm anywhere you look. The job that used it often exits green: the HTTP client retried, got 401 three times, logged a warning nobody reads, and returned an empty result that the rest of the pipeline happily processed. Dashboards render yesterday’s cache. The one email the vendor sent went to the inbox of a person who set the key up two teams ago. By the time the failure is visible, it is visible as missing data, and you are debugging the pipeline instead of rotating a credential.

The manual route: a canary call and a response you actually read

Choose a low-cost authenticated endpoint that reflects the access your application actually needs. Consult that service’s documentation for its authentication, usage limits and error responses. A successful authentication check alone does not prove there is usable quota or useful data.

Keep the expected response explicit. Distinguish revoked access, exhausted budget, temporary throttling and a response that no longer matches your expectations. Status codes can overlap between these cases, so follow the service’s documented response semantics rather than guessing from the status alone.

The mistake in most homemade checkers: collapsing everything into “up” or “down”. A key check has at least four distinct outcomes: the key is dead (401, and on some vendors 403), the budget is exhausted, you are temporarily rate limited, or the response no longer has the fields your parser expects. A checker that pages you to rotate a healthy key on a rate-limit blip trains you to ignore it, and one that reports “up” on an empty quota misses the exact failure you built it for. Interpret access and usage evidence together, and retain enough context to explain the verdict.

Wrap those calls in a daily cron job that posts anything other than a clean pass to the channel where your incidents live, and you have a working manual monitor for one or two keys.

The automated route: configured checks on a schedule

Datasource Pulse provides configured credential checks and HTTP checks at $0.02 per check, with no subscription. A check run daily is about $0.61 a month. This keyless HTTP example is a setup smoke test, not an authenticated quota check:

{ "type": "credential", "id": "public-endpoint", "label": "Public endpoint availability", "vendor": "generic_http", "url": "https://example.com", "successStatusCode": 200 }

The four outcomes above come back as stable verdict strings: a dead or revoked key is state: failing with dead_token, an empty budget is quota_exhausted, a temporary throttle is rate_limited, and a response that stopped matching the vendor’s own schema is unexpected_response. Alerts fire on state transitions, not on every run, so a key that is down for six hours produces one alert and one recovery notice when it comes back, not seventy identical pages. One honest scope note: this is a dead man’s switch. It fires when a key stops working, not days before a dated expiry. Where a service offers an advance expiration signal, read that too; for services that expire keys with no date and no warning, the switch is all there is.

Which route should you take?

For one key at one service, a small scheduled check may be enough. The automated route earns its keep when the key count grows: five keys across three vendors means five response formats, five sets of edge cases like the 403 and 429 ambiguities above, and a recovery-notice problem your one-shot script does not solve. One daily run covering every credential, with the same verdict strings across vendors, is the point where buying beats building.

Whichever route you take, trip the alarm once on purpose: run a check with a scrambled key, watch dead_token land where you expect it, then put the real key back. An alert you have never seen fire is a guess, not a monitor.

Datasource Pulse watches the data sources your product depends on, starting with output drift and silent failures despite green run status. Additional checks cover access, available quota and HTTP availability, with timestamped health results.