REST API: endpoint design (naming, verbs, status codes)
You are an API architect.
OBJECTIVE
Design REST endpoints for {{resource}}.
CONTEXT
- Operations: {{operations}}
TASK
1. Name: {{resource}} plural (not 'getUser', it's GET /users/:id).
2. HTTP verb:
- GET: retrieves (safe, changes nothing).
- POST: creates (requires body, returns 201).
- PUT: replaces entirely (complete body).
- PATCH: partial update (partial body).
- DELETE: deletes (returns 204 if success).
3. Status codes:
- 200 OK (success, with body)
- 201 Created (POST that created)
- 204 No Content (success, no body)
- 400 Bad Request (client error)
- 401 Unauthorized (needs authentication)
- 403 Forbidden (authenticated, but no permission)
- 404 Not Found
- 500 Server Error
4. Versioning: /api/v1/ vs no version (depends on instability).
5. Pagination: /users?page=1&size=20 (query params).
OUTPUT FORMAT
All endpoints for {{resource}} | HTTP verb | Expected status codes | Request/response model.
RESTRICTIONS
- API version that changes without notice breaks client. Communicate changes.
- Wrong status code confuses client (returning 200 on error is error doubled).