For rear flat mount calipers, you must measure the frame thickness (the diameter of the tube where the bolt passes through) to select the appropriate bolt. According to manufacturer specifications from Sram, the bolts must be 5 mm - 7 mm longer:
Liguria Cycling Lodge San Biagio, Italy. Rudi, bicycle builder. Road and gravel bicycles, one by one assembled. Test, rent and tour bicycle service on the Italian Riviera, Cote d'Azur. B&B for cyclists, serviced accommodation.