As has been documented in different studies, there is a close relationship between capital flows and domestic credit. This relationship emerges from different channels, which are usually not directly identified. In this paper, a principal-agent approach is proposed in order to disentangle the distinct channels through which shocks on capital debt flows can affect credit-related variables. The model predicts that a foreign credit crunch will not only adversely affect aggregate credit, but will reduce the proportion of firms with access to intermediated funds. Using a comprehensive micro data set for the period comprised between 1999Q1-2012Q1 on foreign debt flows and the relevant credit-related variables, a VEC model is estimated to empirically validate the predictions from the theoretical framework. Results confirm that, in the short-run, a negative shock to foreign funds effectively reduces the proportion of firms with access to intermediated finance (both local and foreign), whilst at the same time induces a substitution of funding by firms from foreign to local sources, thus effectively having a positive effect on domestic credit growth. Nonetheless, the estimated long-run relationship indicates that capital debt flows and domestic credit growth are positively related. These results have important policy implications, related with the potential impact on credit (and access) generated by the use of certain macro prudential measures.