Video in progress

You are opening a public API for external partners. What do you design differently from an internal service-to-service API?

A public API is a commitment that lives for years: you don't control the clients and can't force them to upgrade. So a clear versioning and deprecation policy, strong authentication and quotas, idempotency, a stable error format, webhooks, a sandbox and documentation are part of the contract. I don't expose the internal model directly.

📖 Answer

A breaking change in an internal API is a week of agreement with a few teams. In a public API, the developer who wrote the partner's integration 2 years ago has already left, and nobody opens that code. If you make a change, their business stops.

Decisions that follow from this.

A separate layer. The public API is a facade over the internal services (an edge service or a gateway + BFF). When the internal model changes, the facade translates. Internal enums, ID formats and field names don't leak out.

Versioning and deprecation. The major version is in the URL (/v1/), and within a version only additive changes. Removing an old version has a published deadline (say 12 months), Deprecation and Sunset headers, metrics showing who still uses the old version, and writing to those people personally.

Security and fairness:

  • OAuth2 client credentials or signed requests, a separate key per partner, and the ability to rotate it;
  • a quota per partner and 429 + Retry-After;
  • limits on request size, page size and query complexity.

The reliability contract:

  • an Idempotency-Key for write operations, because the partner's network is unreliable and they will resend;
  • a stable error format (ProblemDetail) and machine-readable error codes, so the partner doesn't parse the message text;
  • webhooks for asynchronous results: signed, retried, with an event ID, and a list endpoint to recover missed webhooks.

Experience:

  • an OpenAPI document and SDKs generated from it;
  • a sandbox environment, test cards and a way to trigger a webhook manually;
  • a changelog and a status page.

Observability: traffic, errors and latency per partner. Before a partner calls to say "something broke on your side", you should already have seen their 4xx share jump.

In an internal API most of this is overkill, since speed and flexibility matter more there. In a public API, every decision passes the question "are we ready to support this for 5 years?".