If it is the version in Repos, you can choose different branches or tags to build different versions through the UI interface.And the RestAPI can only be called in Pipelines. At this time, there is no way to call it before build.
Also, Each task in a pipeline has a Version selector to let you choose the version you want. If you change the version and have problems with your builds, you can revert the pipeline change from the History tab. The ability to restore to an older version of a release pipeline is not currently available. You must manually revert the changes to the release pipeline, then save the pipeline.
If the specific meaning of version you mentioned is not the above two cases, please describe it in detail.