# Validation, Errors and REST Design

An API is a promise to everyone who calls it. Design endpoints people can guess, create, update and delete with the right methods and status codes, check every request before trusting it (first by hand, then with Zod), and answer every error the same way.

Updated: November 19, 2026

## [REST Endpoints](https://www.ask-codey.com/courses/nodejs-in-depth/topics/node-rest-endpoints)

1. [Designing REST Endpoints: Create, Update and Delete](https://www.ask-codey.com/lessons/node-rest-endpoints) (Journeyman): A REST API names each kind of thing it holds with a plural noun, such as /tickets, and lets the HTTP method be the verb, so POST answers 201 with the new item, PUT replaces an item, PATCH changes part of it, and DELETE answers 204 with no body.

## [Checking What Comes In](https://www.ask-codey.com/courses/nodejs-in-depth/topics/node-validation)

1. [Checking Input by Hand](https://www.ask-codey.com/lessons/node-validation-by-hand) (Apprentice): A server checks every request body before it saves anything, because any program can send anything, and a validation function collects every problem (a missing field, the wrong type, text that's too long, a value that isn't allowed) so the API can answer 400 with the whole list.
2. [Validating with Zod](https://www.ask-codey.com/lessons/node-validation-with-zod) (Journeyman): Zod writes a request body's rules as a schema, an object that describes the shape the data must have, and safeParse checks a body against it, giving back either the cleaned data or a list of issues that the API turns into its field problems.

## [Handling Errors](https://www.ask-codey.com/courses/nodejs-in-depth/topics/node-error-handling)

1. [Error Handling and Consistent Error Responses](https://www.ask-codey.com/lessons/node-express-error-handling) (Journeyman): Express 5 passes an error from any route, async ones included, to error-handling middleware with four parameters, and a 404 handler after the routes catches every unknown path, so every error the API sends has one JSON shape and no caller ever sees an HTML page or a stack trace.

## [Exercise: Bike Repair Tickets](https://www.ask-codey.com/courses/nodejs-in-depth/topics/exercise-node-bike-repair-tickets)

1. [Exercise: Bike Repair Tickets](https://www.ask-codey.com/lessons/exercise-node-bike-repair-tickets) (Journeyman): Finish Spoke & Chain's tickets API with Express and Zod, checking every new ticket, moving a ticket only to its next status, deleting with 204, and answering every error in one JSON shape, and let Supertest's tests check every answer.

Source: https://www.ask-codey.com/courses/nodejs-in-depth/chapters/node-validation-errors-and-rest
