About This Template
Good API documentation is the single most important factor in developer adoption. This template provides a proven structure for creating clear, comprehensive, and maintainable API documentation. It is organized into sections that developers expect and can navigate quickly.
Template Structure
Section 1: Overview
Begin with a concise description of what your API does and who it is for.
Include the following:
- A one-paragraph summary of the API's purpose
- The base URL for all API requests (e.g.,
https://api.yourservice.com/v1) - Supported response formats (typically JSON)
- A link to your changelog or release notes
- Contact information or a link to your support channels
Example:
The Acme API provides programmatic access to manage widgets, users, and billing. All requests are made to
https://api.acme.com/v1and return JSON responses. This documentation covers version 1 of the API.
Section 2: Authentication
Explain how developers authenticate their requests.
- Describe the authentication method (API key, OAuth2, JWT)
- Show exactly where credentials go (header, query parameter, body)
- Provide a complete request example with authentication included
- Link to your guide on obtaining credentials
Example:
Include your API key in the
Authorizationheader of every request:Authorization: Bearer YOUR_API_KEY
Section 3: Errors
Document your error response format and common error codes.
Standard error response format:
{
"error": {
"code": "invalid_request",
"message": "The 'email' field is required.",
"status": 400
}
}
Common error codes to document:
| Status Code | Meaning | Description |
|---|---|---|
| 400 | Bad Request | The request body or parameters are invalid |
| 401 | Unauthorized | Authentication credentials are missing or invalid |
| 403 | Forbidden | The authenticated user lacks permission |
| 404 | Not Found | The requested resource does not exist |
| 429 | Too Many Requests | Rate limit exceeded |
| 500 | Internal Server Error | An unexpected server error occurred |
Section 4: Rate Limiting
Explain your rate limiting policy.
- Requests per minute or second allowed per key
- Headers returned with rate limit information
- What happens when the limit is exceeded
- How to request a higher limit if needed
Section 5: Pagination
Describe how paginated responses work.
- The pagination strategy (cursor-based, offset-based)
- Query parameters for controlling pagination (
limit,offset, orcursor) - Response fields that indicate pagination state (
next_cursor,has_more,total) - A complete example of paginating through results
Section 6: Endpoint Reference
For each endpoint, provide the following:
Endpoint header:
POST /v1/widgets
Description: A brief explanation of what the endpoint does.
Request parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | The name of the widget |
| color | string | No | The widget color (default: "blue") |
| quantity | integer | No | Number of widgets (default: 1) |
Request example:
{
"name": "Super Widget",
"color": "red",
"quantity": 5
}
Response example:
{
"id": "wdg_abc123",
"name": "Super Widget",
"color": "red",
"quantity": 5,
"created_at": "2026-01-10T12:00:00Z"
}
Error responses: List endpoint-specific errors beyond the common ones.
Section 7: Webhooks
If your API supports webhooks, document them thoroughly.
- How to register a webhook URL
- Available event types and their payloads
- How to verify webhook signatures
- Retry policy for failed deliveries
- Example payload for each event type
Section 8: SDKs and Libraries
List official and community SDKs with installation instructions.
- Language-specific SDK names and package manager commands
- Links to SDK source code repositories
- Quick start examples for each supported language
Writing Tips
- Lead with examples. Developers often scan for code samples first and read prose second.
- Keep it current. Outdated documentation is worse than no documentation. Automate generation where possible.
- Use consistent terminology. Define terms once and use them consistently throughout.
- Provide a quickstart. Include a "make your first request in 5 minutes" guide at the top.
- Test your examples. Every code sample should be a working, copy-pasteable example.
How to Use This Template
- Download the Markdown template using the link above
- Fill in each section with your API's specific details
- Add endpoint documentation for every public endpoint
- Have a developer unfamiliar with your API review the documentation for clarity
- Publish using a documentation platform such as Mintlify, ReadMe, or a static site generator