Back to guide/General Productivity

Coding: API Endpoint

Specifying the full contract (method, route, auth, schema) upfront means the generated code matches your architecture. Requiring error handling and tests produces production-ready code.

ai-prompt-templates-freeframeworkendpoint_purposehttp_method
Edit View
Prompt
Create a {{framework}} API endpoint for {{endpoint_purpose}}.

Specifications:
- Method: {{http_method}}
- Route: {{route_path}}
- Auth: {{auth_type}} (e.g., JWT, API key, none)
- Request body: {{request_schema}}
- Response: JSON with proper status codes (200, 400, 401, 404, 500)

Requirements:
- Input validation with descriptive error messages
- Proper error handling (try/catch, don't expose internal errors)
- TypeScript types for request and response
- One integration test example using {{test_framework}}

Add inline comments explaining non-obvious decisions.

Variables to customize

{{framework}}{{endpoint_purpose}}{{http_method}}{{route_path}}{{auth_type}}{{request_schema}}{{test_framework}}

Why this prompt works

Specifying the full contract (method, route, auth, schema) upfront means the generated code matches your architecture. Requiring error handling and tests produces production-ready code.

Save this prompt to your library

Organize, version, and access your best prompts across ChatGPT, Claude, and Cursor.