When restructuring daemon routes for REST conformance, check each route against this list. Fix one violation per commit.
| Method | Must be… | Creates? | Idempotent? | Cacheable? |
|---|---|---|---|---|
| GET | Read-only, no side effects | No | Yes | Yes |
| POST | Create new resource | Yes | No | No |
| PUT | Replace entire resource | No (update) | Yes | No |
| PATCH | Partial update | No | No | No |
| DELETE | Remove resource | No | Yes | No |
| Scenario | Correct Code | Common Mistake |
|---|---|---|
| Successful GET | 200 OK | — |
| Successful POST (create) | 201 Created | 200 OK |
| Successful PUT/PATCH | 200 OK | — |
| Successful DELETE | 204 No Content | 200 with empty body |
| Resource not found | 404 Not Found | 200 with {error: true} |
| Invalid input | 400 Bad Request | 500 Internal Error |
| Unauthorized | 401 Unauthorized | 403 Forbidden |
| Forbidden | 403 Forbidden | 401 Unauthorized |
| Conflict (duplicate) | 409 Conflict | 400 Bad Request |
| Rate limited | 429 Too Many Requests | 503 Service Unavailable |
| Server error | 500 Internal Server Error | — |
| Not implemented | 501 Not Implemented | 404 |
| Service unavailable | 503 Service Unavailable | 500 |
Location header pointing to the new resourceAll error responses should follow a consistent format:
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Task name is required",
"details": [
{ "field": "name", "issue": "must not be empty" }
]
}
}
Location: /api/tasks/{id} headerContent-Type: application/jsonX-RateLimit-Limit and X-RateLimit-RemainingRetry-After header when appropriate/api/tasks not /api/getTasks/api/tasks not /api/task/api/tasks/{id}/events not /api/taskEvents?taskId={id}/api/v1/... or /api/... (pick one, be consistent)?page=1&limit=20)?limit=1000000){ "data": [...], "pagination": { "page": 1, "limit": 20, "total": 142 } }