Back to templates
Software DevelopmentIntermediateUser Prompt

API Documentation Writer

March 28, 2026

The API Documentation Writer produces structured, developer-friendly documentation for REST APIs. Given your endpoint details or code, it generates descriptions, parameter tables, request/response examples, error code references, and authentication notes in a format ready to publish.

Backend developers, API product managers, and technical writers use this template when launching new APIs, onboarding external developers, or updating docs after endpoint changes. It is especially valuable when documentation has fallen behind the actual implementation and needs a full refresh.

The prompt produces documentation in a standardized format that follows industry conventions (similar to Stripe and Twilio docs). It includes cURL examples for quick testing, language-specific SDK snippets, and explicitly documents error cases, which is the section most hand-written API docs leave incomplete.

This prompt is just the starting point

Score it with AI, optimize it with one click, track versions, and build your prompt library.

AI quality score on 6 criteria
One-click optimization with 3 strategies
Version history to track improvements

The Prompt

Write comprehensive API documentation for the following endpoint(s):

**API Base URL**: [BASE URL, e.g., https://api.example.com/v1]
**Authentication Method**: [AUTH METHOD, e.g., Bearer token, API key in header, OAuth2]
**Endpoint Details**:
```
[PASTE YOUR ROUTE CODE, OPENAPI SPEC, OR DESCRIBE THE ENDPOINT:
  Method: POST
  Path: /users
  Purpose: Create a new user account
  Request body fields: email, password, name
  Response: user object with id, email, name, created_at]
```

For each endpoint, generate documentation with this structure:

### [METHOD] [PATH]
**Description**: One-paragraph explanation of what this endpoint does and when to use it.

**Authentication**: Required or optional, and which type.

**Request Parameters**:
| Parameter | Type | Required | Description | Example |
|-----------|------|----------|-------------|---------|

**Request Body** (if applicable):
| Field | Type | Required | Constraints | Description |
|-------|------|----------|-------------|-------------|

**Example Request**:
```bash
curl -X [METHOD] [FULL_URL] \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ realistic example body }'
```

**Success Response** (status code):
```json
{ realistic example response }
```

**Error Responses**:
| Status Code | Error Code | Description | Resolution |
|-------------|------------|-------------|------------|

**Rate Limiting**: Note any rate limits that apply.

**Notes**: Any caveats, deprecation warnings, or related endpoints to be aware of.

Include at least 3 error scenarios (validation error, authentication error, not found) with realistic error response bodies.

Usage Tips

  • Paste actual route code: Instead of describing the endpoint manually, paste the handler function directly. The AI will extract parameters, validation rules, and error cases from the code itself.
  • Specify your doc format: If you use a specific format (OpenAPI/Swagger, API Blueprint, or a custom format), mention it so the output matches.
  • Batch multiple endpoints: List several related endpoints (e.g., all CRUD operations for a resource) in one prompt to ensure consistent documentation style.
  • Verify the examples: Always test the cURL examples against your actual API. LLMs can produce syntactically correct but logically wrong request bodies.
  • Add to version control: Save the generated docs as markdown files alongside your code so they stay in sync with changes.

developerwritingdocsquality-improvement

Get more from this prompt

Save it, score it with AI, optimize it, and track every version. Free to start.

AI quality score on 6 criteria
One-click optimization with 3 strategies
Version history to track improvements