API Reference Documentation
Document an API endpoint or function completely: description, parameters, request and response examples, errors and authentication details.
Welcome back!
Step 1 of 12Learn
What API reference is for
An API (application programming interface) lets one program talk to another. API documentation is read by developers who are building something, usually in the middle of writing code. They want precise answers fast: What does this endpoint return? Is this parameter required? What does error 422 mean here?
API reference is the part of the documentation that describes every endpoint, function, class or method in a consistent format. It is classic reference content: complete, accurate, predictable and designed for lookup, not for reading from top to bottom.
Because developers jump straight to the item they need, every entry must stand on its own and follow the same structure. If one endpoint lists its errors at the top and another at the bottom, readers waste time hunting.
Reference alone isn't enough, though. Developers also need conceptual explanations (how authentication works, how pagination works, rate limits) and task guides (how to accept your first payment). The best API docs link these together: a reference entry for an endpoint links to the guide that uses it, and the guide links back to the full reference.
Many teams generate reference pages from a machine-readable description, such as an OpenAPI file for REST APIs. Generation keeps structure consistent, but the descriptions still need a writer's care: a field described only as "The status" is technically present and practically useless.
Step 2 of 12Practice · Choose one
Why should every API reference entry follow the same structure?
Step 3 of 12Learn
Anatomy of an endpoint entry
A complete REST endpoint entry typically includes:
- Name and one-line description in plain words: "Create a customer. Adds a new customer record and returns it."
- Method and path: POST /v1/customers
- Authentication: what credentials or permissions are required.
- Parameters, usually in a table: name, location (path, query, body), type, required or optional, default, constraints and a description that says what the parameter does.
- Request example: a complete, copyable call.
- Response example: a realistic response body, with the meaning of important fields.
- Errors: the status codes this endpoint can return and what each means here, plus how to fix it.
- Notes: rate limits, side effects (for example, "sends a welcome email"), idempotency, pagination.
Parameter descriptions are where many references fall short. Compare:
- Weak: email (string): The email.
- Strong: email (string, required): The customer's email address. Must be unique within your account; returns 409 if it already exists. Maximum 254 characters.
The strong version answers the questions a developer will otherwise discover by trial and error: is it required, what format, what limit, what happens on conflict.
Step 4 of 12Diagram
Parts of an endpoint entry
Every entry in the same order, so developers know where to look. Tap each part.
Tap a shape with to see more.
- POST /customers
- Name and one-line description
"Create a customer."
- Authentication
Which key or scope is required.
- Parameters
Type, required or optional, default, allowed values.
- Example request
Realistic values, copyable.
- Example response
The matching body and status.
- Errors
Status codes and what to do about each.
Step 5 of 12Practice · Select all that apply
A parameter is documented as "limit (integer): The limit." Which details would make it more useful? Select all that apply.
Select all that apply.
Step 6 of 12Learn
Documenting errors
Developers spend much of their time dealing with things going wrong, so error documentation is some of the most valuable reference content you can write.
For REST APIs, errors are signaled partly with HTTP status codes. A few that appear constantly:
| Code | Meaning | Typical cause |
|---|---|---|
| 400 Bad Request | The request is malformed or invalid | Missing field, wrong type |
| 401 Unauthorized | Not authenticated | Missing or invalid API key |
| 403 Forbidden | Authenticated but not allowed | Key lacks permission |
| 404 Not Found | Resource doesn't exist | Wrong ID or path |
| 409 Conflict | Conflicts with current state | Duplicate unique value |
| 429 Too Many Requests | Rate limit exceeded | Too many calls too fast |
| 500 Internal Server Error | Server-side failure | Not the client's fault |
The confusingly named 401 actually means not authenticated (we don't know who you are), while 403 means not authorized (we know who you are, and you can't do this). Getting this distinction right in docs saves developers real debugging time.
For each endpoint, list the errors it can realistically return, the error code or message in the response body, and what the developer should do: fix the field, refresh the token, wait and retry with backoff, or contact support.
Step 7 of 12Practice · Match the pairs
Match each HTTP status code to the situation it signals.
Tap an answer, then tap the place where it belongs (or drag it there).
- 401
- 403
- 404
- 429
- 500
Step 8 of 12Practice · Diagram
Status codes by who must act
4xx: fix the request. 5xx: the server failed. Tap a code.
The API key is valid but lacks the "billing" permission. Tap the code.
Tap the shape that answers the question, then press Check.
- Error response
- 4xx: client side
Something in the request needs to change.
- 5xx: server side
Not the caller's fault; retry later or report.
- 400 Bad Request
Missing field, wrong type.
- 401 Unauthorized
Not authenticated: missing or invalid key.
- 403 Forbidden
Known caller, not allowed.
- 404 Not Found
Wrong ID or path.
- 429 Too Many Requests
Rate limit exceeded.
- 500 Internal Server Error
Step 9 of 12Note
Step 10 of 12Learn
Versioning and deprecation
APIs change, and the docs must tell developers how and when.
Semantic versioning is a common scheme: MAJOR.MINOR.PATCH, such as 2.4.1.
- MAJOR increases for breaking changes: anything that makes existing code stop working, like removing a field or changing a type.
- MINOR increases for new, backward-compatible features.
- PATCH increases for backward-compatible bug fixes.
So moving from 2.4.1 to 2.5.0 should be safe, while 3.0.0 warns developers to read the migration guide.
When a feature will be removed, mark it deprecated well in advance. A good deprecation notice states what is deprecated, what to use instead, and when it will stop working:
"The phone field is deprecated and will be removed in version 3.0 (planned for June 2027). Use phone_numbers, which supports multiple numbers."
Clearly label which version each page describes, and keep docs for older versions available as long as those versions are supported. Developers maintaining older integrations need accurate docs too.
Step 11 of 12Practice · Diagram
Reading a version number: 2.4.1
Tap each part to see what a bump means.
A release adds a new optional parameter and breaks nothing. Tap the part that goes up.
Tap the shape that answers the question, then press Check.
- Version 2.4.1
- MAJOR = 2
Breaking changes. Code may need updating.
- MINOR = 4
New features, backward compatible.
- PATCH = 1
Backward-compatible bug fixes.
Step 12 of 12Practice · Choose one
A library moves from version 4.2.3 to 5.0.0. Under semantic versioning, what does this signal?
Lesson complete!