# Web APIs with Controllers

Web APIs with Controllers: Web APIs with Controllers: an overview, Creating an API Controller, GET, POST, PUT, DELETE, Returning ActionResult&lt;T>.

Updated: November 3, 2026

1. [Web APIs with Controllers: an overview](https://www.ask-codey.com/lessons/web-apis-with-controllers-an-overview) (Apprentice): REST is the common way to design a web API. Each kind of data is a resource with its own address, and the HTTP method says what to do with it. GET, POST, PUT and DELETE match SELECT, INSERT, UPDATE and DELETE, each with its usual status code.
2. [Creating an API Controller](https://www.ask-codey.com/lessons/web-apis-with-controllers-creating-an-api-controller) (Journeyman): An API controller derives from ControllerBase, is marked \[ApiController\], and gets its address from \[Route\]. It asks for its DAO through an interface registered in Program.cs, and its actions return data that ASP.NET Core sends as JSON.
3. [GET](https://www.ask-codey.com/lessons/web-apis-with-controllers-get) (Journeyman): GET reads data. One \[HttpGet\] action returns the whole collection, and an \[HttpGet("{id}")\] action returns one item, its id taken from the address. ASP.NET Core sends what they return as JSON, with 200 OK.
4. [POST](https://www.ask-codey.com/lessons/web-apis-with-controllers-post) (Journeyman): POST creates a new item from the JSON in the request body. The DAO inserts it and returns it with its new id, and the action answers 201 Created with CreatedAtAction, which also says where the new item lives. Invalid bodies get 400 automatically.
5. [PUT](https://www.ask-codey.com/lessons/web-apis-with-controllers-put) (Journeyman): PUT replaces an item with the one in the request body, its id taken from the address. The DAO updates the row and hands back the category as it was saved, and the action answers 200 OK with it, or 404 Not Found when there's no such item.
6. [DELETE](https://www.ask-codey.com/lessons/web-apis-with-controllers-delete) (Journeyman): DELETE removes the item at an address. It sends no body; the action deletes by the id from the route and answers 204 No Content, or 404 Not Found when there was nothing to delete.
7. [Returning ActionResult&lt;T>](https://www.ask-codey.com/lessons/web-apis-with-controllers-returning-actionresult-t) (Journeyman): ActionResult&lt;T> lets an action return either its data or a status code result, such as NotFound(). Return the item to answer 200 with it, or a helper such as NotFound(), BadRequest() or Conflict() to answer with that status instead.

Source: https://www.ask-codey.com/courses/csharp-full-stack-bootcamp/topics/web-apis-with-controllers
