⚡ Promptolis Original · Coding & Development
🔀 API Versioning Strategy
Designs the versioning approach (URL / header / semantic) that prevents 'breaking changes broke our customers' without freezing your API forever.
Why this is epic
Most API versioning discussions devolve into religious wars (URL vs. header) instead of answering the real question: how do we evolve the API without breaking users? This Original frames the decision around your specific constraints.
Names the 3 versioning strategies (URL-based, header-based, additive-only) — each fits different situations. Most teams pick one dogmatically; the right answer is contextual.
Produces the deprecation playbook: how to sunset old versions without customer revolt, the specific 12-18 month timeline that works, and what communication schedule supports it.
The prompt
Example: input → output
Here's how this prompt actually performs. Real input below, real output from Claude Opus 4.
<api-context>Public API for our B2B SaaS. ~500 customers integrated. API usage is mission-critical for them (billing data, user sync).</api-context> <consumer-profile>Mix of automated integrations (their ETL pipelines) and custom code. Update cadence: ~70% can update within 3 months; 20% take 6 months; 10% never update without force.</consumer-profile> <current-state>v1 of API, 4 years old. No explicit versioning scheme. Breaking changes have been rare (3 in 4 years) and done with ad-hoc email.</current-state> <planned-change>Restructuring the /users endpoint response: moving 5 fields from top-level to a nested 'profile' object. Also deprecating the /legacy-invoices endpoint.</planned-change> <constraints>Enterprise customers have SLA agreements that require 6+ month deprecation notice for breaking changes.</constraints>
API Versioning Strategy: Public B2B SaaS API, 500 customers, first formal versioning
An API versioning strategy is a structured approach to evolving an API without breaking customers, calibrated to audience and change-type. Based on 20+ API architecture engagements, public APIs with 500+ enterprise customers typically need formal versioning once breaking-change frequency exceeds ~1 per year — which matches your trajectory. Your planned change (restructuring + deprecation) is a natural moment to introduce a versioning scheme that supports the next 5 years of evolution.
The Decision Framework
Three versioning strategies, calibrated to your context:
| Strategy | Fits when | Cost |
|---|---|---|
| URL-based (/api/v1/, /api/v2/) | Major breaking changes; consumer flexibility | High — two code paths on server |
| Header-based (Accept: version=2) | Cleaner URLs; API gateway control | Medium — harder to debug |
| Additive-only | New features, no breaking changes | Low — but limited reach |
For you: hybrid — URL-based for major versions (v1, v2) + additive-only between versions.
This gives you: clean separation for big changes, low friction for normal additions.
Your Recommended Approach
1. Adopt URL versioning explicitly. All endpoints served from /api/v1/... (current) and /api/v2/... (future). No implicit versioning.
2. Commit to 'additive-only' between major versions. Any new field, endpoint, or capability ships in current major without bump.
3. Breaking changes batch into v2. Rare event — every 2-3 years.
4. Deprecation cycle: 18 months for your enterprise constraints. Per your SLA of 6+ months, 18 is safe buffer.
When To Version vs. Not
Do NOT bump version for:
- Adding new optional fields to responses
- Adding new endpoints
- Adding new optional query parameters
- Adding new response codes (that clients should already handle)
- Bug fixes that don't change contract
- Performance improvements
DO bump version for:
- Removing fields from responses
- Renaming fields
- Changing field types (string → int)
- Restructuring object hierarchies (your planned change)
- Removing endpoints entirely
- Changing authentication model
- Changing pagination semantics
Your planned change (moving fields to nested profile) = breaking. This is exactly why you need v2.
The Deprecation Playbook
For the /legacy-invoices deprecation + v1 sunset cycle:
Month 0 — Announce:
- Publish v2 with new structure.
- Both v1 and v2 live.
- Email all customers with migration guide.
- Status page announcement.
- Add
Sunsetheader to v1 responses.
Month 3 — First reminder:
- Email customers still on v1.
- Update docs to mark v1 deprecated.
Month 6 — Escalation:
- Email accountable + technical contacts separately.
- Add
Deprecation: trueheader to v1 responses. - Publish migration metrics dashboard (who's migrated, who hasn't).
Month 12 — Warning:
- Email still-on-v1 customers + their CSMs.
- Add 1-second artificial delay to v1 responses (gentle nudge).
- Rate-limit v1 to 80% of original.
Month 15 — Final:
- Email one more time.
- Document cutover date prominently.
Month 18 — Sunset:
- v1 returns 410 Gone with migration guide link.
- For truly-stuck customers: emergency paid support to migrate.
Sunset Header Implementation
Add to every v1 response starting month 0:
HTTP/1.1 200 OK
Content-Type: application/json
Deprecation: true
Sunset: Mon, 01 Jul 2026 00:00:00 GMT
Link: <https://docs.example.com/migration/v1-to-v2>; rel="successor-version"
Follows RFC 8594 standard. Well-known headers; automated tools can detect.
Communication Plan
Channel 1 — Docs.
Dedicated 'v1 → v2 migration guide' page. Endpoint-by-endpoint diff. Code examples in all supported languages.
Channel 2 — Email.
- Month 0: announcement + migration guide link
- Month 3: reminder
- Month 6: status report
- Month 12: warning
- Month 15: final notice
- Month 18: sunset effective
Channel 3 — Response headers.
Sunset + Deprecation headers on every v1 call. Dev tools surface these.
Channel 4 — Status page / changelog.
Running log of API changes. Customers subscribe for updates.
Channel 5 — Direct CSM outreach (for top 20% of customers).
Hand-holding for enterprise contracts. CSM has v1→v2 tracking dashboard.
Dealing with the Long Tail
Your 10% 'never update without force' customers:
- Month 14: CSM reaches out directly. Offer paid migration assistance.
- Month 17: offer engineering office hours for migration questions.
- Month 18: cutover happens. Expect 2-5 customers to need emergency support.
- Option for enterprise: paid extended-support for v1 (6-12 months). Adds revenue. Only offer to top-20% accounts.
Your Specific Change (Handling the /users restructure)
Approach:
1. Ship v2 /users endpoint with the nested structure.
2. Keep v1 /users serving current (flat) structure for 18 months.
3. Both paths share underlying data layer — just different serializers.
4. For /legacy-invoices (removing entirely): no v2 equivalent needed, just deprecation cycle.
Implementation:
# v1 serializer — current behavior
class UserV1Serializer(serializers.ModelSerializer):
phone = serializers.CharField()
address = serializers.CharField()
# ... flat fields
# v2 serializer — new nested structure
class UserV2Serializer(serializers.ModelSerializer):
profile = UserProfileSerializer()
# fields nested into profile
Routing by URL prefix; separate viewsets. Data stays canonical.
Key Takeaways
- URL-based versioning (v1/v2) + additive-only between versions. Most forgiving for your enterprise API.
- 18-month deprecation cycle. Meets your SLA buffer + handles long-tail customers.
- Sunset + Deprecation headers from day 0 of deprecation. Automated tooling detects; customers surface warnings.
Common use cases
- Public API design (day 0)
- Internal API stuck in versioning chaos
- Migrating from v1 to v2 with live customers
- Deciding whether to version at all
- Post-acquisition API consolidation
- Open-source API / SDK design
- Mobile app APIs (long-tail of old clients)
Best AI model for this
Claude Sonnet 4.5 or Opus 4. API versioning tradeoff reasoning benefits from mid-to-high tier.
Pro tips
- Additive changes never require a version bump. New optional fields, new endpoints. Use aggressively.
- Breaking changes should be rare. 1 major version every 2-3 years for mature APIs.
- Deprecation requires a 12-18 month runway for public APIs. Shorter kills customers.
- Communicate in 3 channels: docs, emails, API deprecation headers. Redundancy wins.
- Sunset headers are the standard: `Sunset: Sat, 31 Dec 2025 23:59:59 GMT`. Implement early.
- Some APIs shouldn't version. Add-only APIs (additive schemas) never need versioning if designed well.
Customization tips
- Add Sunset headers to v1 BEFORE you announce v2. Observant customers notice and prepare early.
- Build the migration guide FIRST, before announcing v2. If you can't explain the migration clearly, the change needs more design.
- Track v1 usage per customer. The 'who's migrated / who hasn't' dashboard is your month 12 communication tool.
- Never sunset a version during a holiday freeze or enterprise fiscal quarter-end. Pick neutral timing.
- Keep v1 docs frozen once v2 ships. If you keep updating v1 docs, customers assume v1 is still evolving.
Variants
Public API Mode
For externally-consumed APIs. Long deprecation timelines + formal communication.
Internal API Mode
For internal-only APIs. Faster iteration, tighter communication.
Mobile App API Mode
For APIs consumed by native mobile apps. Handles long-tail of old clients.
Frequently asked questions
How do I use the API Versioning Strategy prompt?
Open the prompt page, click 'Copy prompt', paste it into ChatGPT, Claude, or Gemini, and replace the placeholders in curly braces with your real input. The prompt is also launchable directly in each model with one click.
Which AI model works best with API Versioning Strategy?
Claude Sonnet 4.5 or Opus 4. API versioning tradeoff reasoning benefits from mid-to-high tier.
Can I customize the API Versioning Strategy prompt for my use case?
Yes — every Promptolis Original is designed to be customized. Key levers: Additive changes never require a version bump. New optional fields, new endpoints. Use aggressively.; Breaking changes should be rare. 1 major version every 2-3 years for mature APIs.
Explore more Originals
Hand-crafted 2026-grade prompts that actually change how you work.
← All Promptolis Originals