Skip to main content
AIPromptIndex
GitHub Copilot Coding advanced

REST API Endpoint Builder

Added Apr 1, 2026

Build a complete REST API endpoint for [ENDPOINT_PURPOSE] in [FRAMEWORK]. The endpoint should handle [HTTP_METHODS] requests at the path [ROUTE_PATH]. Include input validation using [VALIDATION_LIBRARY], proper error handling with appropriate HTTP status codes, authentication middleware check, rate limiting configuration, and comprehensive JSDoc or docstring documentation. Write the controller logic, service layer, and data access layer as separate files following clean architecture principles. Include example request/response payloads for each HTTP method and Swagger/OpenAPI documentation annotations.
0
Share
Try in GitHub Copilot

About This Prompt

Building robust API endpoints involves much more than writing a route handler. This prompt generates the full stack of an endpoint including validation, error handling, authentication, and documentation layers. The clean architecture separation means you get maintainable code with proper separation of concerns from the start. The included Swagger annotations save you the tedious step of writing API documentation after the fact. This is especially valuable for backend developers starting new microservices or adding endpoints to existing APIs who want consistent, well-structured code.

Variables to Customize

[ENDPOINT_PURPOSE]

What the endpoint does

Example: managing user subscription plans

[FRAMEWORK]

Backend framework to use

Example: Express.js with TypeScript

[HTTP_METHODS]

Which HTTP methods to implement

Example: GET, POST, PUT, DELETE

[ROUTE_PATH]

The URL path for the endpoint

Example: /api/v1/subscriptions

[VALIDATION_LIBRARY]

Validation tool to use

Example: Zod

Tips for Best Results

  • Specify your database ORM if you want the data access layer to match your stack
  • Add authentication method details for more accurate middleware code
  • Request integration tests as a follow-up prompt

Example Output

// subscriptions.controller.ts
import { Router, Request, Response, NextFunction } from 'express';
import { SubscriptionService } from './subscriptions.service';
import { CreateSubscriptionSchema, UpdateSubscriptionSchema } from './subscriptions.validation';
import { authenticate } from '../middleware/auth';
import { rateLimit } from '../middleware/rateLimit';

/**
 * @swagger
 * /api/v1/subscriptions:
 *   get:
 *     summary: List all subscriptions for the authenticated user
 */
api rest backend clean-architecture swagger

Get the Best AI Prompts Weekly

Curated prompts, tips, and guides delivered to your inbox every week. Free.