Abstract:The role of the distribution system operator (DSO) is evolving with the increasing possibilities of demand management and flexibility. Rather than implementing conventional approaches to mitigate network congestions, such as upgrading existing assets, demand flexibility services have been gaining much attention lately as a solution to defer the need for network reinforcements. In this paper, a framework for a decentralized local market that enables flexibility services trading at the distribution level is introduced. This market operates on two timeframes, day-ahead and real-time and it allows the DSO to procure flexibility services which can help in its congestion management process. The contribution of this work lies in considering the uncertainty of demand during the day-ahead period. As a result, we introduce a probabilistic process that supports the DSO in assessing the true need of obtaining flexibility services based on the probability of congestion occurrence in the following day of operation. Besides being able to procure firm flexibility for high probable congestions, a new option is introduced, called the right-to-use option, which enables the DSO to reserve a specific amount of flexibility, to be called upon later if necessary, for congestions that have medium probabilities of taking place. In addition, a real-time market for flexibility trading is presented, which allows the DSO to procure flexibility services for unforeseen congestions with short notice. Also, the effect of the penetration level of flexibility on the DSO's total cost is discussed and assessed. Finally, a case study is carried out for a real distribution network feeder in Spain to illustrate the impact of the proposed flexibility framework on the DSO's congestion management process.