X-ray photoelectron spectroscopy (XPS) is a widely used standard method in the analysis of surfaces. In its conventional form a vacuum technique, it was adapted to samples in ambient pressures up to around 1 mbar already in the 1970s. However, it is only during the past 15 years that ambient pressure x-ray photoelectron spectroscopy (APXPS) has become a standard <I>in situ</I> measurement technique, as a result of the advent of third-generation synchrotron light sources and improved electron energy analysers. We will provide an introduction to APXPS, its technical realisation, and, using a number of case studies, its capabilities for the identification of surface species, structure, and reactions. In particular, we will discuss how we have used APXPS in the <I>in situ</I> study of the atomic layer deposition (ALD) of light and heavier element materials. The presentation will also include an overview of APXPS studies of Mg and other materials.