The increasing penetration of distributed energy resources in the distribution grid is producing an ever-heightening interest in the use of the flexibility on offer by said distributed resources as an enhancement for the distribution grid operator. This paper proposes an optimization problem which enables satisfaction of distribution system operator requests on flexibility. This is a decision-making problem for a new aggregator type called Smart Energy Service Provider (SESP) to schedule flexible energy resources. This aggregator operates a local electricity market with high penetration of distributed energy resources. The optimization operation problem of SESP is formulated as an MILP problem and its performance has been tested by means of the simulation of test cases in a local market. The novel problem has also been validated in a microgrid laboratory with emulated loads and generation units. The performed tests produced positive results and proved the effectiveness of the proposed solution.