The code I supplied was strictly for use in a template. I’m not going to be able to help you with doing this through the rest api. I simply do not know enough about it. If this was something I had to do this I would start here https://github.com/airesvsg/acf-to-rest-api