Write an API Endpoint
A prompt that produces a clean, validated API route with proper error handling, not a toy example.
5-10 min|Intermediate
BuildQuick WinDeveloper
Prompt Template
Write a [POST/GET/etc.] API route at [path] that does the following: 1. Accepts: [describe the request body/params with types] 2. Validates: [list validation rules] 3. Does: [describe the business logic] 4. Returns: [describe the success response shape] 5. Error cases: [list specific error scenarios and their HTTP status codes] Use [framework-specific conventions, e.g. Next.js Route Handlers, Express, etc.]. Include input validation. Do not use any external validation library unless I specify one.
You define the contract upfront. The AI knows exactly what to build, what to validate, and how to handle errors instead of guessing at all three.
Any time you need a new API endpoint. Adapt the framework instruction to match your stack.