CW-301f · Module 1
API Documentation Generation
4 min read
API documentation has a specific structure that Claude can generate reliably from source code, OpenAPI specs, or even informal descriptions. The structure is: endpoint, method, parameters, request body, response body, error codes, and a working example. Every API doc page follows this structure. Consistency is more important than prose quality — developers scan API docs, they do not read them.
The generation prompt: "Generate API documentation for this endpoint. Use this exact structure: Endpoint (URL + method), Description (one sentence), Authentication (required method), Parameters (table: name, type, required, description), Request Body (JSON schema with example), Response (JSON schema with example), Error Codes (table: code, meaning, resolution), Example (curl command with a realistic payload and the expected response)." The curl example is non-negotiable — developers copy-paste examples before reading documentation.
## POST /api/v1/contacts
Create a new contact record.
**Authentication:** Bearer token (required)
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| include | string | No | Comma-separated related resources |
### Request Body
```json
{
"name": "Jane Smith",
"email": "jane@example.com",
"company": "Acme Corp"
}
```
### Response (201 Created)
```json
{
"id": "ct_abc123",
"name": "Jane Smith",
"email": "jane@example.com",
"createdAt": "2026-02-22T10:30:00Z"
}
```
### Errors
| Code | Meaning | Resolution |
|------|---------|------------|
| 400 | Invalid request body | Check required fields |
| 409 | Email already exists | Use PUT to update |