The massive integration of renewable energy resources increases the uncertainty with respect to real-time operation of the electrical systems. This transition introduces new challenges and opportunities for various entities that are involved in energy generation, transmission, distribution and consumption such as system operators and market participants in the wholesale electricity market. The concept of Decentralized Energy Management or Demand Response is emerging as one of the main approaches to resolve the violations of the network operation limits and to increase the flexibility of the system. This paper introduces an interaction framework for trading flexibility among proactive end-users in an economically efficient way. It proposes new market participants with their roles and functionalities, that will operate alongside the existing ones to ensure market efficiency and to enable secure operation of distribution grids. The proposed framework consists of a main mechanism called ‘ahead-markets scheduling’. The ahead-markets scheduling includes two sub-mechanisms, day-ahead and intra-day, which are operated by a local flexibility market operator. The ahead-markets scheduling provides a trading platform that allows market participants to reflect their need(s) for flexibility and to monetize flexibility services in a fair and competitive manner. It enables flexibility trades which will eventually facilitate network management for the system operator.