code: public JSONObject batchRules(List<JSONObject> rules, boolean forwardToReplicas, boolean clearExistingRules, RequestOptions requestOptions) throws AlgoliaException {
      JSONArray array = new JSONArray();
      for (JSONObject obj : rules) {
        array.put(obj);
      }
  
      return client.postRequest("/1/indexes/" + encodedIndexName + "/rules/batch?forwardToReplicas=" + forwardToReplicas + "&clearExistingRules=" + clearExistingRules, array.toString(), true, false, requestOptions);
    }
docs: Add or Replace a list of synonyms
  
  @param rules              the list of rules to add/replace
  @param forwardToReplicas  Forward this operation to the replica indices
  @param clearExistingRules Replace the existing query rules with this batch
  @param requestOptions     Options to pass to this request