Programmatically create a new docType

Is it possible to create a new docType programmatically?

Basically i have a CSV file being dropped in and from this i want to create a new docType and then import the data into a new document of the new docType.

The CSV file from time to time will be different, so each new CSV file will be a new docType

Any guidance would be appreciated

I am currently working around my problem, i have CSV with 120 fields, where i wanted to create a docType for the CSV.

I couldn’t find a way to do this via APIs so ended up creating the docType files (json etc) via script and applying it to the app and used bench command “reload-docType” to sync with the DB

that’s my current workaround until i find APIs to create docTypes!!