API Design Standards
Overview
This skill defines API design standards for consistent, reliable, and developer-friendly APIs. Good API design reduces integration friction, prevents bugs, and makes cross-company collaboration smooth.
When to Use
- When designing any new API endpoint or service interface
- When modifying existing APIs
- When reviewing API specifications or documentation
- When integrating between companies or external services
- Don't use when: Building internal-only functions with no network exposure
Core Procedures
Step 1: Design Principles
Apply these principles to all API design:
- RESTful: Use standard HTTP methods (GET, POST, PUT, PATCH, DELETE) appropriately
- Resource-Based: URLs represent resources, actions are HTTP methods
- Consistent Naming: Use lowercase-with-dashes for paths, plural nouns for collections
- Versioned: Include version in URL or header from day one
- Documented: Every endpoint, parameter, and response documented
Step 2: Endpoint Design
GET /api/v1/{resource} # List resources (paginated)
GET /api/v1/{resource}/{id} # Get specific resource
POST /api/v1/{resource} # Create new resource
PUT /api/v1/{resource}/{id} # Replace resource
PATCH /api/v1/{resource}/{id} # Partial update
DELETE /api/v1/{resource}/{id} # Delete resource
Step 3: Request Standards
- Query Parameters: Filtering (?status=active), sorting (?sort=created_at:desc), pagination (?page=1&limit=20)
- Request Body: JSON content type, validated against schema, clear error messages
- Headers: Content-Type, Accept, Authorization with Bearer token
- Idempotency: POST not guaranteed idempotent, PUT/PATCH/DELETE are
Step 4: Response Standards
All responses include:
- Appropriate HTTP status code (200, 201, 400, 401, 403, 404, 409, 422, 429, 500)
- JSON response body for successful responses
- Consistent error format:
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Human-readable description",
"details": [{"field": "name", "issue": "Required field"}]
}
}
- Pagination metadata for collection responses
Step 5: Security Standards
- Authentication required for all non-public endpoints
- Authorization checked for every resource access
- Rate limiting applied to prevent abuse
- Input validation and sanitization on all parameters
- HTTPS required, never transmit over HTTP
- No secrets in URLs, query parameters, or error messages
Quality Checklist
Error Handling
- Error: API design doesn't fit RESTful pattern
Response: Document why non-RESTful approach is needed, get architecture review
- Error: Breaking change needed to existing API
Response: Create new version, deprecate old version with sunset header, provide migration guide
- Error: Response times exceed SLA
Response: Implement pagination, add caching, optimize queries
Cross-Team Integration
Related Skills: testing-strategy, secrets-handling, documentation-quality-check, data-modeling-standards
Used By: Backend engineers, API developers, Integrators, any agent creating interfaces used by others
1---2name: api-design-standards3description: Use when designing, implementing, or reviewing APIs to ensure consistent, reliable, and developer-friendly interfaces. This skill provides standardized API design principles and patterns across all companies and services.4---56# API Design Standards78## Overview9This skill defines API design standards for consistent, reliable, and developer-friendly APIs. Good API design reduces integration friction, prevents bugs, and makes cross-company collaboration smooth.1011## When to Use12- When designing any new API endpoint or service interface13- When modifying existing APIs14- When reviewing API specifications or documentation15- When integrating between companies or external services16- **Don't use when:** Building internal-only functions with no network exposure1718## Core Procedures1920### Step 1: Design Principles21Apply these principles to all API design:22- **RESTful:** Use standard HTTP methods (GET, POST, PUT, PATCH, DELETE) appropriately23- **Resource-Based:** URLs represent resources, actions are HTTP methods24- **Consistent Naming:** Use lowercase-with-dashes for paths, plural nouns for collections25- **Versioned:** Include version in URL or header from day one26- **Documented:** Every endpoint, parameter, and response documented2728### Step 2: Endpoint Design29```30GET /api/v1/{resource} # List resources (paginated)31GET /api/v1/{resource}/{id} # Get specific resource32POST /api/v1/{resource} # Create new resource33PUT /api/v1/{resource}/{id} # Replace resource34PATCH /api/v1/{resource}/{id} # Partial update35DELETE /api/v1/{resource}/{id} # Delete resource36```3738### Step 3: Request Standards39- **Query Parameters:** Filtering (?status=active), sorting (?sort=created_at:desc), pagination (?page=1&limit=20)40- **Request Body:** JSON content type, validated against schema, clear error messages41- **Headers:** Content-Type, Accept, Authorization with Bearer token42- **Idempotency:** POST not guaranteed idempotent, PUT/PATCH/DELETE are4344### Step 4: Response Standards45All responses include:46- Appropriate HTTP status code (200, 201, 400, 401, 403, 404, 409, 422, 429, 500)47- JSON response body for successful responses48- Consistent error format:49```json50{51 "error": {52 "code": "VALIDATION_ERROR",53 "message": "Human-readable description",54 "details": [{"field": "name", "issue": "Required field"}]55 }56}57```58- Pagination metadata for collection responses5960### Step 5: Security Standards61- Authentication required for all non-public endpoints62- Authorization checked for every resource access63- Rate limiting applied to prevent abuse64- Input validation and sanitization on all parameters65- HTTPS required, never transmit over HTTP66- No secrets in URLs, query parameters, or error messages6768## Quality Checklist69- [ ] RESTful principles applied to all endpoints70- [ ] Consistent naming conventions followed71- [ ] API versioned from day one72- [ ] All endpoints documented with request/response examples73- [ ] Error responses follow standard format74- [ ] Authentication and authorization in place75- [ ] Rate limiting configured76- [ ] Input validation on all parameters7778## Error Handling79- **Error:** API design doesn't fit RESTful pattern80 **Response:** Document why non-RESTful approach is needed, get architecture review81- **Error:** Breaking change needed to existing API82 **Response:** Create new version, deprecate old version with sunset header, provide migration guide83- **Error:** Response times exceed SLA84 **Response:** Implement pagination, add caching, optimize queries8586## Cross-Team Integration87**Related Skills:** testing-strategy, secrets-handling, documentation-quality-check, data-modeling-standards88**Used By:** Backend engineers, API developers, Integrators, any agent creating interfaces used by others