We study the optimal management of capital flows in a small open economy model with financial frictions and multiple policy instruments. The paper reports two main findings. First, both foreign exchange intervention (FXI) and macroprudential polices are tools complementary to the monetary policy rate that can largely reduce inflation and output volatility in a scenario of capital outflows. Second, the optimal policy mix depends on the underlying shock driving capital flows. FXI takes the leading role in response to foreign interest rate shocks, while macroprudential policy becomes the prominent tool for domestic risk shocks. These results highlight the importance of calibrating the use of multiple instruments according to the underlying shocks that induce shifts in capital flows.