How do you change a public API without breaking existing clients, such as old mobile app versions?
What the interviewer wants to hear
- Prefer additive, backward-compatible changes
- Version breaking changes (URL or header)
- Deprecation policy with timelines and communication
- Monitor usage of old versions before removing
- Contract tests and documentation
Model answer
Old mobile apps can stay installed for years, so I treat the API as a contract. Most changes should be additive: adding optional fields or new endpoints does not break clients that ignore unknown fields. Breaking changes, like renaming or removing a field or changing its type, go into a new version, for example /v2/orders or a version header, while v1 keeps working. I keep both versions on the same business logic with a thin mapping layer. Then I announce a deprecation timeline, add Deprecation and Sunset headers, and track how many requests still hit v1, per client version. Only when traffic is near zero, or the app forces an update, do I remove it. I use OpenAPI docs and contract tests in CI to catch accidental breaking changes before release.
Can you answer it under time pressure?
Take a timed medium round and get scored on every answer.
More medium Backend Developer questions
- An API endpoint is slow because it runs a heavy database query. How would you add caching, and how do you keep the cache correct?
- You need to rename a column in a large production table that the live app uses. How do you do it without downtime?
- Users say one API endpoint has become slow in production. How do you find and fix the cause?
- Sending emails and generating PDF invoices makes your checkout API slow. How would you move this work to the background?
- How would you add rate limiting to a public API that runs on many servers?
- You are asked to review the security of a REST API before launch. What would you check?
- Your service receives webhooks from a payment provider. How do you make handling them secure and reliable?
- When would you choose Kafka and when RabbitMQ for messaging between services?
- How would you design an API that lets users upload large files, such as videos of several gigabytes?