Updating synonyms via ElasticSearch REST api?

I am writing a code to create elasticsearch indexes with the constraint that everything must be done through the elasticsearch REST APIs.

I am able to create the index, update the mapping and settings with the Java client but I am stuck on how to do the same with the synonyms file.

Is there a way to update synonyms via the elasticsearch REST API?

Have you seen https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-synonym-tokenfilter.html?
It shows both file and API methods.