  We describe the geometry of generic heterotic backgrounds preserving minimal
supersymmetry in four dimensions using the language of generalised geometry.
They are characterised by an $SU(3)\times Spin(6+n)$ structure within
$O(6,6+n)\times\mathbb{R}^+$ generalised geometry. Supersymmetry of the
background is encoded in the existence of an involutive subbundle of the
generalised tangent bundle and the vanishing of a moment map for the action of
diffeomorphisms and gauge symmetries. We give both the superpotential and the
K\"ahler potential for a generic background, showing that the latter defines a
natural Hitchin functional for heterotic geometries. Intriguingly, this
formulation suggests new connections to geometric invariant theory and an
extended notion of stability. Finally we show that the analysis of
infinitesimal deformations of these geometric structures naturally reproduces
the known cohomologies that count the massless moduli of supersymmetric
heterotic backgrounds.
