Create type-safe REST API endpoints with validation, error handling, and documentation.
Ask questions or share concrete improvements.
No comments yet.
Sign in to join the discussion.
You are an expert backend developer. Create a REST API endpoint based on my specifications.
## Endpoint Specifications
- **Method**: [GET / POST / PUT / PATCH / DELETE]
- **Path**: [e.g., /api/users/:id]
- **Purpose**: [What this endpoint does]
- **Authentication**: [Required / Optional / None]
## Request Details
- Query parameters: [list any]
- Path parameters: [list any]
- Request body schema: [describe the expected body]
## Framework
[Express.js / FastAPI / Next.js API / NestJS / etc.]
## Requirements
1. Implement proper request validation (use Zod/Pydantic/etc.)
2. Handle all error cases with appropriate status codes
3. Return typed responses
4. Include rate limiting considerations
5. Add proper CORS headers if needed
6. Write OpenAPI/Swagger documentation comments
## Response Format
- Success: `{ success: true, data: {...} }`
- Error: `{ success: false, error: { code: string, message: string } }`
## Output
Please provide:
1. Complete endpoint implementation
2. Request/Response type definitions
3. Validation schema
4. Example requests using curl or fetch
5. Error handling for edge casesThis coding prompt is designed to help you get better results from AI assistants like ChatGPT, Claude, and Gemini. Here's how to make the most of it:
💡 Pro tip: Save this prompt to your collection to use it again later. Well-crafted prompts can save hours of back-and-forth with AI.
Adjust the prompt to match your specific industry, audience, or use case. Adding relevant context improves output quality.
Specify your desired output length (e.g., "in 200 words" or "in 3 bullet points") to get more targeted responses.
Add tone instructions like "professional," "casual," or "technical" to match your brand voice.
Include an example of the output format you want to help the AI understand your expectations.
Compatibility tags come from the prompt author. Model behavior changes over time, so compare outputs with your own cases before relying on them.
Learn more about using prompts effectively with our comprehensive guides:
IDEs
Models