A theory of correlations between N photons of given frequencies and detected at given time delays is presented. These correlation functions are usually too cumbersome to be computed explicitly. We show that they are obtained exactly through intensity correlations between two-level sensors in the limit of their vanishing coupling to the system. This allows the computation of correlation functions hitherto unreachable. The uncertainties in time and frequency of the detection, which are necessary variables to describe the system, are intrinsic to the theory. We illustrate the formalism with the Jaynes--Cummings model, showing how correlations of various peaks at zero or finite time delays bring new insights into the dynamics of open quantum systems.