Introduction When migrating from a monolith to microservices, API incompatibility between the old and new systems causes client errors. The strangler fig pattern helps, but requires careful API management.

Symptoms - API clients receiving different response formats from microservices - Missing endpoints in new microservices - Authentication mechanism incompatible between systems - Request/response schema differences - Rate limiting behavior different between monolith and microservices

Common Causes - Microservice API not matching monolith API contract - Authentication/token format changed - Response pagination format different - Error response format not matching - Missing backward compatibility layer

Step-by-Step Fix 1. **Implement API Gateway as compatibility layer': ```yaml # Kong gateway configuration routes: - name: legacy-compat paths: ["/api/v1"] service: monolith - name: new-api paths: ["/api/v2"] service: microservice plugins: - name: request-transformer config: add: headers: ["X-API-Version:v2"] ```

  1. 1.**Implement response transformation':
  2. 2.Transform microservice responses to match monolith format.
  3. 3.**Gradually migrate clients to new API':
  4. 4.Communicate API changes and provide migration timeline.

Prevention - Maintain API contract with OpenAPI/Swagger specifications - Use API versioning for breaking changes - Implement API gateway for traffic routing - Test API compatibility in staging - Use consumer-driven contract testing