The optimum parameters for the generation of synchrotron radiation in ultraintense laser pulse interactions with planar foils are investigated with the application of Bayesian optimisation, via Gaussian process regression, to 2D particle-incell simulations. Individual properties of the synchrotron emission, such as the yield, are maximised, 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 polarisation of the laser light. The results demonstrate the utility of applying a machine learning-based optimisation approach and provide new insights into the physics of radiation generation in multi-petawatt laser-foil interactions, which will inform the design of experiments in the QED-plasma regime.