---
title: "Generate notebook patches from parameter choices"
method: POST
path: "/cases/generate_notebook"
tags: ["cases"]
---

# Generate notebook patches from parameter choices

`POST /cases/generate_notebook`

Generate patches that apply user-chosen parameter values to a case
notebook. Each parameter's top-level assignment is located in the
notebook's parameter cell (the code cell tagged "parameters"; only
that cell is ever rewritten) and its right-hand side is
deterministically replaced with the given value; the title describing
the resulting computation is generated by the LLM. Returns the title
and a list of per-cell patches.

## Request body

- object
  - `case_template_id` string — Public id of the case template the notebook belongs to. When present, the template's parameter definitions (value types, labels and units) drive value quoting and the generated title; without it the current right-hand side of each assignment decides the quoting.
  - `language` 'ja' | 'en' — Language for the generated title. Defaults to "ja".
  - `notebook` object, required — The notebook JSON object (.ipynb) to rewrite.
  - `parameters` object[], required — Parameter values to apply to the notebook.
    - `value` string, required — New value for the variable.
    - `variable_name` string, required — Name of the notebook variable to rewrite.

## Response `200`

Notebook patches generated successfully

- object
  - `patches` object[], required
    - `cell_index` integer, required — Zero-based index of the cell to edit in notebook.cells.
    - `diff` string, required — Unified diff that rewrites the cell source.
  - `title` string, required — Short title describing the computation with the applied parameters.

## Other responses

- `400` — Bad request
- `503` — Service unavailable
- `504` — Gateway timeout
- `default` — Other error

---

[API](https://skmtc.dev/matlantis/apis/matlantis-web-ui-backend-api.md) · [All operations](https://skmtc.dev/matlantis/apis/matlantis-web-ui-backend-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/matlantis/matlantis-web-ui-backend-api/revisions/b155f3a32673/schema)
