The optimum parameters for the generation of synchrotron radiation in ultraintense laser pulse interactions with planar foils are investigated with the application of Bayesian optimization, via Gaussian process regression, to 2D particle-in-cell simulations. Individual properties of the synchrotron emission, such as the yield, are maximized, and simultaneous mitigation of bremsstrahlung emission is achieved with multi-variate objective functions. The angle-of-incidence of the laser pulse onto the target is shown to strongly influence the synchrotron yield and angular profile, with oblique incidence producing the optimal results. This is further explored in 3D simulations, in which additional control of the spatial profile of synchrotron emission is demonstrated by varying the polarization of the laser light. The results demonstrate the utility of applying a machine learning-based optimization approach and provide new insights into the physics of radiation generation in laser–foil interactions, which will inform the design of experiments in the quantum electrodynamics (QED)-plasma regime.