AFAIK, It is not possible to create the folders and subfolders in one go via any rest apis. However, please the below rest api which can be used to create folders:
id can be either one of the constants
-my- or an Alfresco Node Identifier (e.g. 444be4a6-5693-4d10-af4b-b55448fe4f97). The POST data defines the folder metadata and looks like in this example:
"name": "My Folder",
"cm:title": "My Folder",
"cm:description": "My new folder"
If you would have to create the folder and subfolders in one go, you would have to create your custom webscript to handle your specific requirement. In your webscript you can include the code to create folders/subfolders based on the path value passed.
See the detailed solution here: https://hub.alfresco.com/t5/alfresco-content-services-forum/how-to-create-directory-structure-using-...
(ACSCE, AWS SAA, Azure Admin)