Is there a way to programmaticaly generate documents?

You can use a similar process to what you already have with jinja templating. In fact, you could even use jinja to create a typst document rather than whatever document format you are using right now (I assume you’re doing HTML then converting to PDF).

So, if for example:

<h1>{{ some_heading }}</h1>
<p> Some {{ some_value }} </p>

You’d convert that to

= {{ some_heading }}
Some {{ some_value }}

and so on.

You would then

  1. populate the template with values,
  2. output a temporary typst file
  3. use subprocess and convert it to PDF using typst compile.
  4. delete the temporary file (if need be)
  5. serve the PDF

The bottom line is that you are producing a string, writing it to file, and using typst to convert it. There are multiple ways to produce that string, jinja being one of them (and not a bad option imo).