Treat sections as entries in a table

This is what Im working with now, but looking to be able to automate this with a button or something. In the end automating with API. See my use case here: Combining a section and a table, automatically