API Documentation and Developer Experience Questions
Documentation and developer experience for API consumers: reference docs for endpoints and fields, OpenAPI-driven and interactive documentation, quickstarts and runnable code samples, doc comments that feed generated reference, changelogs, deprecation notices and migration guides, error messages and error tables that explain themselves, developer portals, sandboxes and onboarding flows. Covers developer experience (DX) as a product concern: time to first successful call, DX and docs-effectiveness metrics and dashboards, diagnosing onboarding drop-off, developer feedback loops, experiments and developer research, documentation standards and CI checks across teams, prioritising DX investment, and reducing support load through better docs and self-service. Designing the API itself (versioning policy, auth, rate limits, webhooks, gateways, SDK engineering) is a separate subject.
How would you define developer experience for an API product, and which handful of metrics would you track to know whether it is improving?
Sample Answer
Direct answer
Developer experience (DX) for an API product is the quality of the whole journey a developer has with it: discovering it, getting a first call working, building an integration, operating it in production, troubleshooting, and upgrading. It is not just docs or pretty SDKs. Judge it by outcomes across that journey, using about five metrics, one per stage, each with a clear numerator (the top of the fraction) and denominator (the bottom). An integration below means one customer's application connected to your API, and a developer usually has one or more. Two status-code families appear: 2xx means the request succeeded and 4xx means the caller made a mistake (bad input, missing auth).
The metrics I would track
| Stage | Metric | Definition |
|---|---|---|
| Get started | Time to first successful call | Median and 90th percentile (p90, the time by which 90% finish) minutes from first docs view to first 2xx |
| Activate | 7-day activation rate | Signups making a successful call within 7 days, divided by all signups |
| Build | Support contacts per 100 active integrations | Tickets about how to use the API in a month, divided by integrations that made a call that month, times 100 |
| Operate | Client-error share for new integrations | 4xx responses divided by all responses, for integrations in their first 30 days |
| Evolve | Deprecation migration rate | Integrations moved off a deprecated version by its sunset date, divided by those affected |
Add a small survey (one question, "how easy was it to integrate?") for the human view the numbers miss, but keep it a companion, not the target.
My north star (the one number the team steers by): the activation rate, with the time to first successful call as its speed companion. Activation says whether developers succeed at all; time says how painful it was.
Worked example of the arithmetic
A month with 200 signups, 120 of whom make a successful call within 7 days: activation is 120 / 200 = 60%. The docs change; next month 220 signups and 154 activate: 154 / 220 = 70%. Support: 40 how-to tickets across 500 active integrations is 40 / 500 x 100 = 8 per 100. Numbers are only comparable when denominators are defined the same way each month.
The other three, with made-up numbers:
- Time to first successful call. Ten new developers take 4, 5, 6, 7, 8, 9, 11, 14, 22 and 45 minutes. The median is the middle of the sorted list, (8 + 9) / 2 = 8.5 minutes. The p90 (nearest-rank method) is the 9th of 10 values, 22 minutes, so the slowest tail is what a docs fix should target.
- Client-error share. New integrations sent 1,000 responses in their first 30 days and 150 were 4xx: 150 / 1,000 = 15%. If clearer error messages and examples cut that to 90 of 1,000, it is 9%. A high 4xx share means developers keep sending requests the API rejects, which points at unclear docs or errors (it does not count server failures, which are 5xx and a reliability issue).
- Deprecation migration rate. A deprecated version is an old API version you have announced will be retired, and its sunset date is the day it stops working. If 40 integrations were on v1 and 30 had moved to v2 by the sunset date, the rate is 30 / 40 = 75%. The 10 left behind are the ones to contact before you switch it off.
How each is gamed, and the guard
- Time to first call can be improved by counting a trivial ping: require a real endpoint.
- Support contacts fall if you make contacting support hard: pair with the survey and with client-error share.
- Activation rises if signups are filtered harder: watch signup volume alongside it.
Pitfalls
- Vanity metrics (numbers that look impressive but do not show developers succeeding, such as page views, downloads, GitHub stars) that say nothing about success.
- Twenty metrics: nobody acts on them. Five, one per stage, each with an owner.
You inherit a mature API product with poor documentation, heavy developer support volume and stalling adoption. Lay out your first 30 and 90 days: what you measure first, what quick wins you ship, and what you defer.
Sample Answer
Direct answer
Spend the first 30 days learning where the pain really is, using existing data and direct conversations, while shipping only fixes that are cheap and obviously right. Spend days 31 to 90 on the structural changes the evidence supports (four are listed below; if the ticket classification shows fewer are justified, do only those), and explicitly defer anything large that the evidence does not yet justify (for example a full docs-platform migration or a new SDK for a long-tail language).
Days 1 to 30: measure and listen
- Baseline the three outcomes: activation (signups reaching a first successful call within 7 days, divided by signups), support tickets per 1,000 active developers, and adoption trend (active developers per month). Without a baseline you cannot claim anything later.
- Classify the support volume: read a sample of a couple hundred recent tickets and tag each with a cause (auth setup, unclear error, missing docs, real bug, billing). This tells you how much volume docs could remove.
- Talk to people: five developers who stalled, five who are thriving, and the support engineers who answer the tickets daily. Support staff know the top ten confusions from memory.
- Audit the docs by walking them: do the quickstart yourself from a clean machine and write down every place you got stuck.
Quick wins to ship inside 30 days
- Fix the quickstart so it runs end to end (tested by someone else).
- Add an error-code page for the five most common error messages found in the tickets.
- Turn the most-asked support answer into a docs page and link to it from the error message.
- Add a "was this helpful" control and a feedback link so the pipeline of signal exists.
Days 31 to 90: structural changes
- Generate the reference from an OpenAPI description (the standard machine-readable API spec) and add CI checks so docs cannot drift from code.
- Build task guides for the top three jobs developers attempt.
- Automate the samples so they are executed in CI (continuous integration, the build run on every change).
- Set up a monthly docs-and-support review so tickets flow back into docs.
What I would defer
New SDKs (software development kits, language-specific client libraries) in more languages, a portal redesign, and translation. They are expensive, and none should start before the ticket classification shows they would remove real volume.
Worked example of the ticket read
Of 200 sampled tickets, if 60 are "how do I authenticate", 40 are "what does this error mean", 30 are "how do I paginate", 30 are genuine bugs and 40 are billing or account, then 130 of 200 (65%) are plausibly answerable by docs. That justifies putting docs first. If instead 130 were genuine bugs, the right first investment would be in the API itself.
Pitfalls
- Announcing a docs rewrite before understanding the problem. Poor docs can be a symptom of a confusing API design, which docs cannot fully repair.
- Shipping many changes at once, so you cannot tell which helped.
- Treating stalled adoption as purely a docs issue without checking pricing, reliability and product fit.
You are asked to review the reference page for a single API endpoint before it ships. What must that page contain for a developer who has never seen the API, and how does reference content differ from a getting-started guide?
Sample Answer
Direct answer
An endpoint reference page is the lookup page for one operation of the API. A developer who has never seen the API should be able to make a correct call from it, and handle every outcome, without reading anything else. So it must state what the call does, how to authenticate, every input with type, default and allowed range, a realistic request and response, every error with what to do about it, and the limits that apply. A getting-started guide is organised around a goal ("get a first result in five minutes") and walks one happy path. Reference is organised around the API's structure and is exhaustive.
What the page must contain
- Method, path, one-sentence purpose.
POST /v1/predict: "Returns a prediction for one input." Also the base URL for each environment. - Authentication and permissions. Header format and which key scope or role the call needs (a key scope is the set of actions a given key may perform, for example read-only versus read-write).
- Inputs table. Name, type, required or optional, default, valid range or allowed values, meaning, units.
- Request and response example. Realistic, copy-pasteable, and consistent with the tables. Every response field explained.
- Errors. Each status code the endpoint can return, the body it carries, the cause, and the caller's action (fix the request, retry, wait).
- Limits and behaviour. Rate limit, payload size cap (the maximum request body size), timeout, whether retrying is safe (idempotent means repeating the call has the same effect as making it once), pagination for lists (returning a long list in pages, with a way to ask for the next page).
- Stability. Version,
deprecatedmarker (a flag saying the endpoint is scheduled for removal), link to the changelog (the dated list of what changed in each release).
Reference versus getting-started
| Reference | Getting-started guide | |
|---|---|---|
| Organised by | API structure (endpoint by endpoint) | The reader's goal |
| Reader | Someone who knows what they need and looks it up | Someone new who needs momentum |
| Coverage | Complete: every field, every error | Minimal: one path that works |
| Explanation | Precise and terse | Narrative, explains why each step |
Contract-level sections (written once, linked from every endpoint)
- Authentication overview (how keys are issued, rotated, scoped).
- Rate limits: the numbers, the response headers, and the
429 Too Many Requestsbehaviour includingRetry-After(a response header saying how long to wait before trying again, as a number of seconds or as an HTTP date). - Error format shared by all endpoints.
- Versioning and deprecation policy: how much notice, and how a deprecation is signalled (docs banner, response header).
- SLA (service-level agreement, the published uptime or latency promise) and a status page link.
Reusable endpoint template
METHOD /path One-sentence purpose
Auth Header + required scope
Parameters name | type | required | default | range | description
Request example Realistic, copy-pasteable
Response Fields + example
Errors status | code | cause | what the caller does
Limits Rate, size, timeout, retry-safety
Stability Version, deprecated?, changelog link
Worked example (model inference)
POST /v1/predict, auth Authorization: Bearer <key>. Body field text: string, required, 1 to 2000 characters. top_k: integer, optional, default 1, range 1 to 5. Success 200 returns label, score (0 to 1) and model_version. Failures: 400 (malformed body: the request could not even be parsed, such as broken JSON), 422 (well-formed but invalid: text empty or too long, names the field), 429 (rate limited, wait as long as Retry-After says), 503 (model loading, retry with backoff, meaning wait and retry with growing delays). Payload cap and timeout are stated on the page, not left to be discovered.
What the filled-in page looks like (abridged)
POST /v1/predict Returns a prediction for one input.
Auth Authorization: Bearer <key> Scope: predict:invoke
Body text string required 1-2000 chars Text to classify
top_k integer optional default 1, range 1-5
200 OK {"label": "positive", "score": 0.93, "model_version": "2024-05"}
Errors
status | code | cause | caller does
400 | invalid_json | body is not valid JSON | fix the request
422 | text_too_long | text over 2000 characters | shorten text
429 | rate_limited | over 60 requests/minute | wait as `Retry-After` says
503 | model_loading | model warming up | retry, backing off
Limits 60 requests/minute per key. Body up to 32 KB. Timeout 10 s.
Retrying is safe (read-only, idempotent).
Stability v1, stable. Not deprecated. Changelog: /changelog
The numbers above are illustrative placeholders for a fictional endpoint. Two sample notices that belong on the contract-level pages:
- Rate-limit notice: "Exceeding the limit returns 429 with a
Retry-After: 12header. Wait 12 seconds, then retry." (Retry-Aftermay also carry an HTTP date, such asRetry-After: Wed, 21 Oct 2026 07:28:00 GMT, so the page should say which form the API sends and clients should accept both.) - Deprecation notice: "
GET /v1/predict-legacyis deprecated as of 2025-01-15 and will be removed on 2025-07-15. UsePOST /v1/predict. Responses now carry aDeprecationheader."
Pitfalls
- Field lists without types, defaults or ranges.
- Only the success case documented.
- An example whose values do not satisfy the page's own schema.
- Tutorial prose creeping into reference until nobody can scan it.
How would you structure and maintain an OpenAPI specification so it produces both readable reference docs and usable client code? Focus on what goes in the spec beyond the schemas, and how you keep it from drifting away from the real API.
Sample Answer
Direct answer
OpenAPI is a machine-readable description format for HTTP APIs (a YAML or JSON file). Treat the spec as a product with two audiences: humans reading rendered reference docs, and code generators producing SDKs (software development kits, client libraries in a given language). Schemas alone give you neither: readable docs need descriptions, examples and errors, and usable clients need stable operation names, auth and servers. Drift means the file slowly stops matching what the running API really does. Keep it from drifting by making CI (continuous integration, the automated checks on every pull request) fail when the spec and the running API disagree.
What goes in the spec beyond schemas
operationIdon every operation. Unique and stable. Generators typically turn it into the SDK method name, so renaming it is a breaking change for SDK users.summary,descriptionandtags. These become the docs page text and navigation groups.exampleson requests and responses. They render as sample payloads and drive mock servers (fake API servers that answer from the examples, so front-end developers can build before the real service exists).- Every error response, not just
200, referencing one shared error schema. serversandsecuritySchemes. Base URLs per environment, and how auth works (for example a bearer token sent in theAuthorizationheader), so clients configure themselves.- Reusable
components(parameters, responses, schemas) referenced with$ref(a pointer that means "use the definition stored over there"), so pagination or error shapes are defined once. deprecated: trueon retiring operations, plus vendor extensions (fields startingx-, such asx-codeSamples, an optional extension some doc renderers use to show code samples) for extras.- Split a big spec across files and bundle it (merge the pieces back into one file) for publishing.
paths:
/invoices:
post:
operationId: createInvoice
summary: Create an invoice
description: Creates a draft invoice for an existing customer.
tags: [Invoices]
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [customer_id, amount_cents]
properties:
customer_id: {type: string, example: cus_123}
amount_cents: {type: integer, minimum: 1, example: 2500}
responses:
"201": {description: Created}
"422":
description: Validation failed
content:
application/json:
schema: {$ref: "#/components/schemas/Error"}
components:
schemas:
Error:
type: object
required: [code, message]
properties:
code: {type: string}
message: {type: string}
Reading it line by line: operationId: createInvoice becomes the SDK method name (typically client.invoices.create(...)); summary is the one-line title on the docs page and description is its body text; tags: [Invoices] decides which navigation group and which SDK class the operation lands in; the example values are the sample payload shown in the docs; and the 422 response, pointing at the shared Error schema through $ref, becomes both the documented error body and the error type the SDK raises.
Keeping it from drifting
The standard core set is a linter, a breaking-change diff and a contract test; the rest is optional polish.
- Lint the spec (a linter is a tool that checks a file against style rules) with Spectral, the common OpenAPI linter: the built-in
spectral:oasruleset only WARNS on a missing operationdescriptionoroperationId(executed: Spectral run on the shipped spec with both removed printedoperation-descriptionandoperation-operationIdas warnings, 0 errors), and it does not flag a missing example at all, because its example rule only validates examples that exist. So write a custom ruleset that raises those rules toerrorand adds a rule requiring examples, then make CI fail on errors. - Detect breaking changes (edits that make existing clients stop working, such as removing a field or renaming an operation): diff the spec against the main branch (for example with oasdiff, a tool that compares two versions of a spec and reports what changed) and block removed fields or renamed operations without an explicit override.
- Contract-test the real service: a tool such as Schemathesis (the usual choice today; Dredd is an older alternative you may meet) sends requests generated from the spec to a test deployment and fails when responses do not match. This is the only check that catches code diverging from the spec.
- Generate an SDK in CI and compile it, so a spec that produces broken clients fails before release.
- One owner and one review path: spec changes go through the same pull request as the code that implements them.
Trade-offs and pitfalls
- Descriptions rot faster than types, so lint for presence and review for accuracy.
- A hand-edited published copy of the spec is the classic drift source: publish only from the repository build.
- Over-strict schemas make clients fail when the server adds a field:
additionalProperties: falsemeans "any field not listed here is invalid", so a validating client rejects a response the moment the server adds a harmless new field. Decide deliberately.
External developers need a sandbox to build against before they have production access. What should the sandbox give them, how do you keep it faithful to production, and how do you document where it differs?
Sample Answer
Direct answer
A sandbox is a safe copy of the API where outside developers can make real calls with fake money and fake data, before the provider trusts them with production. It should give them self-serve access, realistic and resettable data, a way to trigger every error and edge case on demand, and the same request and response shapes as production. You keep it faithful by making production and sandbox share the same contract and the same tests, and you document the remaining differences in one table that developers see before they hit them.
What the sandbox should give developers
- Instant, self-serve credentials. A sandbox key created in the portal in a minute, with no sales call. If getting a key takes days, developers stall before writing any code.
- A separate base URL (the address every request starts with) and separate keys (for example
api.sandbox.example.com). A test key must never work against production, and a production key must never work in the sandbox, so nobody moves real money by mistake. - Seeded, realistic data. A few sample customers, orders and accounts already present, so list and search calls return something meaningful on the first try.
- Triggers for every outcome. Developers must be able to test failure without waiting for one to happen. The usual technique is "magic values": a documented input that forces a result, such as amount
4003always returns a card-declined error (the number itself is arbitrary, chosen by the provider and listed in a "test values" table in the docs so nobody has to guess it), or a headerX-Sandbox-Scenario: rate_limitedforces a 429 (Too Many Requests). - Working asynchronous behaviour. If production sends webhooks (HTTP callbacks the provider makes to the developer's server), the sandbox must send them too, with a "resend this event" button. Otherwise the most bug-prone part of an integration goes untested.
- Reset and inspect tools. A "wipe my sandbox data" button and a log of recent requests, so a developer can tell whether the bug is theirs.
Keeping it faithful to production
- One contract, two environments. Both are described by the same OpenAPI file (OpenAPI is the standard machine-readable format for describing an HTTP API). Publish the spec once, not a sandbox copy that can drift.
- Run the same contract tests against both. A contract test is an automated check that a service still returns the responses its published description promises. After every deploy, an automated suite sends the same requests to sandbox and production-like builds and checks status codes and response fields. A failure blocks the release.
- Same code paths where it is safe. Validation, authentication, pagination and error formats should run the real code. Only the parts with real-world side effects (moving money, sending email, calling a bank) are replaced with stubs (fake stand-ins that return canned results). Pagination means returning long lists in pages.
- Keep the release cadence aligned. The sandbox is never behind production: a new API version reaches the sandbox first, or on the same day, so partners can test ahead of the change. Two environments on different versions is the commonest source of silent drift.
- Watch for drift. Track "worked in sandbox, failed in production" support tickets. Each one is a fidelity bug and should produce either a fix or a new row in the differences table.
Documenting where it differs
Put one page called "Sandbox vs production" in the docs, link it from the quickstart (the short guide to a first working call), and repeat the relevant row next to the affected endpoint. Illustrative content:
| Area | Sandbox | Production | What the developer should do |
|---|---|---|---|
| Rate limits | 100 requests/minute | Higher, per plan | Do not load-test in the sandbox |
| Webhooks | Delivered within seconds | Delivered with retries over hours | Handle duplicates and out-of-order events |
| Settlement (money actually moving between banks) | Instant | Takes days | Never assume instant in your UI |
| Data | Wiped on request, may be reset on upgrade | Permanent | Do not store sandbox IDs |
Also add a header on every sandbox response (for example X-Environment: sandbox) so logs make the environment obvious.
Worked example
A payments partner tests refunds. In sandbox, POST /refunds for a payment of amount 1000 (10.00 in the smallest currency unit, cents) returns 201 at once with "status": "refunded", and the webhook arrives in 2 seconds, so their code marks the order refunded immediately. In production the refund is pending for days and the webhook comes later. To let them rehearse that, the sandbox scenario is requested like this: POST /refunds with header X-Sandbox-Scenario: refund_pending, which returns 201 with "status": "pending" and sends the refund.completed webhook only when the developer clicks "advance time" in the portal. A state transition is a status change like pending to refunded. The differences table row "Settlement: instant vs takes days" and a sandbox scenario that returns status: "pending" on request would have caught this before launch. Faking the delay is cheap and prevents the most common go-live surprise.
Trade-offs and pitfalls
- Perfect fidelity is not the goal. A sandbox that reproduces every production rule is expensive and slow. Pick fidelity for shapes, validation, errors and state transitions, and accept documented differences for speed, scale and external systems.
- An undocumented difference is worse than a large one. Developers forgive "the sandbox is instant" if the docs say so.
- Stale data and shared state cause flaky partner tests, so isolate each account's data.
- Do not use the sandbox to hold production-like personal data. Synthetic data only.
Unlock Full Question Bank
Get access to all 36 API Documentation and Developer Experience interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.