API documentation example
One endpoint, documented the way a developer wants to read it: what it does, what it takes, what comes back, and what goes wrong.
api-documentation.md
# Documents API
Base URL: `https://api.example.com/v1`
All requests need an `Authorization: Bearer <token>` header.
## Create a document
```http
POST /documents
Content-Type: application/json
```
### Body
| Field | Type | Required | Description |
| --- | --- | :---: | --- |
| `title` | string | yes | Shown in listings. Max 200 characters. |
| `body` | string | yes | Markdown source. Max 1 MB. |
| `tags` | string[] | no | Lowercase, no spaces. |
| `draft` | boolean | no | Defaults to `false`. |
### Example
```bash
curl -X POST https://api.example.com/v1/documents \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"title": "Notes", "body": "# Notes", "tags": ["internal"]}'
```
```json
{
"id": "doc_8f3a",
"title": "Notes",
"created_at": "2026-08-27T09:12:44Z",
"draft": false
}
```
### Errors
| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_body` | A required field is missing or the wrong type |
| 401 | `unauthorized` | Missing or expired token |
| 413 | `too_large` | Body over 1 MB |
| 429 | `rate_limited` | More than 60 requests a minute |
> [!NOTE]
> Rate limits are per token, not per IP address.
Documents API
Base URL: https://api.example.com/v1
All requests need an Authorization: Bearer <token> header.
Create a document
POST /documents
Content-Type: application/json
Body
| Field | Type | Required | Description |
|---|---|---|---|
title |
string | yes | Shown in listings. Max 200 characters. |
body |
string | yes | Markdown source. Max 1 MB. |
tags |
string[] | no | Lowercase, no spaces. |
draft |
boolean | no | Defaults to false. |
Example
curl -X POST https://api.example.com/v1/documents \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"title": "Notes", "body": "# Notes", "tags": ["internal"]}'
{
"id": "doc_8f3a",
"title": "Notes",
"created_at": "2026-08-27T09:12:44Z",
"draft": false
}
Errors
| Status | Code | When |
|---|---|---|
| 400 | invalid_body |
A required field is missing or the wrong type |
| 401 | unauthorized |
Missing or expired token |
| 413 | too_large |
Body over 1 MB |
| 429 | rate_limited |
More than 60 requests a minute |
[!NOTE] Rate limits are per token, not per IP address.