Back to guide/Developer Tools

API Documentation from Code

Generate complete API docs from your route handler — with realistic examples and a working curl command.

documentationapidevelopmentchatgpt
Edit View
Prompt
Generate API documentation for this endpoint:

```
{{paste your route handler code}}
```

Format as a markdown section with:
1. **Endpoint:** METHOD /path
2. **Description:** One sentence explaining what it does
3. **Authentication:** Required / Optional / None
4. **Request:**
   - Headers (if any)
   - URL parameters
   - Query parameters
   - Request body (JSON schema with types and examples)
5. **Response:**
   - Success response (status code + JSON example with realistic data)
   - Error responses (each possible error code with example)
6. **Example:** Complete curl command that works

Use realistic data in examples (not "string" or "example"). For a user endpoint, use "jane.doe@company.com", not "user@example.com".

Variables to customize

{{paste your route handler code}}

Why this prompt works

'Realistic data, not placeholder strings' produces documentation that developers can actually test with. The curl example makes the endpoint immediately testable.

Save this prompt to your library

Organize, version, and access your best prompts across ChatGPT, Claude, and Cursor.