# When It Isn't There: HTTPException and 404

A FastAPI route answers 404 for an item that isn't there by raising HTTPException with a status code and a detail message, which stops the function at once and sends {"detail": ...}, and a route that creates something sets status_code=201 on its decorator.

![Cheat sheet: When It Isn't There: HTTPException and 404](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/8607b0f5a68f44918234594cb561c046.webp)

- Category: FastAPI
- Level: Apprentice
- Tags: 201 Created, 404 Not Found, fastapi, HTTPException, rest-api, Status Code in FastAPI
- Author: Gregor Dzierzon
- Updated: November 23, 2026

Source: https://www.ask-codey.com/cheat-sheets/fastapi-not-found-httpexception-cheat-sheet
