The reference number you’re referring to, is issued by the Iranian Ministry of Foreign Affairs to visa applicants.
It is mandatory to get one prior to being issued a visa, but you do not need one to book a flight, or even to board your flight. The airline generally will not look for it, since they will see in Timatic that you are eligible for a visa on arrival.
It’s not mandatory to have a reference number if you wish to obtain a visa on arrival, but it will make the visa-on-arrival process much faster if you have a reference number.
Note that visas on arrival can only be obtained at the major airports in Iran. You can’t obtain a visa on arrival if you enter via land, and will need a regular visa in this case.