middleware api