api-design

  • Idempotency keys, and where they have to be stored

    A client that times out and retries has sent the same request twice, and the server cannot tell whether the first one succeeded. The key makes the retry…

  • The Responsable interface removes a controller branch

    A controller returning either a view or JSON depending on the request ends up with the same conditional in every action, and the decision has nothing to do…

  • A circuit breaker before the third-party outage

    A payment provider was slow and the whole site went down with it. A timeout bounds one request; it does nothing about how many are waiting at once.

  • Event versioning is harder than API versioning

    An API version can be retired once the clients have moved. An event may be sitting in a queue, or in an event store, published by a version…

  • Retry only what is safe to retry

    A retry policy applied at the HTTP client level retries everything, including the POST that succeeded and whose response was lost. The safety of a retry is a…

  • Designing an API two mobile clients can live with

    Two apps, two release cycles, and neither can be forced to update. What is additive, what is not, and the decisions that have to be made before the…

  • Custom endpoints belong in a namespace you own

    Registering a route under wp/v2 puts it in core’s namespace, where a future core route can collide with it and where nothing signals that it is yours. The…

  • A timeout is not a concurrency limit

    Setting a five-second timeout on a slow dependency feels like protection and is not: with twelve PHP-FPM workers and a dependency taking five seconds, twelve concurrent requests occupy…

  • A circuit breaker has three states and people implement two

    Closed and open are obvious: pass through, or fail fast. The third state is what makes it a breaker rather than a switch — half-open lets exactly one…

  • An event-driven seam between two services

    The synchronous call between two services was the reason both were down. Publishing an event decouples their availability — and makes eventual consistency a business decision.