On this page
An API deprecation notice is more useful when a client can discover both the planned sunset date and the migration instructions from a response. The Sunset and Link headers can provide those two pieces of information without changing the response body.
This tutorial shows how to combine them, what to put at the linked destination, and how clients should behave when guidance is missing or unavailable.
Key Takeaways
Sunsetcommunicates when a resource is expected to become unavailable; it is not an availability guarantee until that time.- A
Linkheader with thesunsetrelation can point clients to human-readable sunset and migration information. - The headers do not, by themselves, define compatibility promises, a replacement API, or what a client must do next.
- Clients need a fallback when a link is absent, unreachable, or unsuitable for automated use.
- Apply the notice to the affected resource and keep dates, documentation, and operational communications consistent.
Give the date and guidance together
The following is an illustrative response from a fictional API. Its dates are hypothetical, not a real service commitment:
HTTP/1.1 200 OK
Content-Type: application/json
Sunset: Tue, 01 Jan 2030 00:00:00 GMT
Link: <https://api.example.com/guides/orders-v1-sunset>; rel="sunset"; type="text/html"
{"orders": []}
The Sunset value is an HTTP date. The link identifies a page about the sunset; type="text/html" describes the intended representation of that page. The response remains an ordinary successful API response: clients must still process its status and body normally.
A hypothetical rollout could work like this:
- October 2029: The provider announces that the orders v1 endpoint is deprecated and begins returning the headers.
- January 2030: The provider expects the endpoint to become unavailable at the time in
Sunset. - Before migration: Clients read the linked guide, assess compatibility, and switch to the documented replacement.
The date communicates a plan, not a promise that every request will succeed until then. Outages, security responses, contract terms, or a changed plan can affect availability. Conversely, clients should not assume the endpoint will necessarily fail at the exact stated second. Publish any availability commitments separately and update the notice if plans change.
Advertisement
Make the linked page actionable
A useful sunset page should identify the affected endpoint or API version and explain the transition without requiring the reader to infer it from the URL. Include:
- The planned sunset time, including the time zone, and the scope of the change.
- The replacement endpoint or version, if one exists, and steps for obtaining access.
- Changes to authentication, request and response schemas, errors, pagination, rate limits, and other behavior where applicable.
- Compatibility expectations: what remains supported during migration, what may change, and which commitments are contractual rather than informational.
- A migration checklist, representative request examples, and a way to obtain help.
- How changes to the plan will be communicated, including whether existing clients will receive direct notice.
If there is no replacement, say so. If different customers or resources have different dates, make the applicable scope explicit rather than publishing a single ambiguous deadline.
Keep the guide accessible to the intended audience for the migration period. If it requires authentication, tell clients how to obtain access through an established support channel. Do not include credentials or customer-specific secrets in a URL.
Publish the headers consistently
Decide which responses describe the resource being sunset and emit the notice consistently for those responses. Document whether the notice applies to an entire API version, an individual endpoint, or a narrower operation. A header on one response should not be presented as proof that unrelated resources share the same deadline.
Check the full delivery path, including gateways, proxies, and caches: an intermediary can remove headers or serve an older response after the plan changes. Consider cache behavior when changing a date or link, and verify what clients actually receive. For browser-based cross-origin clients, configure CORS to expose Sunset and Link if application code needs to read them.
Headers complement, rather than replace, direct customer communication, release notes, and contractual notices. Those channels matter especially for clients that do not inspect response headers.
Build a resilient client workflow
A client that receives Sunset should record or surface the date to an operator responsible for migration. It can also present the sunset link as guidance. Treat the linked page as documentation, not as a machine-readable migration contract unless the provider separately defines one.
When parsing headers, use an HTTP-date parser for Sunset and a Web Linking-aware parser for Link. A response can contain more than one link, and link parameters can contain quoted values; splitting the header on every comma is not a reliable general parser.
Plan for these cases:
- No link: Record the sunset notice and consult the provider's established documentation or support channel. Do not guess a migration URL.
- Link cannot be reached or requires access: Continue according to the API's normal error-handling policy, alert an operator, and seek guidance through the provider's established channel. A documentation outage does not itself tell you that the API request failed.
- No
Sunsetheader: Do not infer that the API is permanent or that no deprecation exists. Other communication channels may carry the notice. - Conflicting dates or changed guidance: Surface the conflict and confirm the applicable plan with the provider rather than silently choosing a deadline.
If software fetches documentation links automatically, treat link targets as untrusted input. A server-side fetcher needs destination and scheme restrictions, DNS and redirect revalidation, network egress controls, timeouts, and response-size limits; parsing a URL alone is not an SSRF defense.
Advertisement
Common Mistakes
- Treating
Sunsetas a deprecation announcement with a complete policy. The date does not explain the replacement, compatibility terms, or support process. - Treating the date as an uptime guarantee. State availability commitments separately and have clients handle ordinary failures.
- Publishing a link that only the API team can access. Test access from the perspective of the partner or public client that needs the instructions.
- Changing the date without coordinating caches and communications. Clients may see stale responses or an older copy of the guide.
- Assuming every client follows links automatically. Provide direct notifications and a fallback support path.
Best Practices
Test representative responses through the same gateway and cache path used by clients. Check that the date is valid, the link resolves for its intended audience, and the page matches the affected resource. Include header handling and migration readiness in client integration tests, including missing headers and unreachable documentation.
Standards verification note: This article's standards documents were not retrieved in this run. Before implementing a standards-dependent policy, consult RFC 8594 for Sunset and RFC 8288 for Web Linking, and check their current status records for updates or supersession. Exact conformance details and current status have not been verified here.
Conclusion
Use Sunset to communicate a planned end and a sunset link to explain how to respond. Make the migration guide specific, keep other notification channels working, and design clients to handle both missing guidance and ordinary service failures.
What would your domain sell for?
A free TidyURLs account unlocks the Domain Estimator. It prices a name from 191,011 real domain sales.