skip to content

How do the HTTP `Deprecation` and `Sunset` response headers work, what do they carry, and how should a client and a provider each use them?

level: middleimportance: should knowfreq 40%

answer

  1. Sunset = HTTP-date it stops responding (RFC 8594)
  2. Deprecation = stop building on this (RFC 9745)
  3. Link rel=deprecation / rel=sunset for docs
  4. emit at the gateway, count per client
  5. client: log + metric + daily-deduped alert

basics

~20 s

Sunset (RFC 8594) gives an HTTP-date after which the resource becomes unresponsive; Deprecation says it is already or will be deprecated. Pair them with Link rel="sunset" or rel="deprecation" to documentation. Clients should log and alert on them.

solid answer

~50 s

Both are advisory response headers that put the lifecycle in-band, where automation can see it. **`Sunset`** (RFC 8594) carries an HTTP-date: the point after which the resource is expected to become unresponsive. Example: `Sunset: Wed, 31 Dec 2025 23:59:59 GMT`. **`Deprecation`** signals that the resource is deprecated — either already (a past date) or from a future date. It is the earlier signal; `Sunset` is the deadline. Both pair with a **`Link`** header giving machine-discoverable documentation: `Link: <https://api.example.com/docs/deprecation>; rel="deprecation"` or `rel="sunset"`. **Provider:** emit them on every response from the deprecated endpoint or version from the day of announcement, and keep the dates stable — moving a sunset date backwards destroys trust. **Client:** SDKs and gateways should log them, emit a metric, and alert once per day rather than per request, so a deprecation becomes a ticket rather than a surprise outage. They are advisory only: nothing is enforced, and email plus changelogs still matter.

code

http · 7 lines
http
HTTP/1.1 200 OK
Content-Type: application/json
Deprecation: Sun, 01 Jun 2025 00:00:00 GMT
Sunset: Wed, 31 Dec 2025 23:59:59 GMT
Link: <https://api.example.com/docs/migrate-v1-v2>; rel="sunset"

{"id":"cus_123","name":"Ada"}

go deeper

for a junior

Name both headers, say Sunset carries a date after which the endpoint stops working, and that clients should log it.

for a middle

Give the formats, the Link relations, the RFCs, and describe both provider emission and client handling.

for a senior

Emphasise gateway-level emission, per-client metrics feeding the shutoff decision, date stability, and deduplicated client alerting.

for a principal

Treat in-band signalling as one channel in a governed deprecation programme, and weigh its low adoption against the cost of out-of-band comms.

## The problem they solve Deprecation notices historically lived in blog posts, changelogs and emails to an address that left the company two years ago. The integration itself — the code actually calling you — never learns. These headers move the signal onto the wire, so the running client can see it. ## `Sunset` Defined by RFC 8594. A single HTTP-date in IMF-fixdate form: `Sunset: Wed, 31 Dec 2025 23:59:59 GMT` It means: this resource is expected to become **unresponsive** after that instant. It is a statement of intent, not a guarantee, and it is not a caching directive — it says nothing about response freshness and must not be confused with `Expires`. It can be applied to any resource: a whole API version, one endpoint, or one representation. ## `Deprecation` The companion signal, standardised as RFC 9745 after a long draft life. It marks the resource as deprecated, optionally from a stated date, which may be in the future ("will be deprecated on…") or the past ("has been deprecated since…"). Because it existed as a draft for years, deployed implementations vary in the value format — some emit a bare `true`. Interoperate defensively: treat the header's *presence* as the signal and parse the value best-effort. The two are complementary: `Deprecation` says "stop building on this", `Sunset` says "here is when it stops working". Emitting both, with a sensible gap between them, is the norm. ## `Link` relations Neither header can carry prose. Attach documentation with a `Link` header using `rel="deprecation"` or `rel="sunset"`, pointing at a page that explains what is going away, why, and how to migrate. Some providers also emit a custom `Warning`-style or vendor header carrying a human sentence, which shows up in curl output and developer consoles. ## Provider practice Emit the headers from an edge filter or gateway rather than per-controller, so coverage is uniform and no endpoint is forgotten. Start on announcement day, not a week before shutdown. Keep the date **stable or later, never earlier**: pulling a sunset date forward is the fastest way to lose the trust that makes the next deprecation cheap. Record a metric each time you emit them, tagged by client, so you know exactly who has not migrated. Keep serving the endpoint until the date, then return a clear permanent error. ## Client practice Handle them once, centrally, in the HTTP client or SDK: - log at WARN with the endpoint, the date and the `Link` target - emit a counter metric so a dashboard shows deprecated-endpoint usage over time - alert with strong deduplication — once per endpoint per day, not per request, or the signal drowns - optionally fail CI or a synthetic test when a header appears against a production dependency What a client must not do is act automatically: do not switch endpoints, and do not start failing calls before the sunset date. The header is information for humans, delivered by machines. ## Limits They are advisory. Nothing enforces them, most HTTP libraries ignore unknown response headers, and a client that never looks at headers learns nothing. They complement — never replace — email to registered integrators, changelog entries, dashboard banners and, for high-value consumers, a direct conversation.

  • How is `Sunset` different from `Expires`?
    `Expires` is a caching header describing when a stored response becomes stale; caches act on it automatically. `Sunset` is a lifecycle announcement about the resource itself — the date after which the endpoint is expected to stop responding at all. Confusing them leads to responses that are cached wrongly or deprecations that no human ever sees.
  • Should a client automatically stop calling an endpoint once it sees a `Sunset` header?
    No. The header is advisory and the endpoint is still expected to work until the stated date, so self-disabling causes an outage the provider did not ask for. The correct behaviour is to log, count, and raise an alert or ticket so a human plans the migration before the deadline.

saying these in an interview costs you the question

  • Treating `Sunset` as a caching directive similar to `Expires`
  • Moving a published sunset date earlier when the shutdown schedule slips forward
  • Emitting the headers only in the final days before shutdown
  • Assuming headers alone constitute notice, with no email, changelog or dashboard communication
  • Alerting on every response carrying the headers, which floods logs and gets the alert muted

context