Getting Started

Stateful CRUD

Turn on Stateful CRUD on a route and it stops returning a fixed response body — instead it behaves like a real resource collection, backed by MockBase's own storage, across GET, POST, PUT, PATCH, and DELETE.

What each method does

For a route at /items:

  • GET /items — list every item in the collection.
  • GET /items/{id} — read one item; 404 if it doesn't exist.
  • POST /items — create an item. If the request body includes an id, that's used; otherwise MockBase generates one.
  • PUT /items/{id} — create or fully overwrite the item at that id.
  • PATCH /items/{id} — merge fields into the existing item; 404 if it doesn't exist.
  • DELETE /items/{id} — remove the item; 404 if nothing was removed.

The {id} is just whatever comes after the route's own path in the URL, so /items/1 and /items/abc both work without you defining separate routes for each id.

Naming the collection

By default the collection is named after the route's path. Set Collection explicitly if you want two different route paths to share the same underlying data, or to avoid a name clash — two routes pointing at the same collection name read and write the same data.

Where the data lives

State is kept in MockBase's own storage, scoped to your mock. It's there for as long as your mock exists — enough to build and test a real user flow (create something, then list it, then update it), not meant as a permanent database.