move createorupdate function to the api obj