API Contract First Design
Design a complete API contract before writing any implementation code
Design a complete API for: [FEATURE_OR_SERVICE]
**Consumers:** [WHO_CALLS_THIS — e.g., "React SPA, mobile app, third-party integrations"]
**Auth:** [AUTH_METHOD — e.g., "Bearer JWT", "API key", "public"]
For each endpoint, document:
### [METHOD] /api/v1/[path]
- **Description:** one-line purpose
- **Auth:** required / optional / public
- **Request body:**
```json
{ "field": "type — description" }
```
- **Response (200):**
```json
{ "field": "type — description" }
```
- **Error responses:** 400, 401, 404, 422 with example bodies
- **Rate limit:** requests per minute
Also provide:
- Pagination strategy (cursor-based) with example
- Error response format (consistent across all endpoints)
- Versioning strategy
- TypeScript types for all request/response shapes
- OpenAPI/Swagger snippet for one representative endpoint
Design principles: use nouns not verbs in URLs, plural resource names, consistent naming, proper HTTP methods and status codes.How to Use This Prompt
- 1Copy the prompt template above
- 2Paste into Claude, ChatGPT, or Cursor
- 3Replace [bracketed placeholders] with your specific project details
- 4Iterate on the AI output to refine and customize the results
More API Design Prompts
Related api design templates from the vault
Pagination Design Pattern Chooser
Use this prompt to pagination design pattern chooser with AI assistance
API Rate Limiting with Token Bucket and Quotas
Design and implement a multi-tier rate limiting system with token bucket algorithm, per-user quotas, and clear error responses
REST API Naming Convention Guide
Use this prompt to rest api naming convention guide with AI assistance
Rate Limiter with Sliding Window
PROImplement a production-grade rate limiter with sliding window algorithm
You Might Also Like
Prompts from other categories that share similar tags
REST API Endpoint Generator
Generate a complete CRUD API endpoint with validation and error handling
README Generator from Codebase
Generate a professional README by analyzing the project structure
Code Documentation with JSDoc
Add comprehensive JSDoc documentation to existing code
System Design Document Generator
Generate a comprehensive system design document for a new feature or service
Keep Exploring the Vault