Skip to main content
The POST /api/save-to-file endpoint persists Studio changes to the local JSON data files on disk. It accepts a projectState object — the full in-memory representation of edited content — and the slug of the page being saved, then writes the updated data to the appropriate file under src/data/ (for example, src/data/pages/about.json for the About page). The Studio editor calls this endpoint automatically when you save in the UI. You can also call it directly from scripts or custom tooling during local development.
This endpoint is only available in local development mode. It writes directly to your project’s source files on the local filesystem. In production, Studio routes saves through a different mechanism — this route will not be active.

Request

  • Method: POST
  • Path: /api/save-to-file
  • Content-Type: application/json
object
required
The full project state object produced by the Studio editor. Contains all pages, collections, and site-level data in their edited form.
string
required
The slug of the page or collection entry being saved — for example "about" or "posts/write-the-readme-first". Used to determine which file on disk to write.

Response

200 OK — The data was written to disk successfully.
boolean
Always true on a successful save.

Error responses