The cross section for W or Z boson production in association with two photons is measured in proton-proton collisions at a centre-of-mass energy of 13 TeV. The data set corresponds to an integrated luminosity of 137 fb−1 collected by the CMS experiment at the LHC. The W → ℓν and Z → ℓℓ decay modes (where ℓ = e, μ) are used to extract the Wγγ and Zγγ cross sections in a phase space defined by electron (muon) with transverse momentum larger than 30 GeV and photon transverse momentum larger than 20 GeV. All leptons and photons are required to have absolute pseudorapidity smaller than 2.5. The measured cross sections in this phase space are σ(Wγγ) = $$ {13.6}_{-1.9}^{+1.9}{\left(\mathrm{stat}\right)}_{-4.0}^{+4.0} $$
13.6
−
1.9
+
1.9
stat
−
4.0
+
4.0
(syst) ± 0.08 (PDF + scale) fb and σ(Zγγ) = $$ {5.41}_{-0.55}^{+0.58}{\left(\mathrm{stat}\right)}_{-.070}^{+0.64} $$
5.41
−
0.55
+
0.58
stat
−
.070
+
0.64
(syst) ± 0.06 (PDF + scale) fb. Limits on anomalous quartic gauge couplings are set in the framework of an effective field theory with dimension-8 operators.