API-First Design

API-First Design

A development methodology: design the API contract before writing any client or UI. The API is the product. Clients (web app, mobile, CLI, agent skill, third-party integrations) are equally weighted consumers. Stripe is the canonical case; the entire payments-developer experience is shaped by this discipline.

The opposite is UI-first (or client-first): build the UI, expose whatever internal API the UI happens to need, treat external API access as a secondary concern. Easier short-term; structurally limits the system later.

What "API-first" means in practice

Before any code is written:

  1. The API contract is documented. Endpoints, parameters, response shapes, error codes — all specified. OpenAPI/Swagger or equivalent.
  2. The contract is reviewed by API designers, security, and consumers — not just the team building it.
  3. Clients are mocked first, against the documented contract, to validate the design against real use cases.
  4. Versioning policy is decided before launch. Breaking changes are intentional.
  5. The internal team consumes its own API. No backdoor "internal-only" methods.

Stripe famously runs an internal "API design doc" review for every new endpoint. The doc is ~20 pages. They've never deprecated a public API. The discipline shows in the developer experience — Stripe's docs are a benchmark.

Why this works

Externalisability is free. Once the API is the product, exposing it to third parties is a documentation and security problem, not an architectural rewrite.

Multiple clients are cheap. Once the API is stable and well-documented, adding a new client (mobile app, CLI, partner integration) takes weeks instead of months. Each new client is a small project.

Internal alignment. Teams negotiating an API spec early surface disagreements early. Hidden assumptions ("the front-end will just compute this") become explicit ("the API needs to return this field, computed").

Evolution is constrained. You can't subtly break the contract because it's written down and tested. Versioning becomes deliberate.

Why it costs

Slower start. Writing a spec before code feels like overhead. For a "throwaway" project it usually is overhead. For projects that grow, it's the cheapest possible insurance.

Locks in design. Once external clients depend on the API, you can't easily change it. Wrong calls cost more.

Tooling overhead. OpenAPI generation, mock servers, contract tests, version negotiation — all real work.

The trade-off: API-first wins when you're confident the system will have multiple clients (now or soon). Loses when you're sure it'll only ever be one app.

The Stripe model

Stripe's "Payments APIs: The first 10 years" and Kenneth Auchenberg's Insights from building Stripe's developer platform document the discipline explicitly:

The Stripe-specific tactics aren't all transferable, but the approach — treat the API as a product with its own UX — is.

API-first vs API-also vs Headless

These three terms get conflated:

API-first naturally leads to headless if applied consistently. Most modern startups claim API-first; few are truly headless.

When this applies to local tools

For local CLI tools and daemons (mxr, lazydap), "API-first" maps onto "protocol-first":

Same discipline, different transport. The TUI is just a third-party client of the same protocol the CLI uses.

Common pitfalls

Modern signal: AI agents have made this newly important

Pre-LLM, "API-first" was a developer-experience differentiator. Post-LLM, it's table stakes. AI agents only consume APIs (via shell, MCP, REST, etc.). Tools that don't expose stable, well-documented APIs are invisible to agents. The discipline that pays off in 2026 is the same one Stripe was practising in 2014.

See Agent-Native Interfaces for the agent-era restatement.

See also