⌨️ Codingintermediateapirestbackendexpressfastapi

Write a REST API Endpoint

Generate a complete REST API endpoint with validation, error handling, authentication check, and documentation.

The Prompt

prompt.txt
Write a complete REST API endpoint for the following specification. Include:
1. Route handler with proper HTTP method
2. Input validation and sanitization
3. Authentication/authorization check (JWT or API key)
4. Business logic implementation
5. Proper error responses (400, 401, 403, 404, 500)
6. Success response with correct status code
7. Inline comments explaining key decisions

Framework: [EXPRESS/FASTAPI/NEXTJS ROUTE HANDLER — specify]
Endpoint specification:
[DESCRIBE YOUR ENDPOINT — e.g., POST /api/users — creates a new user with email and password, returns user object without password]

Database/ORM available: [PRISMA/MONGOOSE/SQLALCHEMY — specify]

Example Output

Generated a complete Express.js POST /api/users handler with Zod validation, bcrypt password hashing, Prisma database insert, JWT token generation, and structured error responses for duplicate email (409) and validation failures (400).

FAQ

Which AI model is best for Write a REST API Endpoint?

GPT-4o or Claude Sonnet 4. Specify your framework explicitly for best results.

How do I use the Write a REST API Endpoint prompt?

Copy the prompt, replace the [BRACKETED] placeholders with your specific information, and paste into your preferred AI assistant (ChatGPT, Claude, Gemini, etc.). Generated a complete Express.js POST /api/users handler with Zod validation, bcrypt password hashing, Prisma database insert, JWT token generation, and structured error responses for duplicate email (409) and validation failures (400).