Full answer
Resources and URLs
Use nouns, not verbs, and plural collections:
GET /students list students
GET /students/7 one student
POST /students create
PATCH /students/7 partial update
DELETE /students/7 delete
GET /students/7/attendance attendance records for student 7
Avoid /getStudent?id=7 or /createStudent. Keep nesting shallow (one level is usually enough). For actions that do not fit CRUD, a sub-resource is clearer than a verb: POST /exams/12/publications rather than POST /publishExam.
Methods
GET: read, no side effects, cacheable.POST: create or trigger processing; not idempotent.PUT: replace the whole resource; idempotent.PATCH: partial update.DELETE: remove; idempotent.
Status codes
| Code | Use |
|---|---|
| 200 OK | Successful read or update with a body |
| 201 Created | Resource created; include a Location header |
| 204 No Content | Success, no body (often DELETE) |
| 400 Bad Request | Malformed input or failed validation |
| 401 Unauthorized | Not authenticated (missing or bad credentials) |
| 403 Forbidden | Authenticated but not allowed |
| 404 Not Found | Resource does not exist |
| 409 Conflict | State conflict, such as a duplicate email |
| 422 Unprocessable Content | Valid JSON but semantic validation failed (some APIs use 400 for this) |
| 429 Too Many Requests | Rate limited; send Retry-After |
| 500 / 503 | Server error / temporarily unavailable |
Never return 200 with {"error": ...} in the body; clients and monitoring rely on the code.
Use one error shape everywhere, for example:
{"error": {"code": "EMAIL_TAKEN", "message": "This email is already registered.", "field": "email"}}Lists
Support filters and sorting through query parameters (GET /students?class=10B&sort=-score) and always paginate lists (?limit=50&cursor=...).
Versioning and compatibility
Adding a field is safe. Removing or renaming a field, or changing its type or meaning, breaks clients. For breaking changes, introduce a new version, commonly in the path (/v2/students) or a header, and keep the old version running with a deprecation date.
Other good habits
HTTPS only; authentication through a standard scheme (OAuth 2.0 bearer tokens); idempotency keys on payment-like POSTs; consistent naming (snake_case or camelCase, not both); ISO 8601 timestamps with time zone (2026-12-04T10:15:00Z); documentation in OpenAPI.
By level
Fresher: Name resources as nouns, map CRUD to methods, and use the right common status codes with examples. Getting 401 and 403 right is a common screening check.
Mid: Add error format, pagination, filtering, idempotency and compatibility rules, and design an action endpoint cleanly. Expect a consistent error body and pagination on every list.
Senior: Discuss versioning policy across many clients, long-running operations (202 with a status resource), API governance, rate limit contracts, and how to evolve an API used by partners without breaking them. The answer should describe a deprecation timeline that partners can follow.
Key points
- Plural nouns for resources; HTTP methods carry the action
- Status codes must match the outcome; 401 versus 403 matters
- Use one consistent error body
- Always paginate and allow filtering on lists
- Additive changes are safe; breaking changes need a new version
Common mistakes
- Verbs in URLs like /getStudents
- Returning 200 for errors
- Mixing up 401 and 403
- Removing fields without a new version or deprecation period
Follow-ups
- How would you design an endpoint that triggers a long-running report?
- When would you use PUT instead of PATCH?
- How do you deprecate an API version?
Tips
- Write three example endpoints before talking theory
- Get 401 versus 403 right
- Mention backward compatibility explicitly
Evaluation rubric
- Correct resource naming and method use
- Accurate status codes
- Consistent error format and pagination
- Sensible versioning strategy