how to add variables task and process with the API
Process and task variables (and also business variables) are part of the process definition. The process definition cannot be updated live using APIs.
The process definition is created in Bonita Studio. Bonita Studio use some Bonita Engine internal methods to create the process definition. Such methods are not part of a public API and so are not documented. You can dig into the Bonita Engine source code to find the method that allow to create a process definition (sorry but I have limited knowledge on that so I cannot help more).