SfSkills Domains Docs GitHub

Home / integration / api-versioning-strategy

api-versioning-strategy

Design versioning for custom Apex REST endpoints: URI versioning, backward compatibility, deprecation sunset. NOT for consuming external APIs — use apex/apex-rest-services.

Open the skill folder on GitHub


API Versioning Strategy

Custom Apex REST endpoints should be versioned from day one. Two accepted patterns: URI versioning (/services/apexrest/v1/orders) or header versioning (Accept: application/vnd.myco.v1+json). URI is simpler and more debuggable. This skill defines the class structure, the deprecation sunset policy, and the monitoring required to deprecate safely.

Adoption Signals

Before publishing a new endpoint or when breaking changes are needed on an existing one. Not for internal-only endpoints with known single consumer.

  1. Always include a version prefix in @RestResource urlMapping, even on v1.
  2. Breaking change → new version class; reuse the service layer; deprecate old via response header Sunset: <date>.
  3. Instrument v1 request counts via Event Monitoring or a custom Log__c record to measure traffic.
  4. Notify consumers 90 days before sunset; provide migration doc.
  5. Remove v1 only after 0 traffic for 30 days.

Key Considerations

Worked Examples (see references/examples.md)

Common Gotchas (see references/gotchas.md)

Top LLM Anti-Patterns (full list in references/llm-anti-patterns.md)

Official Sources Used

Package files