Skip to content
Backend take-home · 180 minutes

Tasks REST API with validation and tests

You have three hours to build the backend of a small tasks app as a REST API, in the language and framework you would use at work. Users have tasks with a title, an optional due date and a status. The API creates, lists, reads, updates and deletes tasks, validates every input, and stores data in a real database, SQLite or PostgreSQL. Lists are paginated and can be filtered by status. Send a repository with a README and tests. Reviewers score correct behavior, clear errors, data safety and code they would be happy to maintain, not extra features. Authentication can be a fixed user id in a header; say so in the README.

Requirements

  • POST, GET, PATCH and DELETE on /tasks and /tasks/{id}, with the right status codes (201, 200, 204, 400 or 422, 404)
  • Validation: title required and at most 200 characters, status one of open or done, due date a valid date; all field errors returned at once
  • One error shape for the whole API, for example { error, message, fields }
  • GET /tasks is paginated with a limit and a cursor, filters by status, and has a stable order
  • Data lives in SQLite or PostgreSQL, with the schema created by a migration, not by hand
  • A user only sees and changes their own tasks; another user's task id returns 404
  • The repository has a README, tests for the main behavior and a clean commit history

What reviewers look for

  • It works: every endpoint behaves as the README says, with no crash on bad input
  • Validation at the boundary, with errors a client can show next to each field
  • Database use: a migration, constraints that match the rules, parameterised queries
  • Pagination that does not skip or repeat items when tasks are added
  • Layers that are easy to follow: routing, validation, data access, without a framework fight
  • Tests that call the API as a client would, against a real test database
  • Judgment under a time limit: a chosen scope, with the trade-offs written in the README

Check before you hand it in

  • Create, list, read, update and delete all work, and each returns the status code I documented
  • I sent a missing title, a 300-character title and a bad date, and got one clear error listing each field
  • With a second user id, I could not read, change or delete the first user's tasks
  • I paged through more tasks than one page holds, added a task in between, and saw no task twice
  • The README says how to run the API and the tests, and explains my decisions, what I left out, and what I would do with more time
  • Tests cover creating, validating, listing with a filter and the other user's 404, against a test database
  • The history has small commits, and each message says what changed and why
  • I stopped when the three hours ended, and the API was in a state I could send

If there is time

  • An OpenAPI description generated from the code or written by hand
  • Idempotency keys on POST /tasks
  • A Dockerfile so the reviewer can run it with one command
  • Rate limiting per user, with a 429 and a Retry-After header