We introduce relative noncommutative Calabi–Yau structures defined on functors of differential graded categories. Examples arise in various contexts such as topology, algebraic geometry, and representation theory. Our main result is a composition law for Calabi–Yau cospans generalizing the classical composition of cobordisms of oriented manifolds. As an application, we construct Calabi–Yau structures on topological Fukaya categories of framed punctured Riemann surfaces.