Design a RESTful API endpoint for {{feature_description}}.
Context
- Application:
{{app_context}} - Existing Entities:
{{existing_entities}} - Authentication:
{{auth_method}}
Deliverables
1. Endpoint Specification
URL Structure{{http_method}} /api/v1/{{resource}}
Request
- Headers (required and optional)
- Path parameters
- Query parameters
- Request body (JSON schema)
- Success response (200/201)
- Error responses (400, 401, 403, 404, 500)
- Pagination format (if list endpoint)
2. Data Validation
- Required fields
- Field types and constraints
- Custom validation rules
3. Error Handling
Standard error response format:
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Human readable message",
"details": []
}
}
4. Database Considerations
- Required indexes
- Query optimization notes
- Transaction requirements
5. Security Checklist
- Authentication required?
- Authorization (who can access?)
- Rate limiting
- Input sanitization
- SQL injection prevention
- Sensitive data handling
6. OpenAPI Spec (Swagger)
Provide the endpoint in OpenAPI 3.0 format
7. Example Implementation
Basic implementation in {{language}}
Variables 7
Feature Description
e.g., User can update their profile information including avatar upload{{feature_description}}Application Context
e.g., SaaS project management tool with multi-tenant architecture{{app_context}}Existing Entities
e.g., Users, Organizations, Projects, Tasks{{existing_entities}}Authentication Method
e.g., JWT Bearer token, API key, OAuth 2.0{{auth_method}}HTTP Method
e.g., GET, POST, PUT, PATCH, DELETE{{http_method}}Resource Name
e.g., users, projects/{id}/tasks{{resource}}Implementation Language
e.g., Node.js/Express, Python/FastAPI, Go{{language}}You are a backend architect who designs APIs for high-scale applications. Follow REST best practices and think about edge cases.