APIs

How to Document an API People Will Not Read Twice

The API reference page that gets the most traffic in a typical developer portal is the one for the endpoint everyone already knows how to call. The second most-read page is the one that documents the thing nobody can figure out: an error code, an authentication quirk, a pagination rule that behaves differently on the third request. The pages in between, the ones that describe the happy path in careful prose, get skimmed once and abandoned. Documentation that people will not read twice is documentation that failed on the first pass, or documentation that described a problem the reader did not have.

Most teams write API docs as if the reader is a diligent student working through a textbook. The reader is closer to a person standing in a hallway, phone in one hand, trying to get a token to refresh before a demo starts in four minutes. That reader does not want a narrative. That reader wants the answer, positioned where the eye lands, phrased the way the error message phrased it.

The reference page is a lookup table, not a chapter

Consider what happens the moment a developer hits an unfamiliar response. They copy the error string, switch to a browser, and search. If the docs surface a page whose heading matches that string, the search ends. If the docs surface a page titled "Getting Started with the Payments API," the search continues, and the developer ends up on a forum reading a stranger's guess.

The fix is structural. Every error code gets its own heading, with the code itself as the heading text: PAYMENT_DECLINED_INSUFFICIENT_FUNDS, RATE_LIMIT_WINDOW_EXCEEDED, WEBHOOK_SIGNATURE_STALE. The heading does the work of matching the search query. Underneath, the first sentence says what the code means in plain language, the second says what to do about it, and the third gives a working example of the request that triggered it and the corrected request that will not. Three sentences, one code block, no preamble.

This is a small discipline that most teams resist because it feels like giving each error too much real estate. The resistance is backwards. The error page is the only page a frustrated developer will bookmark. Give it a stable URL and a heading that matches the literal string in the response body, and the second visit becomes a two-second glance instead of a five-minute search.

Pagination rules differ by endpoint and the docs should say so

A developer portal that describes pagination once, in a shared "Conventions" section, has quietly lied to every reader who then hits an endpoint that pages by cursor instead of offset. The lie is not intentional. It is the natural result of treating conventions as universal when the API has exceptions.

The honest version puts the pagination contract on every endpoint page, even when it repeats the shared convention. The repetition costs a few lines. The alternative costs a support ticket every time a developer assumes page=2 works on the cursor endpoint and gets back the same first batch of records with a new cursor. The reader who has already been burned once will not trust the shared conventions page again, and the docs lose authority.

Boilerplate repetition in reference docs is a feature. The reader is not reading the whole portal in order. The reader is landing on one page from a search result. That page has to stand alone.

Code samples belong above the prose, not below it

Scan any popular API reference and notice where the eye goes first. It goes to the gray box. The prose above the box is read only if the box raises a question. Docs that put three paragraphs of explanation before the first code sample are asking the reader to read a manual before touching the machine. The reader will scroll instead.

Put a working request at the top of every endpoint page. Use real placeholder values, not string or your_id_here. A sample like {"customer_id": "cus_NffrFeUfNV2Hib", "amount": 4200, "currency": "usd"} tells the reader more about the expected shape than a paragraph of field descriptions. The prose below the sample can then explain the one field that is not obvious, the one that has a non-default behavior, the one that will cause a 400 if it is the wrong type.

What gets cut when the sample goes to the top: the greeting, the overview paragraph, the sentence that explains what an API is. None of that survives contact with a developer who is already inside the dashboard looking for the field name.

Authentication deserves its own page and its own failure modes

Authentication failures are the single most common reason a first integration attempt stalls. The docs that handle this well give auth its own page, and on that page they document the failure modes with the same care as the happy path. An expired token, a token for the wrong environment, a key with insufficient scope, a signature computed over the wrong body: each of these produces a different response, and each response needs a heading.

Teams that bury auth inside a "Getting Started" flow end up writing the same support answer five times a week. The support answer is good. It should have been a docs page. The moment a support engineer types the same explanation for the third time, that explanation has earned a permanent URL.

One specific habit worth stealing from the better API portals: show the failing request and the failing response side by side, then show the corrected pair. A developer comparing two adjacent code blocks spots the difference in seconds. A developer reading a paragraph about scopes has to translate the prose into a diff.

Changelogs that a returning integrator can scan in ten seconds

The changelog is the page most likely to be read twice, and most teams format it in a way that makes the second read impossible. Entries are grouped by date, described in the passive voice, and bury the breaking change three paragraphs into a release note about a documentation fix. A returning integrator needs to know one thing: did anything change that will break my code?

Structure the changelog so breaking changes come first, marked with a plain word like "Breaking" in the heading, and so the affected endpoint is named in the entry. An entry that reads "Breaking: POST /v1/charges now requires idempotency_key" tells the returning integrator everything in one line. An entry that reads "We have updated the charges endpoint to improve reliability" tells them nothing and forces a diff against the last version of the docs, if that version still exists.

Keep old versions of the docs reachable. The reader who is maintaining a two-year-old integration is not the reader on the current version, and the current version's docs will not answer their question. Versioned docs are unglamorous infrastructure. They are also the difference between a returning developer and a former one.

OpenAPI files are the source of truth or they are decoration

Many teams publish an OpenAPI spec and a hand-written reference that disagree. The spec was generated from the code, the reference was written by a person, and the two drift apart within a quarter. The reader who finds the mismatch loses trust in both.

Pick one. If the spec is the source of truth, generate the reference from it and edit only the descriptions. If the reference is the source of truth, delete the spec or keep it in a repo where nobody treats it as documentation. The worst outcome is a portal with two pages that answer the same question differently, because the reader has no way to know which one is current.

Generation has a cost: the output is only as good as the descriptions in the spec. A generated reference full of description: "" is worse than a hand-written page, because it looks authoritative and says nothing. The teams that get this right treat spec descriptions as first-class documentation, reviewed in pull requests, and they let the generator handle the layout, the anchors, and the search indexing. The human writes the sentences that explain the non-obvious, and the generator handles the rest.

What a support ticket reveals about the missing page

Every support ticket about the API is a data point about a docs page that does not exist. The team that reads its own tickets as a documentation backlog, rather than as a queue to be cleared, ends up with docs that answer real questions. The team that closes tickets without asking why the question was asked keeps answering the same question in private.

A concrete practice: tag each ticket with the endpoint and the error code, and once a month, sort by tag. The top three tags are the three pages that need work. This is not sophisticated analytics. It is reading the mail.

The docs that people will not read twice are the ones that answered the question the first time. There is no trick to that beyond putting the answer where the reader is already looking, in the words the reader is already using, on a page that stands alone because the reader arrived from a search result and will not click through to a conventions page. Every other decision about layout, tooling, and prose style is downstream of that one commitment.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button