Best ChatGPT Prompt for “Write API Documentation”
ChatGPT responds best to Markdown-formatted prompts with role assignment, clear headers, and constraints placed at the end. It gives higher priority to end-positioned instructions, so placing your most critical requirements last produces significantly better results. This free template is optimized specifically for ChatGPT, achieving approximately 37% token reduction compared to unoptimized prompts while producing higher quality output.
Optimize Any Prompt Instantly
Stop manually formatting prompts for each AI model. PromptOptimizr auto-restructures your prompts for ChatGPT, Claude, Gemini, Cursor, and Claude Code — with 3 optimization styles.
What Most People Type
Optimized ChatGPT Prompt
# Task As an expert technical writer specializing in API documentation, write comprehensive documentation for a REST endpoint. # Requirements * Clearly define the purpose of the endpoint. * Detail the HTTP method used (e.g., GET, POST, PUT, DELETE). * Specify the full endpoint URL. * Describe all request parameters, including their data type, whether they are required or optional, and a brief explanation of their purpose. Include 2-3 examples of common parameter combinations. * Outline the structure of the request body, if applicable, detailing each field, its data type, and whether it's required or optional. Provide 1-2 examples of valid request bodies. * Describe the possible response codes (e.g., 200 OK, 400 Bad Request, 404 Not Found, 500 Internal Server Error). * For each successful response code, detail the structure of the response body, including field names, data types, and descriptions. Provide 1-2 examples of successful response bodies. * For error response codes, describe the structure of the error response body, including common error fields like `errorCode` and `message`. Provide 1-2 examples of error response bodies. * Include a section on authentication and authorization requirements, if any. * Add a section for usage examples, demonstrating 2-3 common use cases with sample requests and expected responses. * Ensure all technical terms are accurate and clearly defined. * The documentation should be suitable for developers integrating with the API. # Output Format * Use Markdown for all formatting. * Structure the documentation using the following headers: "Endpoint Overview", "Request Details", "Response Details", "Error Handling", "Authentication", and "Usage Examples". * Use bullet points for lists of parameters, fields, and response codes. * Use code blocks for examples of requests, responses, and request/response bodies. * Place critical constraints, such as adherence to specific formatting or inclusion of all listed sections, at the end of this prompt.
Why This ChatGPT Prompt for “Write API Documentation” Works Better
When you type “Write API documentation for my REST endpoint” into ChatGPT, it lacks structure — ChatGPT has to guess what format you want, how detailed to go, and what to prioritize. The optimized version removes that guesswork.
It uses Markdown headers to organize the task, adds bounded constraints (specific numbers, word counts, formats), and places the most critical instructions at the end — where ChatGPT pays the most attention.
This Prompt Optimized for Other AI Models
Each AI model processes instructions differently. See how this same prompt is optimized for:
Frequently Asked Questions
What makes a good ChatGPT prompt for write api documentation?
ChatGPT responds best to Markdown-formatted prompts with role assignment, clear headers, and constraints placed at the end. It gives higher priority to end-positioned instructions, so placing your most critical requirements last produces significantly better results.
Can I use this prompt template for free?
Yes — copy the optimized prompt below and paste it directly into ChatGPT. For unlimited prompt optimization across all 5 AI models, try PromptOptimizr free with 10 prompts per month. You can also use the Chrome extension to optimize prompts directly inside ChatGPT.
Why is this prompt different from a generic one?
Each AI model processes instructions differently. ChatGPT has specific formatting preferences — this prompt is structured to work with those preferences, not against them. The result is better output quality with approximately 37% fewer tokens.
More ChatGPT Prompt Templates
Optimize Prompts Without Leaving ChatGPT
The PromptOptimizr Chrome Extension injects directly into ChatGPT's interface. No tab switching — click the optimize button right inside the chat, pick your style, and get a model-specific prompt instantly. Works inside ChatGPT, Claude, and Gemini.
Get the Free Chrome Extension →