Expert in RESTful API design, endpoint structure, HTTP methods, status codes, and API best practices. Use this skill when designing new APIs, reviewing endpoint structure, or ensuring REST compliance.
I am an expert in RESTful API design with deep knowledge of:
Resources should be:
/api/users not /api/user/api/projects not /api/Projects/api/task-categories not /api/task_categories or /api/taskCategoriesGET /api/resources # List all resources
GET /api/resources/:id # Get single resource
POST /api/resources # Create new resource
PUT /api/resources/:id # Update resource (full replacement)
PATCH /api/resources/:id # Update resource (partial)
DELETE /api/resources/:id # Delete resource
GET /api/users/:userId/tasks # Get tasks for a user
GET /api/users/:userId/tasks/:taskId # Get specific task for a user
POST /api/users/:userId/tasks # Create task for a user
Nesting Guidelines:
/api/tasks?userId=123 vs /api/users/123/tasks| Method | Purpose | Idempotent | Safe | Request Body | Response Body |
|---|---|---|---|---|---|
| GET | Retrieve resource(s) | ✅ | ✅ | ❌ | ✅ |
| POST | Create resource | ❌ | ❌ | ✅ | ✅ |
| PUT | Replace resource | ✅ | ❌ | ✅ | ✅ |
| PATCH | Update resource | ❌ | ❌ | ✅ | ✅ |
| DELETE | Delete resource | ✅ | ❌ | ❌ | ❌/✅ |
Idempotent: Multiple identical requests have same effect as single request
Safe: Does not modify server state
// Single resource
{
"id": 1,
"title": "Complete API design",
"status": "in-progress",
"createdAt": "2026-03-23T10:00:00Z",
"updatedAt": "2026-03-23T12:00:00Z"
}
// Collection
{
"data": [...],
"pagination": {
"total": 100,
"page": 1,
"limit": 20,
"totalPages": 5
}
}
// Single error
{
"error": {
"status": 400,
"message": "Invalid request",
"code": "INVALID_INPUT"
}
}
// Validation errors
{
"error": {
"status": 422,
"message": "Validation failed",
"code": "VALIDATION_ERROR",
"details": [
{
"field": "email",
"message": "Invalid email format"
},
{
"field": "password",
"message": "Password must be at least 8 characters"
}
]
}
}
GET /api/tasks?status=completed
GET /api/tasks?priority=high&status=in-progress
GET /api/tasks?sort=createdAt:desc
GET /api/tasks?sort=priority:asc,createdAt:desc
GET /api/tasks?page=2&limit=20
GET /api/tasks?offset=40&limit=20
GET /api/tasks?fields=id,title,status
GET /api/tasks?search=design
GET /api/tasks?q=api+development
Recommended approach: URL path versioning
/api/v1/tasks
/api/v2/tasks
Alternative approaches:
Accept: application/vnd.api+json;version=1/api/tasks?version=1Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
POST /api/auth/register # Create account
POST /api/auth/login # Authenticate
POST /api/auth/logout # End session
POST /api/auth/refresh # Refresh token
Include in endpoint documentation:
Example:
### Create Task
Creates a new task for the authenticated user.
**URL**: `/api/tasks`
**Method**: `POST`
**Auth Required**: Yes
**Request Body**:
{
"title": "string (required, 1-200 chars)",
"description": "string (optional)",
"priority": "enum: low|medium|high (default: medium)",
"dueDate": "ISO 8601 date (optional)"
}
**Success Response**: `201 Created`
{
"id": 1,
"title": "Complete API design",
"priority": "high",
"userId": 5,
"createdAt": "2026-03-23T10:00:00Z"
}
**Error Responses**:
- `400 Bad Request`: Invalid input
- `401 Unauthorized`: Not authenticated
- `422 Unprocessable Entity`: Validation errors
When designing or reviewing an API, verify:
❌ Verbs in URLs: /api/getUsers, /api/createTask
✅ Use: GET /api/users, POST /api/tasks
❌ Actions as endpoints: /api/tasks/complete
✅ Use: PATCH /api/tasks/:id with {"status": "completed"}
❌ Inconsistent naming: /api/user, /api/Tasks, /api/project_items
✅ Use: /api/users, /api/tasks, /api/project-items
❌ Wrong status codes: 200 OK for errors, 201 Created for GET
✅ Use: Semantically correct status codes
❌ Exposing implementation details: /api/db/users, /api/v1/api_legacy
✅ Use: Clean, implementation-agnostic URLs
Invoke this skill when you need to:
I will provide expert guidance, best practices, and concrete examples for API design decisions.