factored out code for api dropping into api system