The five-minute test every API has to pass
A developer lands on your documentation page with a job to do. Maybe they need to charge a card, pull a list of orders, or send a notification. They have a deadline, a ticket in a tracker, and no patience for a puzzle. They will give your docs about five minutes. In that time they will either make a successful API call and feel good about your product, or they will close the tab and look for a competitor.
That five-minute window is the real test of API documentation, and most APIs fail it. Not because the API is bad. The endpoints might be clean, the responses sensible, the error handling thoughtful. The docs are what fail: the getting-started page assumes knowledge the reader does not have, the authentication section lives three clicks away from the example that needs it, and the one endpoint they actually need is documented with a single sentence and no example at all.
Good documentation is not a nice extra. For an API, it is the product's front door, its sales pitch, and its support desk rolled into one. Developers choose tools the way the rest of us choose restaurants: they walk past the place with the confusing menu. Stripe is the example everyone cites, and the praise is specific rather than vague — a three-column layout with explanation beside runnable code, the same example in seven languages, and a browser console that makes real test-mode calls against a test account. Stripe did not win developers with a prettier website. It won them by making the first successful call easy.
What good documentation contains
Every API needs the same handful of ingredients. The proportions change with the audience — a public payments API needs more hand-holding than an internal service used by three teams — but the list itself barely changes.
A quickstart that ends in a working call. This is the single most important page in the whole set. It should take a reader from zero to a successful request in minutes, with nothing left to guess: where to get a key, which base URL to use, what the first request looks like, and what a successful response looks like. If the quickstart does not end with something the reader can run, it is not a quickstart. It is a brochure.
Authentication, explained as a task, not a concept. Developers do not read the auth page to learn what OAuth is. They read it because they need a token and they need it now. Show them where the key lives, how to put it in a header, and what happens when it is wrong. A good auth page answers three questions on the first screen: which scheme this API uses, where to get credentials, and what a working request header looks like. Our guide to OAuth covers the flows themselves; the docs page should focus on what the reader has to do, in order, with their own account.
A complete reference. Every endpoint, every parameter, every field in every response, with types, whether each field is required, and what it actually does. The reference is the part of the docs that developers return to daily. Incomplete reference pages are worse than none at all, because they teach developers to stop trusting the docs and start guessing — and guessing against a live API is how production data gets deleted.
Real examples, not placeholders. An example that says {"name": "string"} tells the reader nothing. An example that says {"name": "Acme Books"} tells them what the field is for. Examples should use realistic values, show a full request and a full response, and cover the common case before the exotic one. Where a call has several sensible variations — creating a customer with and without a tax ID, say — show both, rather than making the reader combine two half-examples in their head.
Errors, documented as thoroughly as successes. A developer will spend more of their life debugging your API than celebrating it. Every error your API can return deserves a page or a section: the status code, the error code in the body, what it means in plain words, and what to do about it. "Invalid request" is not an explanation. "The amount field must be an integer in the smallest currency unit — 1000 means $10.00, not 10.00" is one, and it saves a support ticket.
A changelog. APIs change. New fields appear, old ones get deprecated, rate limits move. Developers who have built against your API need to know what changed, when, and whether they have to do anything. A changelog is also a trust signal: an API with a changelog that stops in 2023 looks abandoned, whatever the marketing page says.
Structure: arrange it the way a developer thinks
Information architecture sounds like a designer's concern. For API docs it is the difference between a reader finding an answer in thirty seconds and giving up after ten minutes of clicking. Developers arrive with a task in mind, and they think in a rough order: can I use this at all, how do I start, how do I authenticate, what does this endpoint do, what went wrong.
Put the pages in that order. Quickstart first, visible from the landing page without scrolling or searching. Authentication next, linked from inside the quickstart at the exact point the reader needs a key. Reference after that, grouped by resource — customers, orders, payments — rather than by HTTP method or by the order the endpoints were built. Grouping by resource matches how developers think about your domain; grouping by method is an accident of implementation leaking into the docs.
Navigation should stay visible and predictable. A left-hand table of contents that follows the reader down the page, with the current section highlighted, is the standard for a reason: it lets someone jump without losing their place. Search matters even more than navigation, because experienced developers skip the tour and search for the endpoint name directly. If your docs platform has weak search, fix that before adding more pages — a hundred pages nobody can find are worth less than twenty they can.
The quickstart is a promise
There is a useful way to think about the quickstart: it is a promise your API makes to a stranger. "Give me five minutes and I will show you this works." Breaking that promise costs more than a lost reader. It costs the reader's willingness to try again, and developers talk to each other.
A good quickstart has a shape you can copy. First, one paragraph on what the API does and who it is for. Second, how to get credentials — a link to the dashboard, a note about test versus live keys. Third, the first request, in curl and in one or two popular languages, with the response shown in full. Fourth, what to try next: a link to the guide for the most common task, and a link to the reference. That is the whole page. Anything else belongs somewhere deeper.
Choose the quickstart's language carefully. If your audience is mostly JavaScript developers, lead with JavaScript — our JavaScript guide is a reasonable place to check what that audience already knows — and put curl second. If your API is used from servers, lead with the server language your customers actually use, not the one your team likes best. The example should match the reader, not the author.
Authentication and errors: the two pages that decide everything
Authentication failures and confusing errors are where integrations stall. Both deserve more care than they usually get.
On authentication, be explicit about the scheme and the failure modes. If the API uses bearer tokens, say so, and show the exact header: Authorization: Bearer sk_test_.... If keys differ between test and live environments, say that on the same page, in bold, near the top — not buried in a footnote. Document what a wrong key returns, what an expired token returns, and what a key without the right scope returns, because those three errors look identical to a developer who has just pasted a key for the first time. Rate limits belong here too, or one click away: a developer who hits a 429 on their second request will assume the API is broken unless the docs explain the limit and how to handle it. Our article on API rate limiting explains the mechanics; your docs should state your own numbers plainly.
On errors, document the full shape of an error response, not just the status code. Developers write code against the body: the error code string, the message, and any fields that say which parameter failed. Give each error code its own entry with a cause and a fix, and keep a single error catalogue page that lists everything in one place alongside the entries in the reference pages.
Never return an error your docs do not mention. If the API can return a 402, a 409, or a 422, those codes need entries. An undocumented error code tells a developer that the docs are incomplete, and once they believe that, they stop reading and start experimenting — which is slower, riskier, and exactly what documentation exists to prevent.
Interactive docs and sandboxes
A static page can show a developer what a request looks like. An interactive page lets them make one. That difference is why the OpenAPI Specification matters so much to documentation. OpenAPI is a standard, maintained by the OpenAPI Initiative under the Linux Foundation, for describing a REST API in a machine-readable file: its endpoints, parameters, request bodies, and responses. From that one file, tools can generate a reference site, client libraries, and — the part developers love — an interactive console. Swagger UI, the best-known of those tools, turns an OpenAPI file into a web page where a reader can expand an endpoint, fill in the parameters, press a button, and see a real response.
A sandbox or test environment is the other half of this. Developers need a place to make mistakes safely: test keys, test cards, test data that can be reset. Without one, every experiment risks touching real customers, so developers experiment less and learn slower. If your API moves money or sends messages, a sandbox is not optional. It is part of the documentation, because it is where the documentation gets proven true.
There is a trade-off worth naming. Interactive docs generated from a specification are only as good as the specification. A generated page with no descriptions, no examples, and parameter names like x1 is technically interactive and practically useless. The spec file needs the same care as prose: every endpoint gets a plain-language summary, every parameter gets a description and an example, and every response shows a realistic body. Generation removes the drudgery of keeping pages in sync. It does not remove the writing.
Keeping docs in sync with the code
Stale documentation is the most common complaint developers have about APIs, and it is usually a process failure rather than a writing failure. The API changed, the docs did not, and nobody noticed until a customer filed a ticket. The fix is to make staleness hard rather than relying on someone remembering.
The strongest approach is docs-as-code: the documentation lives in the same repository as the code, in plain text files, reviewed in the same pull requests. When a developer changes an endpoint, the reviewer can ask where the docs update is, in the same review, before the change merges. Many teams generate their reference from the OpenAPI specification, which itself is generated from code annotations — the framework reads the route definitions and produces the spec, so the reference cannot drift from the code unless someone edits the generated file by hand, which should be treated as a bug.
Changelogs and versioning need the same discipline. When a breaking change ships, the docs should say so on the day it ships, with a migration note, not three weeks later after the support queue fills up. Our article on API versioning covers how to version an API so old integrations keep working; the documentation side of that is simpler: every version gets its own docs, and the reader can always tell which version they are reading.
A few habits keep drift down to a manageable level. Run the code samples in the docs as part of continuous integration — if an example stops working, the build fails, exactly as if a test had failed. Review the docs on a schedule, not just when someone complains: a quarterly pass over the ten most-visited pages catches rot before it spreads. And give one person or one small team ownership of the docs. Documentation with no owner rots the way a garden with no gardener does — slowly, then all at once.
The mistakes that quietly drive developers away
Most bad API docs are not bad in one dramatic way. They are bad in a dozen small ways, each of which costs a few developers, and the losses add up.
No getting-started path. The docs open with an architecture overview or a list of endpoints, and there is no page that says "start here". The reader has to assemble their own path from fragments. Always have a page called something like "Quickstart" or "Get started", linked from the landing page, that ends in a working call.
Examples that do not run. A code sample with a placeholder the reader cannot fill in, a missing import, a response that does not match the current API — each one teaches the reader that the docs cannot be trusted, and trust is slow to rebuild. Every example should be copied from a real, tested request, not typed from memory.
Missing errors. Documented success, undocumented failure. Developers discover the missing errors at the worst moment — when something has already gone wrong — and they discover them by trial and error, which is the slowest possible way to learn.
Jargon without definitions. Every API has its own vocabulary: workspaces, projects, ledgers, intents. If your docs use a term, define it the first time it appears, and keep a glossary.
Version confusion. The reader is looking at the docs for version 2 while their integration uses version 1, and nothing on the page says so. Label the version visibly, and keep old versions available.
No changelog, or a changelog that says "bug fixes". Developers planning an upgrade need specifics: which fields changed, which endpoints were deprecated, what the migration path is. "Various improvements" is not a changelog entry. It is a shrug.
How to tell whether your docs work
Documentation is often treated as unmeasurable — something you write once and hope for the best. It can be measured, and the measurements are mostly things you already have.
Time to first successful call is the headline number. If you have a sandbox, log how long it takes a new account to make its first successful request, and watch the trend. If that number is going up, something in the docs or the onboarding flow has got worse. A related number is the share of new sign-ups who make a first call at all. A developer who signs up and never calls the API is a developer the docs lost.
Support tickets are the richest source of evidence. Tag tickets that came from a docs failure — the answer was missing, wrong, or impossible to find — and review them monthly. Five tickets about the same missing example is a clear instruction to write that example. The support team usually knows exactly which pages are broken; ask them before you ask anyone else.
Direct feedback helps too, if you make it easy. A small "was this page helpful?" control at the bottom of each page, with an optional comment box, produces a steady stream of specific complaints. The comments will be blunt. That is the point.
Questions teams ask about API docs
How much documentation does a small API need?
Less than Stripe, more than nothing. A small API still needs a quickstart, an auth page, a reference for every endpoint, error documentation, and a changelog. That is a day or two of work for a focused writer, and it pays for itself the first time a developer integrates without opening a support ticket. Skip the glossy guides until the core five exist.
Should the reference be generated from code or written by hand?
Generate the reference, write the guides by hand. The reference is a list of facts about the API — endpoints, parameters, types — and facts are best produced from the source of truth, which is the code or the OpenAPI specification. The guides are judgement and explanation, and no generator can write those. Teams that hand-write their reference spend their time retyping facts that change; teams that generate everything end up with reference pages that read like a database dump.
How do we document an API that is still changing fast?
Be honest about it. Mark the API beta, keep a changelog that actually lists changes, and document the current behaviour rather than the planned behaviour. Developers tolerate change; they do not tolerate being surprised by it. Version your docs alongside the API, and keep a short migration note with every breaking change.
Who should write the docs?
The best arrangement is a technical writer working closely with the engineers who built the API, with the engineers reviewing for accuracy. If you cannot hire a writer, assign the work to an engineer who enjoys explaining things, and give them real time for it — not the last hour before a release. Documentation written as an afterthought reads like one.
What if our API is internal only?
Internal docs matter just as much, sometimes more. The reader is a colleague, and a colleague who cannot use your API will interrupt you instead — which costs your time as well as theirs. The same rules apply: quickstart, auth, reference, errors, changelog. The audience is smaller, so the guides can be shorter, but the reference still has to be complete.
What to do next
If your API docs need work, start with the quickstart. It is the page with the highest leverage, and it is the page most teams get wrong. Rewrite it so a stranger can make a successful call in five minutes, test it by watching a stranger try, and fix every hesitation you see. Then move to the error catalogue: write down every error the API can return, with a cause and a fix for each one. Then the changelog, if you do not have one.
After that, set up the habits that keep the docs honest: generate the reference from the OpenAPI specification, run the code samples in continuous integration, and give someone ownership of the docs with a monthly review of the analytics and the support tickets. None of this is glamorous. None of it ships a feature. But the next developer who lands on your docs with a deadline and five minutes to spare will either make a call that works or close the tab. Good documentation is what decides which one happens, and it is the cheapest growth your API will ever buy.
Comments
Post a Comment