Create PDF of a query through API template

This is how I approached apitemplate.io implementation.
First, I got to template the data that the document will comprise of. The table was tricky but I just copied the sample file and adjusted it to my test case's need


Here I have two tables with the code to work through the items and some totals values
The output is as below

Now for the JSON to drive this, sample in the template is

The tables covered by children and pay

Back to retool, I have the data derived from tables as well as some single fields


Within this sidebar, I call the query to run report.

pdf trigger


sample: when you expand out children data
[{"id":14,"name":"Ann-Mary Nelson","dob":"2020-03-25","parentID":27,"gender":"girl","enrollDate":"2024-03-15"},{"id":15,"name":"Juliet Nelson","dob":"2020-03-25","parentID":27,"gender":"girl","enrollDate":"2024-03-15"},{"id":16,"name":"Patrick Nelson","dob":"2021-05-19","parentID":27,"gender":"boy","enrollDate":"2024-02-12"}]
sample: when you expand out pay data
[{"id":2,"parentID":3,"childID":1,"payDate":"2024-02-27","schedule":"Jan,Feb,Mar","comment":"Transport","payAmount":75},{"id":3,"parentID":3,"childID":1,"payDate":"2024-02-26","schedule":"Apr,May,Jun","comment":"SunScreen","payAmount":16},{"id":5,"parentID":3,"childID":1,"payDate":"2024-03-06","schedule":"Jan,Feb,Mar","comment":"additional play cover","payAmount":17},{"id":6,"parentID":3,"childID":1,"payDate":"2024-03-06","schedule":"Jan,Feb,Mar","comment":"additional play cover","payAmount":17},{"id":14,"parentID":3,"childID":2,"payDate":"2024-03-09","schedule":"Jan,Feb,Mar","comment":"top-up","payAmount":48},{"id":15,"parentID":3,"childID":1,"payDate":"2024-03-13","schedule":"Jan,Feb,Mar","comment":"Transport","payAmount":65},{"id":18,"parentID":3,"childID":1,"payDate":"2024-03-15","schedule":"Jan,Feb,Mar","comment":"test","payAmount":4},{"id":19,"parentID":3,"childID":2,"payDate":"2024-03-15","schedule":"Jan,Feb,Mar","comment":"for child 2","payAmount":6},{"id":20,"parentID":3,"childID":1,"payDate":"2024-03-16","schedule":"Jan,Feb,Mar","comment":"school transport cover","payAmount":17}]

and of course on the REST API, think you covered this OK.
Hope that helps.