In this paper we consider the optimal reinsurance problem in endogenous form with respect to general convex risk measures ϱ and pricing rules π. By means of a subdifferential formula for compositions in Banach spaces we first characterize optimal reinsurance contracts in the case of one insurance taker and one insurer. In the second step we generalize the characterization to the case of several insurance takers. As a consequence we obtain a result saying that cooperation brings less risk compared to insurance takers acting individually. Our results extend previously known results from the literature.