Design Patterns · Study deck
Service API Contracts: Versioning and Compatibility
Old field devices may use one API for years.
Blueprint Bina is your guide for this deck.

After studying this chapter
Learning objectives
You will be able to:
- Explain: This distinction matters to the chapter's running argument because a client can depend on a service name and behavior without learning which instance happens to serve the next request.
- Explain: Path versioning makes the contract obvious to constrained clients, header versioning suits capable managed clients, and query versioning is a deliberate bridge rather than a default.
- Explain: The design question is no longer whether discovery exists, but which infrastructure component owns it and how that ownership preserves a stable endpoint for deployed devices.
- Explain: Discovery handles where requests go after a client has chosen the contract.
Major section
Versioning Strategies
Path versioning makes the contract obvious to constrained clients, header versioning suits capable managed clients, and query versioning is a deliberate bridge rather than a default.
- The gate is the important connection: additive changes may remain compatible, while breaking changes require migration, deprecation, and a recorded sunset.
Major section
Lifecycle Headers
API versions need an exit path.
- A deprecation policy tells clients that a resource should no longer be chosen for new work.
- A sunset policy tells clients when the resource is expected to become unavailable.
- Discovery handles where requests go after a client has chosen the contract.
Major section
Service Discovery
In dynamic infrastructure, service instances move, scale, and fail.
- Service discovery keeps clients from hardcoding addresses.
- A service instance first registers its location and health, a caller or routing component then discovers an eligible destination, and only then does invocation occur.
- The caller queries a registry, receives healthy instances, and chooses where to send the request.
Major section
Service Discovery (continued)
Good fit for capable internal services that can cache, retry, and observe registry failures.
- The caller sends traffic to a stable load balancer, gateway, or service name.
- Good fit for devices and simple clients that should not contain discovery logic.
- Clients use the Service name while Kubernetes updates the backing endpoints.
Major section
Service Discovery (continued)
Centralizes authentication, rate limits, routing, TLS termination, schema enforcement, and public endpoint stability.
- The design question is no longer whether discovery exists, but which infrastructure component owns it and how that ownership preserves a stable endpoint for deployed devices.
- The client knows only the stable front door; the load balancer consumes health and location evidence before selecting a backend.
- The contract must also say what happens to active sessions and writes during failover.
Major section
Service Discovery (continued)
This returns to the contract theme: placement and scaling can change without pushing registry logic or volatile addresses into constrained firmware.
- DNS and global routing are useful for public entry points, regional routing, and failover, but they should be paired with health checks and operational runbooks.
- This keeps global discovery aligned with the chapter's promise that clients depend on stable behavior rather than current instance addresses.
- This distinction matters to the chapter's running argument because a client can depend on a service name and behavior without learning which instance happens to serve the next request.
Major section
Key Concepts
Backward compatibility: The ability for old clients to keep working with a newer server.
- Deprecation: A signal that a resource should no longer be chosen for new work.
- Sunset: A signal that a resource is expected to become unavailable at a future time.
- API gateway: A stable entry point that can centralize routing, authentication, rate limits, and policy enforcement.
Major section
Try It Yourself: Design an API Migration
Design a migration for an IoT building platform that must replace /v1/devices/{id}/telemetry with a new schema.
- Existing firmware can update, but not all devices connect every day.
- The new schema adds quality flags and changes the unit representation.
- Operators need to know which clients still call the old version.
Deck summary
Key takeaways
Path versioning makes the contract obvious to constrained clients, header versioning suits capable managed clients, and query versioning is a deliberate bridge rather than a default.
- API versions need an exit path.
- In dynamic infrastructure, service instances move, scale, and fail.
- Good fit for capable internal services that can cache, retry, and observe registry failures.
- Centralizes authentication, rate limits, routing, TLS termination, schema enforcement, and public endpoint stability.
Retrieval practice
Recall check 1 of 5

Blueprint Bina says: answer from memory, then check your reasoning.
Q1Your IoT platform has deployed devices using /v1/devices. You need to include a new optional firmware_version field in the device registration response. What should you do?
Show answer
Answer: A Compatibility is about old clients continuing to work with newer servers.
Retrieval practice
Recall check 2 of 5

Blueprint Bina says: answer from memory, then check your reasoning.
Q2A constrained device needs to call an IoT command API. The backend command service runs in Kubernetes and scales up or down during the day. Which discovery approach keeps the device simplest?
Show answer
Answer: A Server-side discovery through a gateway, load balancer, or Kubernetes Service keeps constrained clients simple while allowing backend instances to move and scale.
Retrieval practice
Recall check 3 of 5

Blueprint Bina says: answer from memory, then check your reasoning.
Q3Place each SOA responsibility where it lives so you can separate a device capability failure from service discovery and an API contract or policy failure.
Show answer
Answer: A SOA keeps three failures distinguishable: the endpoint may not provide the capability, the registry may not find a healthy service, or the gateway contract may reject the client request.
Q4Complete the idempotent command handler so retries do not create duplicate commands:
Show answer
Answer: A The idempotency key identifies one logical command.
Retrieval practice
Recall check 4 of 5

Blueprint Bina says: answer from memory, then check your reasoning.
Q5A firmware bug causes some devices to retry a telemetry upload immediately after every timeout. What API behavior best prevents those devices from harming the whole platform?
Show answer
Answer: A Rate limiting should be part of the API contract.
Retrieval practice
Recall check 5 of 5

Blueprint Bina says: answer from memory, then check your reasoning.
Q6A platform needs to change a telemetry location field from an object with lat/lng to an array with longitude/latitude order. Existing clients parse the old shape. What is the safest migration?
Show answer
Answer: A Breaking changes require a new contract.
Print reference
Answers 1 of 2
Answer key.
- A · Compatibility is about old clients continuing to work with newer servers.
- A · Server-side discovery through a gateway, load balancer, or Kubernetes Service keeps constrained clients simple while allowing backend instances to move and scale.
- A · SOA keeps three failures distinguishable: the endpoint may not provide the capability, the registry may not find a healthy service, or the gateway contract may reject the client request.
- A · The idempotency key identifies one logical command.
Print reference
Answers 2 of 2
Answer key.
- A · Rate limiting should be part of the API contract.
- A · Breaking changes require a new contract.