API Compatibility
When to use
- Modifying request/response shapes, CLI flags, SDK exports, or event payloads consumers rely on.
- Deprecating a field, endpoint, or behavior.
- The user asks for a "breaking change", "v2", or "migrate callers".
When not to use
- Purely internal helpers with a single in-repo caller and no published contract.
- Bug fixes that restore documented behavior without changing the contract.
- Experimental endpoints explicitly marked unstable in docs and headers.
Assumptions
- You can identify the public surface (OpenAPI, exported types, CLI help, or docs).
- Semver or an explicit API versioning scheme may apply; follow the repo's convention.
- Do not delete or rename public endpoints/fields without confirmation and a migration note.
- Do not force-push release tags or rewrite published changelog history without confirmation.
Workflow
- Inventory the current public contract and known callers (in-repo first).
- Prefer additive changes (new fields optional; new endpoints; new flags).
- If a break is required, design deprecation → dual-run → remove, or a versioned path.
- Document the change and migration steps in changelog/PR.
- Ship with tests that lock both old (while supported) and new behavior.
Steps
- Classify the change — Additive, deprecating, or breaking. Default to additive.
- Preserve wire compatibility — New JSON fields optional; do not reuse field names for new meanings; avoid tightening validation unexpectedly.
- Deprecation path — Mark old fields/endpoints deprecated with a removal timeline; keep them working until then when feasible.
- Version or migrate — For hard breaks: new path (
/v2), negotiated version header, or coordinated caller PRs. State which. - Tests & examples — Update contract tests, golden files, and README/OpenAPI examples in the same change.
- Announce — PR summary includes impact, migration steps, and rollback (revert commit / previous version).
Success criteria
- Change type (additive / deprecating / breaking) is explicit in the PR.
- Breaks have a documented migration or version strategy.
- Existing supported clients keep working, or unsupported breakage is called out with confirmation.
- Contract tests/docs updated in the same diff.
- Destructive removals were confirmed or deferred.
Out of scope
- GraphQL schema federation strategy across many services.
- Marketing version numbering unrelated to API contracts.
- Database schema migrations without an external API impact (handle separately).