functional batch_api middleware